Skip to content

Commit

Permalink
Update to 2024.10.2
Browse files Browse the repository at this point in the history
- update easytime custom template
- update spa climate entities
  • Loading branch information
jazzyisj committed Oct 15, 2024
1 parent bd4d84a commit 870c896
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 32 deletions.
190 changes: 172 additions & 18 deletions custom_templates/easy_time.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,21 @@
'October',
'November',
'December',
]
],
'time_of_hour':{
0: '{hour} o\'clock',
1: 'a minute past {hour}',
15: 'quarter past {hour}',
30: 'half past {hour}',
45: 'quarter to {hour}',
59: 'a minute to {hour}',
'past_hour': '{minute} past {hour}',
'to_hour': '{minute} to {hour}',
},
'time_of_day':{
'midnight': 'midnight',
'noon': 'noon',
},
},
'sk':{
'_language': 'Slovak',
Expand Down Expand Up @@ -143,7 +157,7 @@
'November',
'December',
]
},
},
'nl':{
'_language': 'Nederlands',
'and': 'en',
Expand Down Expand Up @@ -288,7 +302,7 @@
'_language': 'Deutsch',
'and': 'und',
'in': 'in',
'ago': 'vor',
'ago': 'vor %s',
'now': 'jetzt',
'lose': 'Du verlierst',
'gain': 'Du gewinnst',
Expand Down Expand Up @@ -349,7 +363,7 @@
'Juli',
'August',
'September',
'October',
'Oktober',
'November',
'Dezember',
]
Expand Down Expand Up @@ -851,9 +865,9 @@
'and': 'i',
'in': 'u',
'ago': 'prije',
'now': 'sad',
'now': 'sada',
'lose': 'gubiš',
'gain': 'dobijaš',
'gain': 'dobivaš',
'time':{
'format': '24-hr',
'year': [
Expand Down Expand Up @@ -891,8 +905,8 @@
'today': 'danas',
'tomorrow': 'sutra',
'yesterday': 'jučer',
'next': 'slijedeći',
'last': 'prošli',
'next': 'sljedeći',
'last': 'protekli',
},
'days':[
"Ponedjeljak",
Expand Down Expand Up @@ -989,11 +1003,97 @@
'Listopad',
'Grudzień',
]
},
'ru':{
'_language': 'Русский',
'and': 'и',
'in': 'в',
'ago': 'назад',
'now': 'сейчас',
'lose': 'уменьшение',
'gain': 'увеличение',
'time':{
'format': '24-hr',
'year': [
'г',
'год',
'лет',
],
'week': [
'нед',
'неделя',
'недель',
],
'day': [
'д',
'день',
'дней',
],
'hour': [
'ч',
'час',
'часов',
],
'minute': [
'мин',
'минута',
'минут',
],
'second': [
'сек',
'секунда',
'секунд',
],
},
'delta':{
'today': 'сегодня',
'tomorrow': 'завтра',
'yesterday': 'вчера',
'next': 'следующий',
'last': 'последний',
},
'days':[
"Понедельник",
"Вторник",
"Среда",
"Четверг",
"Пятница",
"Суббота",
"Воскресенье",
],
'months':[
'Январь',
'Февраль',
'Март',
'Апрель',
'Май',
'Июнь',
'Июль',
'Август',
'Сентябрь',
'Октябрь',
'Ноябрь',
'Декабрь',
],
'time_of_hour':{
0: '{hour} часов ровно',
1: '{hour} и 1 минута',
15: '{hour} с четвертью',
30: '{hour} с половиной',
45: 'без четверти {hour}',
59: 'без минуты {hour}',
'past_hour': '{hour} и {minute} минут',
'to_hour': 'без {minute} минут {hour}',
},
'time_of_day':{
'midnight': 'полночь',
'noon': 'полдень',
},
}
} %}
{# DO NOT MODIFY BELOW THIS LINE #}

{% set valid_entity_id_pattern = '^(?!.+__)(?!_)[\\da-z_]+(?<!_)\\.(?!_)[\\da-z_]+(?<!_)$' %}
{% set _bad_value = '?' %}
{% set _durations = {
'year': 31536000,
Expand Down Expand Up @@ -1077,7 +1177,7 @@
{%- endmacro -%}
{%- macro _check_for_duration_sensor(input) %}
{%- if input is string and input | regex_search('^(?!.+__)(?!_)[\da-z_]+(?<!_)\.(?!_)[\da-z_]+(?<!_)$') and input.startswith('sensor') and states[input] is not none and states[input].attributes.device_class is defined and states[input].attributes.unit_of_measurement is defined -%}
{%- if input is string and input | regex_search(valid_entity_id_pattern) and input.startswith('sensor') and states[input] is not none and states[input].attributes.device_class is defined and states[input].attributes.unit_of_measurement is defined -%}
{%- set obj = states[input] -%}
{%- set divisor = _duration_sensor.get(obj.attributes.unit_of_measurement) -%}
{{- (obj.state | float / divisor) | string | as_timedelta -}}
Expand All @@ -1102,7 +1202,7 @@
{#- assume time as string or entity_id -#}
{%- elif input is string and input not in ['', 'None'] -%}
{#- if entity_id -#}
{%- if input | regex_search('^(?!.+__)(?!_)[\da-z_]+(?<!_)\.(?!_)[\da-z_]+(?<!_)$') -%}
{%- if input | regex_search(valid_entity_id_pattern) -%}
{%- if attribute is not none and attribute is string -%}
{{- _to_datetime(state_attr(input, attribute), None) -}}
{%- elif input.startswith('input_datetime') and is_state_attr(input, 'has_date', False) -%}
Expand Down Expand Up @@ -1261,7 +1361,7 @@
{# Returns a time phrase with only the details you care about most of the time. e.g. 3 hours and 4 minutes #}
{%- macro custom_time(uptime, values='', language=default_language, utc=False, short=False) %}
{%- set args = values.replace(' ', '').split(', ') | list if values is string else [] %}
{%- set args = values.replace(' ','').split(',') | list if values is string else [] %}
{%- if args %}
{{- _time(uptime, None, language, args, False, utc, short) }}
{%- else %}
Expand All @@ -1270,7 +1370,7 @@
{%- endmacro %}
{%- macro custom_time_attr(uptime, attribute, values='', language=default_language, utc=False, short=False) %}
{%- set args = values.replace(' ', '').split(', ') | list if values is string else [] %}
{%- set args = values.replace(' ','').split(',') | list if values is string else [] %}
{%- if args %}
{{- _time(uptime, attribute, language, args, False, utc, short) }}
{%- else %}
Expand All @@ -1291,7 +1391,7 @@
{%- endmacro %}
{%- macro custom_time_between(t1, t2, values='', attr1=None, attr2=None, language=default_language, utc1=False, utc2=False, max_period='year', short=False) %}
{%- set values = values.replace(' ', '').split(', ') | list if values is string else [] %}
{%- set values = values.replace(' ','').split(',') | list if values is string else [] %}
{%- set seconds = _time_between(_delta_seconds, t1, attr1, utc1, t2, attr2, utc2) | float | abs %}
{{- _just_time(seconds, language, values, False, short=short) }}
{%- endmacro %}
Expand Down Expand Up @@ -1337,7 +1437,7 @@
{# Returns a time phrase with only the details you care about most of the time. e.g. in 3 hours and 4 minutes #}
{%- macro custom_relative_time(uptime, values='', language=None, utc=False, short=False) %}
{%- set args = values.replace(' ', '').split(', ') | list if values is string else [] %}
{%- set args = values.replace(' ','').split(',') | list if values is string else [] %}
{%- if args %}
{{- _relative_time(uptime, None, language, args, False, utc, short) }}
{%- else %}
Expand All @@ -1346,7 +1446,7 @@
{%- endmacro %}
{%- macro custom_relative_time_attr(uptime, attribute, values='', language=None, utc=False, short=False) %}
{%- set args = values.replace(' ', '').split(', ') | list if values is string else [] %}
{%- set args = values.replace(' ','').split(',') | list if values is string else [] %}
{%- if args %}
{{- _relative_time(uptime, attribute, language, args, False, utc, short) }}
{%- else %}
Expand Down Expand Up @@ -1501,7 +1601,7 @@
{{- now().strftime(_get_language_time_format(fmat, language)) }}
{%- endmacro %}
{%- set _clock_icon = ['twelve', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven'] %}
{%- set _clock_icon = ['twelve','one','two','three','four','five','six','seven','eight','nine','ten','eleven'] %}
{%- macro clock_icon(hour=None) -%}
{%- if hour is none or hour is not integer -%}
Expand All @@ -1518,6 +1618,8 @@
{%- set idx = month.month - 1 %}
{%- elif month is integer and month > 0 %}
{%- set idx = (month - 1) % 12 %}
{%- elif month | regex_match(valid_entity_id_pattern) %}
{%- set idx = (states(month) | as_datetime | as_local).month - 1 %}
{%- else %}
{%- set idx = now().month - 1 %}
{%- endif %}
Expand All @@ -1529,6 +1631,8 @@
{%- set idx = weekday.weekday() %}
{%- elif weekday is integer and weekday > 0 %}
{%- set idx = (weekday - 1) % 7 %}
{%- elif weekday | regex_match(valid_entity_id_pattern) %}
{%- set idx = (states(weekday) | as_datetime | as_local).weekday() %}
{%- else %}
{%- set idx = now().weekday() %}
{%- endif %}
Expand All @@ -1547,7 +1651,7 @@
{%- set ns = namespace(days=[]) %}
{%- for i in range(-7, 14) %}
{%- set prefix = translate('delta', 'last', language=language) ~ ' ' if i < -1 else translate('delta', 'next', language=language) ~ ' ' if i > 6 else '' %}
{%- set ns.days = ns.days + [ (i | string, prefix ~ _days.get(i, weekday(midnight.weekday() + i + 1, language))) ] %}
{%- set ns.days = ns.days + [ (i | string, prefix ~ _days.get(i, weekday(midnight.weekday() + (i % 7) + 1, language))) ] %}
{%- endfor %}
{%- set collection = dict.from_keys(ns.days) %}
{%- set days = count_the_days(input, attr, utc) %}
Expand All @@ -1568,3 +1672,53 @@
{%- endif %}
{%- endif %}
{%- endmacro %}
{%- macro hour(hour, language=None) %}
{%- if hour is datetime %}
{%- set hour = hour.hour %}
{%- elif hour | regex_match(valid_entity_id_pattern) %}
{%- set hour = (states(hour) | as_datetime | as_local).hour %}
{%- endif %}
{%- set _12 = not (hour % 12) %}
{%- set _24 = not (hour % 24) %}
{%- set _12hr = translate('time','format') == '12-hr' %}
{%- if _12 and _24 and _12hr %}
{{- translate('time_of_day', 'midnight', language=language) }}
{%- elif _12 and _12hr %}
{{- translate('time_of_day', 'noon', language=language) }}
{%- else %}
{{- hour % 12 if _12hr else hour }}
{%- endif %}
{%- endmacro %}
{%- macro clock_phrase(input=None, attr=None, utc=False, language=None) %}
{%- if input is none %}
{%- set dt = now() %}
{%- elif input is datetime %}
{%- set dt = input %}
{%- else %}
{%- set dt = _to_datetime(input, attr, utc) | as_datetime %}
{%- endif %}
{%- set this_hour = dt.hour %}
{%- set this_minute = dt.minute %}
{%- if this_minute > 30 %}
{%- set hour_phrase = hour(this_hour + 1, language=language) %}
{%- set minute_calc = 60 - this_minute %}
{%- set minute_phrase = _phrase('minute', 60 * minute_calc, language, True, True) if this_minute % 5 else minute_calc | string %}
{%- else %}
{%- set hour_phrase = hour(this_hour, language=language) %}
{%- set minute_phrase = _phrase('minute', 60 * this_minute, language, True, True) if this_minute % 5 else this_minute | string %}
{%- endif %}
{%- if this_minute in [0, 1, 15, 30, 45, 59] %}
{%- if hour_phrase in ['noon', 'midnight'] and this_minute == 0 %}
{%- set fmat = '{hour}' %}
{%- else %}
{%- set fmat = translate('time_of_hour', this_minute, language=language) %}
{%- endif %}
{%- elif this_minute > 30 %}
{%- set fmat = translate('time_of_hour', 'to_hour', language=language) %}
{%- else %}
{%- set fmat = translate('time_of_hour', 'past_hour', language=language) %}
{%- endif %}
{{- fmat.format(hour=hour_phrase, minute=minute_phrase) -}}
{%- endmacro %}
5 changes: 2 additions & 3 deletions include/ignored_entities.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

# roku tv - unknown when inactive
- select.office_tv_application
- select.office_tv_channel
- sensor.office_tv_active_app
- sensor.office_tv_active_app_id

Expand Down Expand Up @@ -53,11 +52,11 @@
#BUG Balboa Spa - often unavailable https://github.com/jazzyisj/home-assistant-config/issues/29
- binary_sensor.spa_filter1
- binary_sensor.spa_filter2
- climate.spa
- climate.spa_climate
- fan.spa_pump1
- fan.spa_pump2
- fan.spa_pump3
- switch.spa_light
- switch.spa_light1
- switch.spa_temp_range
- sensor.spa_temperature
- sensor.spa_target_temperature
Expand Down
10 changes: 5 additions & 5 deletions templates/spa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,24 @@
- name: "Spa Heating"
unique_id: spa_heating
device_class: heat
state: "{{ is_state_attr('climate.spa', 'hvac_action', 'heating') }}"
state: "{{ is_state_attr('climate.spa_climate', 'hvac_action', 'heating') }}"

- sensor:
- name: "Spa Temperature"
unique_id: spa_temperature
icon: mdi:thermometer
device_class: temperature
unit_of_measurement: "°C"
state: "{{ state_attr('climate.spa', 'current_temperature') | float }}"
availability: "{{ is_number(state_attr('climate.spa', 'current_temperature')) }}"
state: "{{ state_attr('climate.spa_climate', 'current_temperature') | float }}"
availability: "{{ is_number(state_attr('climate.spa_climate', 'current_temperature')) }}"

- name: "Spa Target Temperature"
unique_id: spa_target_temperature
icon: mdi:thermometer
device_class: temperature
unit_of_measurement: "°C"
state: "{{ state_attr('climate.spa', 'temperature') | float }}"
availability: "{{ is_number(state_attr('climate.spa', 'temperature')) }}"
state: "{{ state_attr('climate.spa_climate', 'temperature') | float }}"
availability: "{{ is_number(state_attr('climate.spa_climate', 'temperature')) }}"

- name: "Hot Tub Power"
unique_id: hot_tub_power
Expand Down
2 changes: 1 addition & 1 deletion ui/button/climate/spa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
###############################################################################
type: custom:button-card
template: menu_button
entity: climate.spa
entity: climate.spa_climate
icon: mdi:hot-tub
show_label: true
label: >
Expand Down
Loading

0 comments on commit 870c896

Please sign in to comment.