-
-
Save EverythingSmartHome/13f14c328669f72eee717752069a0398 to your computer and use it in GitHub Desktop.
| {{ states.binary_sensor | |
| | selectattr('attributes.device_class', 'in', ['door','window']) | |
| | selectattr('state', 'equalto', 'on') | |
| | list | count }} |
| {% set AREAS = ['kitchen','office','bedroom','living room'] %} | |
| {% set DOMAIN = 'light' %} | |
| {% set ns = namespace(ids=[]) %} | |
| {% for a in AREAS %} | |
| {% set ns.ids = ns.ids + area_entities(a) %} | |
| {% endfor %} | |
| {{ expand(ns.ids|unique) | |
| | selectattr('domain','equalto', DOMAIN) | |
| | selectattr('state','equalto','on') | |
| | list | count }} |
| # Security 🔏 | |
| {% if states.sensor.open_doors_and_windows.state | int > 0 %} | |
| You have {{states.sensor.open_doors_and_windows.state}} doors/windows open. | |
| {% else %} | |
| All windows and doors are closed. | |
| {% endif %} |
| ## Lights 💡 | |
| You have {{states.sensor.kitchen_light_count.state}} lights on currently. |
| {% set area_id = 'kitchen' %} | |
| {% set ents = expand(area_entities(area_id)) %} | |
| {% set lights = ents | |
| | selectattr('domain', 'equalto', 'media_player') | |
| | selectattr('state', 'equalto', 'playing') %} | |
| {{ lights | list | count }} |
| {% set area_id = 'kitchen' %} | |
| {% set ents = expand(area_entities(area_id)) %} | |
| {% set switch = ents | |
| | selectattr('domain', 'equalto', 'switch') | |
| | selectattr('state', 'equalto', 'on') %} | |
| {{ switch | list | count }} |
| {% set time = now().hour %} | |
| {% if time >= 5 and time < 12 %} | |
| {% set greeting = 'Good morning' %} | |
| {% elif time >= 12 and time < 17 %} | |
| {% set greeting = 'Good afternoon' %} | |
| {% elif time >= 17 and time < 24 %} | |
| {% set greeting = 'Good evening' %} | |
| {% elif time >= 0 and time < 5 %} | |
| {% set greeting = 'You should be sleeping' %} | |
| {% endif %} | |
| # {{greeting}}, {{user}}! |
| {% set time = now().hour %} | |
| {% if time >= 5 and time < 12 %} | |
| {% set greeting = 'Good morning' %} | |
| {% elif time >= 12 and time < 17 %} | |
| {% set greeting = 'Good afternoon' %} | |
| {% elif time >= 17 and time < 24 %} | |
| {% set greeting = 'Good evening' %} | |
| {% elif time >= 0 and time < 5 %} | |
| {% set greeting = 'You should be sleeping' %} | |
| {% endif %} | |
| {% if state_attr('calendar.lewis_s_calendar', 'start_time') == None %} | |
| {% set cal_message = "you have no upcoming events, enjoy 🥳"%} | |
| {% else %} | |
| {% set start_time = state_attr('calendar.lewis_s_calendar', 'start_time') | as_timestamp | timestamp_custom("%H:%M", false) %} | |
| {% set cal_message = "your next event is at " + start_time %} | |
| {% endif %} | |
| # {{greeting}}, {{user}}! | |
| It's {{now().hour}}:{{now().minute}} and {{cal_message}}. |
The welcome template unfortunately looks at the next start time independent of the date, so you get a message about an event time that might be several days in the future, without any info about the date. I changed mine to only look at today:
{% if state_attr('calendar.lewis_s_calendar', 'start_time') == None
or state_attr('calendar.lewis_s_calendar', 'start_time') | as_datetime | as_local > today_at('00:00:00') %}
{% set cal_message = "you have no upcoming events today, enjoy 🥳"%}
How to add more area with "Switch On Count"? I tried use {% set area_id = ['living_room', 'bedroom'] %}.but no lucky
Thanks
I believe you have to follow the Light On Count example, setting AREAS instead of a single area_id and looping through it
Replacing line 21 of Welcome message with calendar event solves the issue where minute values < 10 are displayed as single integers with no leading 0:
It's {{ now().strftime("%H:%M") }} and {{ cal_message }}.
I wanted to show only lights on a particular floor so this worked nicely for me:
{{ floor_areas('first_floor')
|map('area_entities')|sum(start=[])
|select('match', 'light')|select('is_state', 'on')
|rejectattr('entity_id', 'is_hidden_entity')
|list|count }}
Not sure if this fits here but if you ever wanted to know all devices that report energy in kWh:
{% for s in states.sensor
if 'energy' in s.entity_id and s.attributes.unit_of_measurement == 'kWh' %}
- {{ s.entity_id }}: {{ s.state }} {{ s.attributes.unit_of_measurement }}
{% endfor %}Any ideas on how you would add switches and Kasa outlets to the light count? Not outlets, just the one's I label "Lights"
Any ideas on how you would add switches and Kasa outlets to the light count? Not outlets, just the one's I label "Lights"
I found this Configuration that does it! https://www.home-assistant.io/integrations/switch_as_x/
How to add more area with "Switch On Count"? I tried use {% set area_id = ['living_room', 'bedroom'] %}.but no lucky
Thanks
Look how he did the light on count
There is some great stuff in here, thanks everyone!
Is there a way to have the welcome msg with calendar even be in 12h format instead of 24?
How to add more area with "Switch On Count"? I tried use {% set area_id = ['living_room', 'bedroom'] %}.but no lucky
Thanks
{% set AREAS = ['kitchen','office','bedroom','living room'] %}
{% set DOMAIN = 'switch' %}
{% set ns = namespace(ids=[]) %}
{% for a in AREAS %}
{% set ns.ids = ns.ids + area_entities(a) %}
{% endfor %}
{{ expand(ns.ids|unique)
| selectattr('domain','equalto', DOMAIN)
| selectattr('state','equalto','on')
| list | count }}
How to add more area with "Switch On Count"?
I tried use {% set area_id = ['living_room', 'bedroom'] %}.but no lucky
Thanks