Cleaned up a LOT of templates

This commit is contained in:
2023-04-03 23:47:25 -04:00
parent cb52daa5d8
commit 7c3a32e17b
11 changed files with 46 additions and 276 deletions

View File

@ -274,11 +274,7 @@ script:
- condition: template
value_template: >-
{% set ct = ((now().hour * 60 + now().minute) * 60 ) %}
{% if is_state('input_boolean.hot_day','off') and ct < state_attr('input_datetime.emma_bedtime','timestamp') and ct >= state_attr('input_datetime.emma_wakeup','timestamp') %}
true
{% else %}
false
{% endif %}
{{ is_state('input_boolean.hot_day','off') and ct < state_attr('input_datetime.emma_bedtime','timestamp') and ct >= state_attr('input_datetime.emma_wakeup','timestamp') }}
then:
- service: fan.turn_off
target:

View File

@ -273,48 +273,28 @@ sensor:
value_template: >
{% set current = state_attr('light.basement_studio_lights','brightness') %}
{{ ((current / 255) * 100) | float | round(2) }}
availability_template: >
{% if is_state('light.basement_studio_lights','on') %}
true
{% else %}
false
{% endif %}
availability_template: "{{ is_state('light.basement_studio_lights','on') }}"
unit_of_measurement: '%'
icon_template: mdi:brightness-percent
basement_studio_lights_brightness_intended:
friendly_name: "Basement Studio Lights - Brightness Intended"
unique_id: 3542077f-24c6-460c-a73f-fe7bc8413b81
value_template: "{{ state_attr('switch.adaptive_lighting_basement_studio','brightness_pct') | float | round(2) }}"
availability_template: >
{% if is_state('switch.adaptive_lighting_basement_studio','on') %}
true
{% else %}
false
{% endif %}
availability_template: "{{ is_state('switch.adaptive_lighting_basement_studio','on') }}"
unit_of_measurement: '%'
icon_template: mdi:brightness-percent
basement_studio_lights_colortemp_actual:
friendly_name: "Basement Studio Lights - Colortemp Actual"
unique_id: 93cb2a2f-c8a7-44bf-813f-26ce349a072f
value_template: "{{ state_attr('light.basement_studio_lights','color_temp_kelvin') | int }}"
availability_template: >
{% if is_state('light.basement_studio_lights','on') %}
true
{% else %}
false
{% endif %}
availability_template: "{{ is_state('light.basement_studio_lights','on') }}"
unit_of_measurement: 'K'
icon_template: mdi:thermometer-lines
basement_studio_lights_colortemp_intended:
friendly_name: "Basement Studio Lights - Colortemp Intended"
unique_id: 85d4b063-bae8-43c2-9fea-35820b13f26f
value_template: "{{ state_attr('switch.adaptive_lighting_basement_studio','color_temp_kelvin') | int }}"
availability_template: >
{% if is_state('switch.adaptive_lighting_basement_studio','on') %}
true
{% else %}
false
{% endif %}
availability_template: "{{ is_state('switch.adaptive_lighting_basement_studio','on') }}"
unit_of_measurement: 'K'
icon_template: mdi:thermometer-lines
basement_studio_lights_brightness_diff:
@ -324,12 +304,7 @@ sensor:
{% set current = states('sensor.basement_studio_lights_brightness_actual') | float %}
{% set intended = states('sensor.basement_studio_lights_brightness_intended') | float %}
{{ (current - intended) | float | round(2) }}
availability_template: >
{% if is_state('light.basement_studio_lights','on') and is_state('switch.adaptive_lighting_basement_studio','on') %}
true
{% else %}
false
{% endif %}
availability_template: "{{ is_state('light.basement_studio_lights','on') and is_state('switch.adaptive_lighting_basement_studio','on') }}"
unit_of_measurement: '%'
icon_template: mdi:brightness-percent
basement_studio_lights_colortemp_diff:
@ -339,12 +314,7 @@ sensor:
{% set current = states('sensor.basement_studio_lights_colortemp_actual') | float %}
{% set intended = states('sensor.basement_studio_lights_colortemp_intended') | float %}
{{ (current - intended) | float | round(2) }}
availability_template: >
{% if is_state('light.basement_studio_lights','on') and is_state('switch.adaptive_lighting_basement_studio','on') %}
true
{% else %}
false
{% endif %}
availability_template: "{{ is_state('light.basement_studio_lights','on') and is_state('switch.adaptive_lighting_basement_studio','on') }}"
unit_of_measurement: 'K'
icon_template: mdi:thermometer-lines
living_room_lights_brightness_actual:
@ -353,48 +323,28 @@ sensor:
value_template: >
{% set current = state_attr('light.living_room_lights','brightness') %}
{{ ((current / 255) * 100) | float | round(2) }}
availability_template: >
{% if is_state('light.living_room_lights','on') %}
true
{% else %}
false
{% endif %}
availability_template: "{{ is_state('light.living_room_lights','on') }}"
unit_of_measurement: '%'
icon_template: mdi:brightness-percent
living_room_lights_brightness_intended:
friendly_name: "Living Room Lights - Brightness Intended"
unique_id: a758742f-6724-4920-a9d1-325fe4f02664
value_template: "{{ state_attr('switch.adaptive_lighting_living_room','brightness_pct') | float | round(2) }}"
availability_template: >
{% if is_state('switch.adaptive_lighting_living_room','on') %}
true
{% else %}
false
{% endif %}
availability_template: "{{ is_state('switch.adaptive_lighting_living_room','on') }}"
unit_of_measurement: '%'
icon_template: mdi:brightness-percent
living_room_lights_colortemp_actual:
friendly_name: "Living Room Lights - Colortemp Actual"
unique_id: dbe08826-e113-4474-bbca-60d3c32a4b65
value_template: "{{ state_attr('light.living_room_lights','color_temp_kelvin') | int }}"
availability_template: >
{% if is_state('light.living_room_lights','on') %}
true
{% else %}
false
{% endif %}
availability_template: "{{ is_state('light.living_room_lights','on') }}"
unit_of_measurement: 'K'
icon_template: mdi:thermometer-lines
living_room_lights_colortemp_intended:
friendly_name: "Living Room Lights - Colortemp Intended"
unique_id: 8b974c03-ab5b-4b89-97bf-afee78fa1a40
value_template: "{{ state_attr('switch.adaptive_lighting_living_room','color_temp_kelvin') | int }}"
availability_template: >
{% if is_state('switch.adaptive_lighting_living_room','on') %}
true
{% else %}
false
{% endif %}
availability_template: "{{ is_state('switch.adaptive_lighting_living_room','on') }}"
unit_of_measurement: 'K'
icon_template: mdi:thermometer-lines
living_room_lights_brightness_diff:
@ -404,12 +354,7 @@ sensor:
{% set current = states('sensor.living_room_lights_brightness_actual') | float %}
{% set intended = states('sensor.living_room_lights_brightness_intended') | float %}
{{ (current - intended) | float | round(2) }}
availability_template: >
{% if is_state('light.living_room_lights','on') and is_state('switch.adaptive_lighting_living_room','on') %}
true
{% else %}
false
{% endif %}
availability_template: "{{ is_state('light.living_room_lights','on') and is_state('switch.adaptive_lighting_living_room','on') }}"
unit_of_measurement: '%'
icon_template: mdi:brightness-percent
living_room_lights_colortemp_diff:
@ -419,12 +364,7 @@ sensor:
{% set current = states('sensor.living_room_lights_colortemp_actual') | float %}
{% set intended = states('sensor.living_room_lights_colortemp_intended') | float %}
{{ (current - intended) | float | round(2) }}
availability_template: >
{% if is_state('light.living_room_lights','on') and is_state('switch.adaptive_lighting_living_room','on') %}
true
{% else %}
false
{% endif %}
availability_template: "{{ is_state('light.living_room_lights','on') and is_state('switch.adaptive_lighting_living_room','on') }}"
unit_of_measurement: 'K'
icon_template: mdi:thermometer-lines
@ -908,11 +848,7 @@ automation:
{% if is_state('media_player.basement_tv','playing') %}
false
{% elif is_state('media_player.basement_tv','paused') or is_state('media_player.basement_tv','idle') %}
{% if state_attr('media_player.basement_tv','app_name') in ['TV','Android TV Launcher'] %}
true
{% else %}
false
{% endif %}
{{ state_attr('media_player.basement_tv','app_name') in ['TV','Android TV Launcher'] }}
{% else %}
false
{% endif %}
@ -1336,14 +1272,7 @@ script:
option: Bright
- if:
- condition: template
value_template: >
{% if is_state('input_boolean.kallen_sleeping','off') %}
true
{% elif is_state('input_boolean.kallen_sleeping','on') and is_state('light.kallen_bedroom_lights','on') %}
true
{% else %}
false
{% endif %}
value_template: "{{ is_state('input_boolean.kallen_sleeping','off') or (is_state('input_boolean.kallen_sleeping','on') and is_state('light.kallen_bedroom_lights','on')) }}"
then:
- service: input_select.select_option
target:
@ -1352,14 +1281,7 @@ script:
option: Bright
- if:
- condition: template
value_template: >
{% if is_state('input_boolean.emma_sleeping','off') %}
true
{% elif is_state('input_boolean.emma_sleeping','on') and is_state('light.emma_bedroom_light','on') %}
true
{% else %}
false
{% endif %}
value_template: "{{ is_state('input_boolean.emma_sleeping','off') or (is_state('input_boolean.emma_sleeping','on') and is_state('light.emma_bedroom_light','on')) }}"
then:
- service: input_select.select_option
target:
@ -1607,11 +1529,7 @@ script:
- condition: template
value_template: >
{% set weather = states('weather.iron_nerd_weather_station') %}
{% if weather in ['cloudy','partlycloudy','rainy','snowy','hail','lightning','lightning-rainy','pouring','snowy-rainy'] %}
true
{% else %}
false
{% endif %}
{{ weather in ['cloudy','partlycloudy','rainy','snowy','hail','lightning','lightning-rainy','pouring','snowy-rainy'] }}
then:
- if:
- condition: template

