Call trigger once again

Hi, sorry for this newbie question but how can I retrigger the automation when conditions become true? :slight_smile: I didn’t get it - sorry! My script will only fire once, right?!

The plan is that the light should only be switched on when all the people are not at home and the conditions are true - so even when everyone is out and the sunset will be there later.

alias: Rule_BalconyLight
trigger:
  - platform: state
    entity_id:
      - person.max
      - person.anna
    to: not_home
condition:
  - condition: device
    type: is_off
    device_id: 3dee28f48c3d23b71c44c10ee16ba5f8
    entity_id: switch.balcony
    domain: switch
  - condition: sun
    after: sunset
    after_offset: "00:10:00"
  - condition: time
    before: input_datetime.var_balconytimeoff
action:
  - type: turn_on
    device_id: 3dee28f48c3d23b71c44c10ee16ba5f8
    entity_id: switch.balcony
    domain: switch
mode: single

Currently, it will turn on as soon as one person leaves home (and the other conditions are met)…

If you want it to trigger both when the last person leaves and 10 minutes after sunset, you need to change your trigger.

trigger:
  - platform: numeric_state
    entity_id: zone.home
    below: 1
  - platform: sun
    event: sunset
    offset: "00:10:00"
condition:
  - condition: numeric_state
    entity_id: zone.home
    below: 1
  - condition: device
    type: is_off
    device_id: 3dee28f48c3d23b71c44c10ee16ba5f8
    entity_id: switch.balcony
    domain: switch
  - condition: sun
    after: sunset
    after_offset: "00:10:00"
  - condition: time
    before: input_datetime.var_balconytimeoff
action:
  - type: turn_on
    device_id: 3dee28f48c3d23b71c44c10ee16ba5f8
    entity_id: switch.balcony
    domain: switch
mode: single

Not sure if I am reading this correctly but it looks like you would like to turn “switch.balcony” on with the sun and off with time if the switch is off and no one is home.

if that is the case then.

The trigger should be sun. Conditions should be zone home like what drew said but a condition & your condition for device is good but you dont need it as if it is on and you turn it on then it is on followed by your action to turn_on then your time is needed for off.

EDIT: you dont need your device ID or domain

Hope this helps.

Hi, sorry for the confusion. I want to turn on the lamp when one of the people leaves the house, but only when the sun has set. If no one has left the house and the sun has set, the light should not go on. But as soon as someone leaves the house in the time window, it should come on again. I hope it is clearer now :slight_smile:

What if it one person is home and the other isn’t when sunset passes?