diff --git a/configuration.yaml b/configuration.yaml index c0485cf..ea10d56 100755 --- a/configuration.yaml +++ b/configuration.yaml @@ -112,7 +112,7 @@ cover: # Modular Includes ################################################## -template: !include_dir_merge_named include/templates/ +template: !include_dir_merge_list include/templates/ group: !include_dir_merge_named include/groups/ sensor: !include_dir_merge_list include/sensors/ automation: !include_dir_merge_list include/automations/ diff --git a/include/templates/claus_distance_home.yaml b/include/templates/claus_distance_home.yaml index 195090e..f530714 100644 --- a/include/templates/claus_distance_home.yaml +++ b/include/templates/claus_distance_home.yaml @@ -1,5 +1,5 @@ -sensor: - - name: "claus_distance_home" - unit_of_measurement: m - state: > - {{ distance('device_tracker.clausiphone', 'zone.home') | round(0) }} +- sensor: + - name: "claus_distance_home" + unit_of_measurement: m + state: > + {{ distance('device_tracker.clausiphone', 'zone.home') | round(0) }} diff --git a/include/templates/dishwasher.yaml b/include/templates/dishwasher.yaml index 466edf2..5188e92 100644 --- a/include/templates/dishwasher.yaml +++ b/include/templates/dishwasher.yaml @@ -1,18 +1,18 @@ -sensor: - - name: "Dishwasher Next Start Compact" - unique_id: dishwasher_next_start_compact - state: > - {% set raw = states('input_datetime.dishwasher_next_start') %} - {% if raw in ['unknown', 'unavailable', '', none] %} - Ikke planlagt - {% else %} - {% set dt = as_datetime(raw) %} - {% if dt.date() == now().date() %} - I dag {{ dt.strftime('%H:%M') }} - {% elif dt.date() == (now() + timedelta(days=1)).date() %} - I morgen {{ dt.strftime('%H:%M') }} +- sensor: + - name: "Dishwasher Next Start Compact" + unique_id: dishwasher_next_start_compact + state: > + {% set raw = states('input_datetime.dishwasher_next_start') %} + {% if raw in ['unknown', 'unavailable', '', none] %} + Ikke planlagt {% else %} - {% set weekdays = ['man', 'tir', 'ons', 'tor', 'fre', 'lør', 'søn'] %} - {{ weekdays[dt.weekday()] }} {{ dt.strftime('%H:%M') }} - {% endif %} - {% endif %} \ No newline at end of file + {% set dt = as_datetime(raw) %} + {% if dt.date() == now().date() %} + I dag {{ dt.strftime('%H:%M') }} + {% elif dt.date() == (now() + timedelta(days=1)).date() %} + I morgen {{ dt.strftime('%H:%M') }} + {% else %} + {% set weekdays = ['man', 'tir', 'ons', 'tor', 'fre', 'lør', 'søn'] %} + {{ weekdays[dt.weekday()] }} {{ dt.strftime('%H:%M') }} + {% endif %} + {% endif %} \ No newline at end of file diff --git a/include/templates/family_presence.yaml b/include/templates/family_presence.yaml index 967d685..0a09ec6 100644 --- a/include/templates/family_presence.yaml +++ b/include/templates/family_presence.yaml @@ -1,11 +1,11 @@ -binary_sensor: - - name: "Family Presence" - unique_id: family_presence - device_class: presence - state: > - {{ [ - states('person.anne_schusler_dethlefsen'), - states('person.claus_dethlefsen'), - states('device_tracker.unifi_andreas'), - states('device_tracker.unifi_daniel') - ] | select('eq', 'home') | list | count > 0 }} +- binary_sensor: + - name: "Family Presence" + unique_id: family_presence + device_class: presence + state: > + {{ [ + states('person.anne_schusler_dethlefsen'), + states('person.claus_dethlefsen'), + states('device_tracker.unifi_andreas'), + states('device_tracker.unifi_daniel') + ] | select('eq', 'home') | list | count > 0 }} diff --git a/include/templates/legacy_sensors.yaml b/include/templates/legacy_sensors.yaml index 6649252..0e5eee3 100644 --- a/include/templates/legacy_sensors.yaml +++ b/include/templates/legacy_sensors.yaml @@ -1,116 +1,116 @@ -sensor: - - name: "Batteri (%)" - unique_id: snowywhite_battery_numeric - unit_of_measurement: "%" - state: > - {% set val = states('sensor.snowywhite_battery') %} - {% if val not in ['unknown','unavailable',''] %} - {{ val.replace('%','') | float }} - {% else %} - 0 - {% endif %} +- sensor: + - name: "Batteri (%)" + unique_id: snowywhite_battery_numeric + unit_of_measurement: "%" + state: > + {% set val = states('sensor.snowywhite_battery') %} + {% if val not in ['unknown','unavailable',''] %} + {{ val.replace('%','') | float }} + {% else %} + 0 + {% endif %} - - name: "Rækkevidde (km)" - unique_id: snowywhite_range_numeric - unit_of_measurement: "km" - state: > - {% set val = states('sensor.snowywhite_range') %} - {% if val not in ['unknown','unavailable',''] %} - {{ val.replace(' km','') | float }} - {% else %} - 0 - {% endif %} + - name: "Rækkevidde (km)" + unique_id: snowywhite_range_numeric + unit_of_measurement: "km" + state: > + {% set val = states('sensor.snowywhite_range') %} + {% if val not in ['unknown','unavailable',''] %} + {{ val.replace(' km','') | float }} + {% else %} + 0 + {% endif %} - - name: "Charging (numeric)" - unique_id: snowywhite_charging_numeric - unit_of_measurement: "1" - state: > - {% if is_state('binary_sensor.snowywhite_charging','on') %} - 1 - {% else %} - 0 - {% endif %} + - name: "Charging (numeric)" + unique_id: snowywhite_charging_numeric + unit_of_measurement: "1" + state: > + {% if is_state('binary_sensor.snowywhite_charging','on') %} + 1 + {% else %} + 0 + {% endif %} - - name: "Energy Added (kWh)" - unique_id: snowywhite_energy_added_numeric - unit_of_measurement: "kWh" - state: > - {% set val = states('sensor.snowywhite_energy_added') %} - {% if val not in ['unknown','unavailable',''] %} - {{ val | float }} - {% else %} - 0 - {% endif %} + - name: "Energy Added (kWh)" + unique_id: snowywhite_energy_added_numeric + unit_of_measurement: "kWh" + state: > + {% set val = states('sensor.snowywhite_energy_added') %} + {% if val not in ['unknown','unavailable',''] %} + {{ val | float }} + {% else %} + 0 + {% endif %} - - name: "Charging Rate (km/h)" - unique_id: snowywhite_charging_rate_numeric - unit_of_measurement: "km/h" - state: > - {% set val = states('sensor.snowywhite_charging_rate') %} - {% if val not in ['unknown','unavailable',''] %} - {{ val | float }} - {% else %} - 0 - {% endif %} + - name: "Charging Rate (km/h)" + unique_id: snowywhite_charging_rate_numeric + unit_of_measurement: "km/h" + state: > + {% set val = states('sensor.snowywhite_charging_rate') %} + {% if val not in ['unknown','unavailable',''] %} + {{ val | float }} + {% else %} + 0 + {% endif %} - - name: "Dato" - unique_id: n22_dato - state: > - {{ now().strftime('%A %d %B') | replace('Monday','Mandag') - | replace('Tuesday','Tirsdag') - | replace('Wednesday','Onsdag') - | replace('Thursday','Torsdag') - | replace('Friday','Fredag') - | replace('Saturday','Lørdag') - | replace('Sunday','Søndag') }} + - name: "Dato" + unique_id: n22_dato + state: > + {{ now().strftime('%A %d %B') | replace('Monday','Mandag') + | replace('Tuesday','Tirsdag') + | replace('Wednesday','Onsdag') + | replace('Thursday','Torsdag') + | replace('Friday','Fredag') + | replace('Saturday','Lørdag') + | replace('Sunday','Søndag') }} - - name: "Solopgang" - unique_id: n22_solopgang - state: > - {% set t = state_attr('sun.sun','next_rising') %} - {{ as_timestamp(t) | timestamp_custom('%H:%M') if t else '-' }} + - name: "Solopgang" + unique_id: n22_solopgang + state: > + {% set t = state_attr('sun.sun','next_rising') %} + {{ as_timestamp(t) | timestamp_custom('%H:%M') if t else '-' }} - - name: "Solnedgang" - unique_id: n22_solnedgang - state: > - {% set t = state_attr('sun.sun','next_setting') %} - {{ as_timestamp(t) | timestamp_custom('%H:%M') if t else '-' }} + - name: "Solnedgang" + unique_id: n22_solnedgang + state: > + {% set t = state_attr('sun.sun','next_setting') %} + {{ as_timestamp(t) | timestamp_custom('%H:%M') if t else '-' }} - - name: "Opvask tid tilbage" - unique_id: dishwasher_remaining_minutes - unit_of_measurement: "min" - state: > - {% set val = states('sensor.dishwasher_remaining_time_2') %} - {% if val in ['unknown','unavailable',''] %} - 0 - {% elif ':' in val %} - {% set parts = val.split(':') %} - {{ (parts[0] | int * 60) + (parts[1] | int) }} - {% elif 'min' in val %} - {{ val.replace('min','') | int }} - {% else %} - {{ val | int(0) }} - {% endif %} + - name: "Opvask tid tilbage" + unique_id: dishwasher_remaining_minutes + unit_of_measurement: "min" + state: > + {% set val = states('sensor.dishwasher_remaining_time_2') %} + {% if val in ['unknown','unavailable',''] %} + 0 + {% elif ':' in val %} + {% set parts = val.split(':') %} + {{ (parts[0] | int * 60) + (parts[1] | int) }} + {% elif 'min' in val %} + {{ val.replace('min','') | int }} + {% else %} + {{ val | int(0) }} + {% endif %} - - name: "Dage til jul" - unique_id: dage_til_jul - state: >- - {{ states('sensor.nedtaelling_juleaften') }} + - name: "Dage til jul" + unique_id: dage_til_jul + state: >- + {{ states('sensor.nedtaelling_juleaften') }} - - name: "Dage til nytår" - unique_id: dage_til_nytaar - state: >- - {{ states('sensor.nedtaelling_nytaar') }} + - name: "Dage til nytår" + unique_id: dage_til_nytaar + state: >- + {{ states('sensor.nedtaelling_nytaar') }} - - name: "Dage til ferie" - unique_id: dage_til_ferie - state: >- - {{ states('sensor.nedtaelling_ferie') }} + - name: "Dage til ferie" + unique_id: dage_til_ferie + state: >- + {{ states('sensor.nedtaelling_ferie') }} - - name: "Dagens dato" - unique_id: dato - state: >- - {% set timestamp = strptime(states('sensor.date'), '%Y-%m-%d').timestamp() %} - {% set weekdays_DK = ['Man', 'Tirs', 'Ons', 'Tors', 'Fre', 'Lør', 'Søn'] %} - {% set months_DK = ['Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December'] %} - {{ weekdays_DK[timestamp | timestamp_custom('%w') | int - 1] }}dag den {{ timestamp | timestamp_custom('%-d.') }} {{ months_DK[timestamp | timestamp_custom('%-m') | int - 1] }} {{ timestamp | timestamp_custom('%Y') }} \ No newline at end of file + - name: "Dagens dato" + unique_id: dato + state: >- + {% set timestamp = strptime(states('sensor.date'), '%Y-%m-%d').timestamp() %} + {% set weekdays_DK = ['Man', 'Tirs', 'Ons', 'Tors', 'Fre', 'Lør', 'Søn'] %} + {% set months_DK = ['Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December'] %} + {{ weekdays_DK[timestamp | timestamp_custom('%w') | int - 1] }}dag den {{ timestamp | timestamp_custom('%-d.') }} {{ months_DK[timestamp | timestamp_custom('%-m') | int - 1] }} {{ timestamp | timestamp_custom('%Y') }} \ No newline at end of file