Automation that checks for is doors are open before going to bed

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 :wink:

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 :wink:

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 }}
1 Like

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.

also the template editor comes back true for the condition template

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.

shame - thought that might have been an easy fix

don’t worry, at least yours does work :wink:

Manually executing doesn’t execute the tigger or conditions only the actions

ahh - yup - didn’t consider that - however, if the simplified one runs when the light is turned on outside HA, that would suggest it is using the trigger/condition… guess it depends how @Chandler_K_Sharp is actually triggering it…

The simple one doesnt run either. the only way i can get either of them to run is to trigger manually. i know group.people goes to not home because it is triggering other automations without templates… its something about the templates causing issues but idk what