View File

@ -99,11 +99,7 @@ script:
- condition: template
value_template: >
{% set weather = states('weather.iron_nerd_weather_station') %}
{% if weather in ['cloudy','partlycloudy','rainy','snowy','hail','lightning','lightning-rainy','pouring','snowy-rainy'] %}
true
{% else %}
false
{% endif %}
{{ weather in ['cloudy','partlycloudy','rainy','snowy','hail','lightning','lightning-rainy','pouring','snowy-rainy'] }}
then:
- service: input_select.select_option
target:

View File

@ -1254,12 +1254,7 @@ script:
entity_id: input_boolean.audible_notifications
state: 'on'
- condition: template
value_template: >
{% if type in ['critical','Critical','alert','Alert'] %}
true
{% else %}
false
{% endif %}
value_template: "{{ type in ['critical','Critical','alert','Alert'] }}"
- condition: state
entity_id: group.adults
state: 'home'
@ -1459,12 +1454,7 @@ script:
sequence:
- if:
- condition: template
value_template: >
{% if type in ['critical','Critical'] %}
true
{% else %}
false
{% endif %}
value_template: "{{ type in ['critical','Critical'] }}"
then:
- service: media_player.volume_set
target:

View File

@ -235,29 +235,11 @@ template:
device_class: presence
- name: "Nerds Home"
unique_id: 2672a6a2-4be4-495c-b479-ffc7c6df67d2
state: >-
{% if is_state('group.family','home') %}
{% if is_state('binary_sensor.tony_home','on') or is_state('binary_sensor.kallen_home','on') %}
true
{% else %}
false
{% endif %}
{% else %}
false
{% endif %}
state: "{{ is_state('group.family','home') and (is_state('binary_sensor.tony_home','on') or is_state('binary_sensor.kallen_home','on')) }}"
device_class: presence
- name: "Parents Home"
unique_id: 8de02d19-60a6-436d-9187-1cfc70d6c297
state: >-
{% if is_state('group.adults','home') %}
{% if is_state('binary_sensor.tony_home','on') or is_state('binary_sensor.tina_home','on') %}
true
{% else %}
false
{% endif %}
{% else %}
false
{% endif %}
state: "{{ is_state('group.adults','home') and (is_state('binary_sensor.tony_home','on') or is_state('binary_sensor.tina_home','on')) }}"
device_class: presence
- name: "Basement Unoccupied"
unique_id: 20039c29-8b9d-436d-ba6c-8f2c2bda1db0
@ -649,11 +631,7 @@ script:
- condition: template
value_template: >
{% set weather = states('weather.iron_nerd_weather_station') %}
{% if weather in ['cloudy','partlycloudy','rainy','snowy','hail','lightning','lightning-rainy','pouring','snowy-rainy'] %}
true
{% else %}
false
{% endif %}
{{ weather in ['cloudy','partlycloudy','rainy','snowy','hail','lightning','lightning-rainy','pouring','snowy-rainy'] }}
then:
- service: light.turn_on
target:

