I also just noticed I used the wrong style of quotation marks in the template. I used the “fancy” style instead of the standard text ones because I just did a copy/paste of your post. You probably noticed that if you have it working but I edited the post for the sake of completeness.
Ive got an error to except i get “none” how did you fix?
gotten this to work when manually executing but it wont trigger the automation on its own…
automation:
- id: Door Check
alias: Door Check
trigger:
- platform: state
entity_id: group.life360
from: home
to: not_home
- platform: time
at: '15:24:00'
condition:
condition: template
value_template: >
# this counts the doors that are open and if we have any that are open, the notify will occur
{{ states | selectattr('entity_id', 'in', state_attr('group.all_doors','entity_id')) | selectattr('state','in',['on','open']) | list | length >= 1 }}
action:
- service: notify.ios_marks_iphone_xr
data_template:
title: "Caution!"
message: >
{% set open_doors = states | selectattr('entity_id', 'in', state_attr('group.all_doors','entity_id')) | selectattr('state','in',['on','open']) | map(attribute='name') | list %}
{% if open_doors | length == 1 %}
The {{ open_doors[0] }} door is open.
{% else %}
The {{ open_doors[:-1] | join(', ') }}{{',' if open_doors | length > 2 else ' door'}} and {{ open_doors[-1]}} door are open.
{% endif %}
The docs recommend home and not_home be in quotes…
even still i change it to a state of a light turning on and it still doesnt trigger it…
c’mon. “doesn’t work” means nothing, especially without a config to look at.
If you think it doesn’t trigger (which is easy to check in States), what can be the cause?
It’s either wrong trigger
or condition
section.
Make it as simple as possible - remove condition
and strip down trigger
so it’s simple and yet functional and try to make it work (don’t forget to consult with the docs, don’t just poke around).
Then work with your condition - if it’s a template, test it in Template Editor until you get what you want.
Only then put it all together and check if it works.
Ideally you need to do it yourself as only you have access to your entities and can easily debug your automation, you just need to know how.
If you opt for asking for help - read this, follow it and be patient
And one more thing - it’s a bad idea to resurrect old topics, better to create a new one and reference the old one as a source of your code.
Also, you need to be careful when using solutions from old topics as HA changes rapidly and the functionality might be different now or doesn’t exist anymore.
also - check the state history of group.life360 in the logbook - does it actually change???
does group.all_doors exist?
@AhmadK i did post my code like 3 post up?? i have used the template editor with my condition template give true/false and my action give the correct print. It even works with a script that test the template and the action together. It only doesnt work when it is triggered by the automation… i even changed the trigger to something simple like a light turning on and off.
@walaj yes it does and i even tested it with something simple like a light turning on
@petro yes it does. All of the templates work in editor
the group state changes from home to not_home when you turn on a light? That’s not how groups work.
@petro no i changed the trigger entirely to something else… like a going from off to on to test a simpler trigger
Ok, is the automation turned on?
yes the switch is on
That’s ambiguous… The automation is on or a switch that triggers is on?
nope. I’m talking about this
and apparently you’re still discussing a simplified config we never saw.
post it here, please
Sure heres both configs again…
- id: test doors open
alias: test doors open
trigger:
- platform: state
entity_id: group.people
from: 'home'
to: 'not_home'
- platform: time
at: '22:00:00'
condition:
condition: template
value_template: >
# this counts the doors that are open and if we have any that are open, the notify will occur
{{ states | selectattr('entity_id', 'in', state_attr('group.all_covers','entity_id')) | selectattr('state','in',['on','open']) | list | length >= 1 }}
action:
- service: notify.mobile_app_chandler_sharps_iphone
data_template:
title: "Doors Open!"
message: >
{% set open_doors = states | selectattr('entity_id', 'in', state_attr('group.all_covers','entity_id')) | selectattr('state','in',['on','open']) | list | map(attribute='name') | join(', ') %}
The following doors are open: {{ open_doors }}
simplified
- id: test doors open
alias: test doors open
trigger:
platform: state
entity_id: light.aroma_lamp
from: 'off'
to: 'on'
condition:
condition: template
value_template: >
# this counts the doors that are open and if we have any that are open, the notify will occur
{{ states | selectattr('entity_id', 'in', state_attr('group.all_covers','entity_id')) | selectattr('state','in',['on','open']) | list | length >= 1 }}
action:
- service: notify.mobile_app_chandler_sharps_iphone
data_template:
title: "Doors Open!"
message: >
{% set open_doors = states | selectattr('entity_id', 'in', state_attr('group.all_covers','entity_id')) | selectattr('state','in',['on','open']) | list | map(attribute='name') | join(', ') %}
The following doors are open: {{ open_doors }}
If manually pressing the simplified one is working but the trigger is not, the issue lies in your condition.
So, please, take a screenshot of your group.all_covers in the dev tools states page.
But if the simple one runs, doesn’t that mean the condition is ok, and its the trigger?
Just in case, @Chandler_K_Sharp can you confirm that when you are testing group.people actually goes to ‘not_home’ - how are you testing this - everyone leaves the house and your device_tracker/people tracker is correctly setting not_home?
Does the automation run at 10pm?
at risk of being simplistic - can you set the time part of the trigger to a couple minutes in the future, open the garage door and see what happens? A) does it trigger, B) does it notify?
ALSO - just checked a similar automation I have:
- alias: "SECURITY: check all doors at 8PM"
initial_state: true
trigger:
platform: time
at: '20:00:00'
condition:
condition: template
value_template: "{{ states | selectattr('entity_id', 'in', state_attr('group.doors','entity_id')) | selectattr('state','in',['on','open']) | list | length >= 1 }}"
# this counts the doors that are open and if we have any that are open, the notify will occur
action:
- service: notify.emailjonwork
data_template:
title: "Doors Open!"
message: >
{% set open_doors = states | selectattr('entity_id', 'in', state_attr('group.doors','entity_id')) | selectattr('state','in',['on','open']) | map(attribute='name') | list %}
{% if open_doors | length == 1 %}
Hi. It is 8pm and the {{ open_doors[0] }} is open.
{% else %}
Hi. It is 8pm and the {{ open_doors[:-1] | join(', ') }}{{' door,' if open_doors | length > 2 else ' '}} and {{ open_doors[-1]}} are open.
{% endif %}
The main difference I see is that the condition value_template is in "…
but you don’t have >
after value_template
. it’s ok, multiline YAML string.