-
-
Save EverythingSmartHome/814bc87e83dcff1c06fffa3095b95b3f to your computer and use it in GitHub Desktop.
#Showing the state of a temperature in a template card: | |
{{ states('sensor.your_temperature_sensor') }} | |
#Change the colour of the light depending on status: | |
{% if is_state('light.your_light', 'on') %} | |
orange | |
{% endif %} | |
#Welcome template: | |
{% set time = now().hour %} | |
{% if (time >= 18) %} | |
Good Evening, {{user}}! | |
{% elif (time >= 12) %} | |
Good Afternoon, {{user}}! | |
{% elif (time >= 5) %} | |
Good Morning, {{user}}! | |
{% else %} | |
Hello, {{user}}! | |
{% endif %} | |
I use the following helper values: Powerplugs, Lights on, window shutters, window/doors, room temperature, Sonos active.
This is my configuration yaml:
- sensor:
- name: "Steckdosen an"
unique_id: poweroutlets_turned_on
icon: mdi:power-socket-eu
state: |
{{ states.light
| rejectattr('attributes.entity_id', 'defined')
| selectattr('entity_id', 'in', ['light.aussensteckdose', 'light.steckdose_balkon', 'light.steckdose_dachterrasse'])
| rejectattr('attributes.is_hue_group', 'true')
| selectattr('state', 'eq', 'on')
| reject('search', 'screen')
| reject('search', 'segment')
| list
| count }}
- sensor:
- name: "Lampen an"
unique_id: lights_turned_on
icon: mdi:window-shutter-open
state: |
{{ label_entities("lamp") | select('is_state', 'on') | list | count }}
- sensor:
- name: "Rollläden oben"
unique_id: rollos_oben
icon: mdi:window-shutter-closed
state: |
{{ states.cover | selectattr('state', 'eq', 'open') | reject('search', 'motor') | reject('search', 'markise') | list | count + states.cover | selectattr('state', 'eq', 'opening') | reject('search', 'motor') | reject('search', 'markise') | list | count + states.cover | selectattr('state', 'eq', 'closing') | reject('search', 'motor') | reject('search', 'markise') | list | count }}
- sensor:
- name: "Offene Fenster/Türen"
unique_id: open_window_count
icon: mdi:window-open-variant
state: |
{{ states.binary_sensor | selectattr('attributes.device_class', 'eq', 'door') | selectattr('state', 'eq', 'on') | reject('search', 'ev6') | reject('search', 'gruppe') | list | count +
states.binary_sensor | selectattr('attributes.device_class', 'eq', 'window') | selectattr('state', 'eq', 'on') | reject('search', 'ev6') | reject('search', 'gruppe') | list | count }}
- sensor:
- name: "RTR in Betrieb"
unique_id: active_rtr_count
icon: mdi:thermometer-lines
state: |
{{ states.climate | selectattr('state', 'eq', 'heat_cool') | reject('search', 'ev6') | reject('search', 'gruppe') | list | count }}
- sensor:
- name: "Badheizkörper in Betrieb"
unique_id: active_badheizkorper
icon: mdi:heating-coil
state: |
{{ states.light | selectattr('state', 'eq', 'on') | selectattr('entity_id', 'in', ['light.badheizkorper_og', 'light.badheizkorper_dg']) | list | count }}
- sensor:
- name: "Sonos in Betrieb"
unique_id: active_media_count
icon: mdi:music
state: |
{{ states.media_player | selectattr('state', 'eq', 'playing') | reject('search', 'ev6') | reject('search', 'gruppe') | list | count }}
Old thread, not sure if anyone is interested but if like myself you have setup your full name on HA then it might be worth using (either directly or as a helper):
{{ user.split()[0] }}
Looks cleaner with just the first name and fits better.
I have this code below which is working fine, but I want to make the icon in orange every time that any of these 4 lights below turns on.
light.banheiro_suite_interruptor_iluminacao_interruptor_1
light.banheiro_suite_interruptor_iluminacao_interruptor_2
light.banheiro_suite_interruptor_iluminacao_interruptor_3
light.banheiro_suite_interruptor_iluminacao_interruptor_4
{% if is_state('light.banheiro_suite_interruptor_iluminacao_interruptor_1','on')
%} orange
{% endif %}
Does anybody know how to ADD the "OR" clause on this sintax?
I have this code below which is working fine, but I want to make the icon in orange every time that any of these 4 lights below turns on. light.banheiro_suite_interruptor_iluminacao_interruptor_1 light.banheiro_suite_interruptor_iluminacao_interruptor_2 light.banheiro_suite_interruptor_iluminacao_interruptor_3 light.banheiro_suite_interruptor_iluminacao_interruptor_4
{% if is_state('light.banheiro_suite_interruptor_iluminacao_interruptor_1','on') %} orange {% endif %}
Does anybody know how to ADD the "OR" clause on this sintax?
{% if is_state('light.banheiro_suite_interruptor_iluminacao_interruptor_1','on')
or is_state('light.light_2','on')
or is_state('light.light_3','on')
or is_state('light.light_4','on')
%} orange
{% endif %}
Many thanks @danewhitfield for your assistance! You rock! :-)
Is there a way to use categories as domain? I have smart switches for the lights and several smart plugs (which are also in domain switch), so when I do the count against domain switch - it does add up plugs and switches.
Thanks in advance