View File

@ -291,7 +291,7 @@ script:
entity_id: input_datetime.kallen_bedtime
data:
time: >
{% if is_state('sensor.kallen_school_tomorrow', 'on') %}
{% if is_state('binary_sensor.kallen_school_tomorrow', 'on') %}
21:00
{% else %}
22:00
@ -422,12 +422,7 @@ script:
{% endif %}
- if:
- condition: template
value_template: >
{% if states('sensor.todays_high_temp') | int >= states('input_number.hot_day_threshold') | int %}
true
{% else %}
false
{% endif %}
value_template: "{{ states('sensor.todays_high_temp') | int >= states('input_number.hot_day_threshold') | int }}"
then:
- service: input_boolean.turn_on
target:
@ -438,12 +433,7 @@ script:
entity_id: input_boolean.hot_day
- if:
- condition: template
value_template: >
{% if states('sensor.todays_high_temp') | int <= states('input_number.cold_day_threshold') | int %}
true
{% else %}
false
{% endif %}
value_template: "{{ states('sensor.todays_high_temp') | int <= states('input_number.cold_day_threshold') | int }}"
then:
- service: input_boolean.turn_on
target:
@ -477,7 +467,7 @@ script:
entity_id: input_datetime.audible_notification_off
data:
time: >
{% if is_state('sensor.kallen_school_tomorrow','on') %}
{% if is_state('binary_sensor.kallen_school_tomorrow','on') %}
22:15
{% else %}
23:15
@ -524,9 +514,9 @@ script:
data:
time: >
{% set low = states('sensor.tonights_low_temp') | int %}
{% if is_state('input_boolean.hot_day','on') and is_state('sensor.kallen_school_tomorrow','on') %}
{% if is_state('input_boolean.hot_day','on') and is_state('binary_sensor.kallen_school_tomorrow','on') %}
20:00
{% elif is_state('input_boolean.hot_day','on') and is_state('sensor.kallen_school_tomorrow','off') %}
{% elif is_state('input_boolean.hot_day','on') and is_state('binary_sensor.kallen_school_tomorrow','off') %}
21:00
{% elif low >= 56 and low <= 60 %}
22:30

