Automation trouble on trigger en condition

Hello,

I try to make an automation but can’t get it working.

what i have so far, a group of people called group.vip, if everybody is in the house the groups state is home, if someone is not at home it says away.

what i want, if all people are in the house at let’s say 22:00 clock the front light needs to be turnd off.
if someone is away, the light needs to stay on and only should turned off if the last person has enter the house.

The last part i mannaged to build it to trigger at a state change from away to home after 22:00h

but it isn’t trigger if the group already is at home !

you need 2 triggers, one for group = home, one for time = 22:00
then you need 2 conditions, one for group == home, one for time >= 22:00.

(That’s assuming that your group shows away if at least 1 person is not home, which is not the default behaviour of a group. just wanted to point this out…)

I alterd the group, if one person is away, the group shows away.

i will look into it when i’m back home.

Don’t get it working, would you be so kind to write a small example.

Found the solution:

- id: 'test'
  alias: Frontdoor_off
  description: 'Frontdoor_off'
  trigger:
  - minutes: '1'
    platform: time_pattern
  condition:
  - after: '22:00'
    condition: time
  - condition: state
    entity_id: group.vip
    state: home
  action:
  - entity_id: switch.frontdoor_light
    service: switch.turn_off

So basically it’ll try to trigger every hour… I wonder if it’s the best solution.

This is what I meant:

- id: 'test'
  alias: Frontdoor_off
  description: 'Frontdoor_off'
  trigger:
    platform: time_pattern
    hours: 22
    minutes: 0
    seconds: 0
  - platform: state
    entity_id: group.vip
    to: 'home'
  condition:
  - after: '22:00'
    condition: time
  - condition: state
    entity_id: group.vip
    state: 'home'
  action:
  - entity_id: switch.frontdoor_light
    service: switch.turn_off

How I’d do it

trigger:
  platform: time
  at: '22:00:00'
action:
  - wait_template: "{{ is_state('group.vip' , 'home') }}"
    timeout: '02:00:00'
  - service: switch.turn_off
    entity_id: switch.frontdoor_light
1 Like

mf_social, if i’m right your light is turning off 2 hours after 22:00 if group is home ?

No, he’s saying if you arrive home before 2200 the light will go off at 2200, if you arrive at 2201 to 2359 it will turn off at that time
If you don’t come home it will go off at 0000

1 Like

This is exactly as you stated you wanted it but I don’t do it this way.

I have different radius zones set up around my home for heating lighting and announcements (and then home itself)

Anyone entering the light zone (after dark) triggers the porch light on (timed for 3 minutes) adjust as required. Saves energy, saves co2.

maybe time?
And I’m pretty sure we can drop keys with 0 values…

Lol just copied I’ve of my templates.
After I while I become lazy and just copy paste :joy:

1 Like

yeah :wink:
it’s a bit lengthy, especially comparing to Marc’s one so it asks for some trimming down

Thanks guys/girls,

The one from lolouk i have implemented and works great, to night i go test the one from mf_social.

Differrent radius like Mutt opposed isn’t going to work, my kids don’t always have data set on on there phone, so i can’t get a stady location signal from there phone.

I now test if the phone is in the home network.

Ah, understood in that case both loouk44’s and Marc’s would be good. Though I have to say that Marc’s is by far the most elegant for this sort of problem.

Regardless, it’s whatever you feel most comfortable with :+1:

1 Like

How dare you??? :rofl:

(even though you’re right . Doh ! )

1 Like

What can I say, Marc’s bribe was bigger ! :rofl:

1 Like

That’s what she said

*whistles nonchalantly

1 Like