Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95919

Doors Open/Unlocked/People Home Template Help

$
0
0

@Bartem wrote:

So I have a “report” that tells me people which are home that works fine, but I’d like to add doors which are open to it, but what I’d really like to do that I’m having trouble with is, including my door locks, so it would say something like:
The side door is open. OR The side door is unlocked…
(obviously if it is open, it is unlocked, so I don’t need it to say both if it is open, but I would like to know if it’s unlocked but closed)
I can’t really figure out how to get it to only choose open/vs unlocked when both are on/unlocked.
This is what I have so far, obviously it’s pretty much two of the same, so ideally I’d like to make it all one continuous response, in this current state it leaves a couple blank lines between the result.

{% set people_home = states | selectattr('entity_id', 'in', state_attr('group.family','entity_id')) | selectattr('state','in',['home']) | map(attribute='name') | list %}
{% if people_home | length == 1 %}
{{ people_home[0] }} is at home
{% elif people_home | length == 0 %}
The house is empty
{% else %}
{{ people_home[:-1] | join(', ') }}{{',' if people_home | length > 2 else ''}} and {{ people_home[-1]}} are home
{% endif %}
{% set doors_open = states | selectattr('entity_id', 'in', state_attr('group.doors','entity_id')) | selectattr('state','in',['on']) | map(attribute='name') | list %}
{% if doors_open | length == 1 %}
and the {{ doors_open[0] }} is open
{% elif doors_open | length == 0 %}
and all doors are secure
{% else %}
and the {{ doors_open[:-1] | join(', ') }}{{',' if doors_open | length > 2 else ''}} and {{ doors_open[-1]}} are open
{% endif %}

Any help would be appreciated… I’m a pretty much a noob when it comes to templates…

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>