View File

@ -215,11 +215,7 @@ automation:
{% set rearm = state_attr('input_datetime.morning_alarm_rearm','timestamp') %}
{% set wake = state_attr('input_datetime.master_bedroom_wakeup','timestamp') %}
{% set diff = wake - rearm %}
{% if diff <= 1800 %}
false
{% else %}
true
{% endif %}
{{ diff > 1800 }}
action:
- if:
- condition: state
@ -425,12 +421,7 @@ script:
entity_id: input_boolean.security_armed_home
- if:
- condition: template
value_template: >
{% if silent == 1 %}
false
{% else %}
true
{% endif %}
value_template: "{{ silent != 1 }}"
then:
- service: script.status_annc
data:
@ -491,12 +482,7 @@ script:
entity_id: input_boolean.security_armed_home
state: 'on'
- condition: template
value_template: >
{% if silent == 1 %}
false
{% else %}
true
{% endif %}
value_template: "{{ silent != 1 }}"
then:
- service: script.status_annc
data:

View File

@ -12,111 +12,47 @@ template:
unique_id: f361b30c-1771-41b3-85ff-ef1e0b6be59c
state: >
{% if state_attr('sensor.michigan_wolverines','kickoff_in') %}
{% if 'months' in state_attr('sensor.michigan_wolverines','kickoff_in') %}
true
{% elif 'weeks' in state_attr('sensor.michigan_wolverines','kickoff_in') %}
true
{% else %}
false
{% endif %}
{% else %}
false
{{ ('months' or 'weeks') in state_attr('sensor.michigan_wolverines','kickoff_in') }}
{% endif %}
- name: Ohio State Buckeyes Inhibit
unique_id: d5359cb4-427a-46f8-99d6-4313530fde81
state: >
{% if state_attr('sensor.ohio_state_buckeyes','kickoff_in') %}
{% if 'months' in state_attr('sensor.ohio_state_buckeyes','kickoff_in') %}
true
{% elif 'weeks' in state_attr('sensor.ohio_state_buckeyes','kickoff_in') %}
true
{% else %}
false
{% endif %}
{% else %}
false
{{ ('months' or 'weeks') in state_attr('sensor.ohio_state_buckeyes','kickoff_in') }}
{% endif %}
- name: Toledo Rockets Inhibit
unique_id: 1f84d3f3-a06e-4745-a593-c21fe3504072
state: >
{% if state_attr('sensor.toledo_rockets','kickoff_in') %}
{% if 'months' in state_attr('sensor.toledo_rockets','kickoff_in') %}
true
{% elif 'weeks' in state_attr('sensor.toledo_rockets','kickoff_in') %}
true
{% else %}
false
{% endif %}
{% else %}
false
{{ ('months' or 'weeks') in state_attr('sensor.toledo_rockets','kickoff_in') }}
{% endif %}
- name: Minnesota Vikings Inhibit
unique_id: ea60c987-a95b-4024-a9c7-1bc6975e07e2
state: >
{% if state_attr('sensor.minnesota_vikings','kickoff_in') %}
{% if 'months' in state_attr('sensor.minnesota_vikings','kickoff_in') %}
true
{% elif 'weeks' in state_attr('sensor.minnesota_vikings','kickoff_in') %}
true
{% else %}
false
{% endif %}
{% else %}
false
{{ ('months' or 'weeks') in state_attr('sensor.minnesota_vikings','kickoff_in') }}
{% endif %}
- name: San Francisco 49ers Inhibit
unique_id: ce2441fa-09d6-4afc-b350-fee3745cdb50
state: >
{% if state_attr('sensor.san_francisco_49ers','kickoff_in') %}
{% if 'months' in state_attr('sensor.san_francisco_49ers','kickoff_in') %}
true
{% elif 'weeks' in state_attr('sensor.san_francisco_49ers','kickoff_in') %}
true
{% else %}
false
{% endif %}
{% else %}
false
{{ ('months' or 'weeks') in state_attr('sensor.san_francisco_49ers','kickoff_in') }}
{% endif %}
- name: Cleveland Guardians Inhibit
unique_id: b0980d47-d762-4f23-97b1-9e88da729d8f
state: >
{% if state_attr('sensor.cleveland_guardians','kickoff_in') %}
{% if 'months' in state_attr('sensor.cleveland_guardians','kickoff_in') %}
true
{% elif 'weeks' in state_attr('sensor.cleveland_guardians','kickoff_in') %}
true
{% else %}
false
{% endif %}
{% else %}
false
{{ ('months' or 'weeks') in state_attr('sensor.cleveland_guardians','kickoff_in') }}
{% endif %}
- name: Minnesota Twins Inhibit
unique_id: 2987ae95-f55d-4994-b9dd-018278d2f5ad
state: >
{% if state_attr('sensor.minnesota_twins','kickoff_in') %}
{% if 'months' in state_attr('sensor.minnesota_twins','kickoff_in') %}
true
{% elif 'weeks' in state_attr('sensor.minnesota_twins','kickoff_in') %}
true
{% else %}
false
{% endif %}
{% else %}
false
{{ ('months' or 'weeks') in state_attr('sensor.minnesota_twins','kickoff_in') }}
{% endif %}
- name: Los Angeles Dodgers Inhibit
unique_id: 2c6aae6e-eff6-46e5-bee9-311f9bbc0c0e
state: >
{% if state_attr('sensor.los_angeles_dodgers','kickoff_in') %}
{% if 'months' in state_attr('sensor.los_angeles_dodgers','kickoff_in') %}
true
{% elif 'weeks' in state_attr('sensor.los_angeles_dodgers','kickoff_in') %}
true
{% else %}
false
{% endif %}
{% else %}
false
{{ ('months' or 'weeks') in state_attr('sensor.los_angeles_dodgers','kickoff_in') }}
{% endif %}

View File

@ -56,34 +56,19 @@ sensor:
friendly_name: "Min Ping"
unique_id: ddcb9f6f-7c94-41fe-9453-2a2205b078e0
value_template: "{{ state_attr('binary_sensor.internet','round_trip_time_min') }}"
availability_template: >-
{% if is_state('binary_sensor.internet','on') %}
true
{% else %}
false
{% endif %}
availability_template: "{{ is_state('binary_sensor.internet','on') }}"
unit_of_measurement: "ms"
avg_ping:
friendly_name: "Avg Ping"
unique_id: 79a13c64-7508-48de-8b44-2a23c59917c8
value_template: "{{ state_attr('binary_sensor.internet','round_trip_time_avg') }}"
availability_template: >-
{% if is_state('binary_sensor.internet','on') %}
true
{% else %}
false
{% endif %}
availability_template: "{{ is_state('binary_sensor.internet','on') }}"
unit_of_measurement: "ms"
max_ping:
friendly_name: "Max Ping"
unique_id: c9c71ab6-c7fa-4425-a4ed-768d60e93781
value_template: "{{ state_attr('binary_sensor.internet','round_trip_time_max') }}"
availability_template: >-
{% if is_state('binary_sensor.internet','on') %}
true
{% else %}
false
{% endif %}
availability_template: "{{ is_state('binary_sensor.internet','on') }}"
unit_of_measurement: "ms"
mqtt:

View File

@ -1699,12 +1699,7 @@ script:
## Create a new persistant notification in the UI for a new alert
- if:
- condition: template
value_template: >
{% if states.sensor.weatheralerts.state != '0' %}
true
{% else %}
false
{% endif %}
value_template: "{{ states.sensor.weatheralerts.state != '0' }}"
then:
- service: persistent_notification.create
data:

View File

@ -33,8 +33,8 @@ give_me_darkness:
then:
- if:
- condition: template
value_template: "{% if is_state('person.tony_stork','home') and is_state('person.christina_stork','home')
%}\n true\n{% else %}\n false\n{% endif %}"
value_template: '{{ is_state(''person.tony_stork'',''home'') and is_state(''person.christina_stork'',''home'')
}}'
alias: Both adults are home
then:
- service: script.activate_alexa_actionable_notification