#Automation double-check please?

1 messages · Page 1 of 1 (latest)

visual sierra
#

Hi Everyone,

Just wondering if anyone could double-check the automation below. I’m trying to set up my living room light in such a way that it:

  • Turns on 30 minutes before sunset
  • Only when my wife or me are home

I’ve created groups.yaml and made a group called somebody_home so I can check for the state of that group.

Is the code below correct for what I want to achieve?

description: ""
trigger:
  - platform: sun
    event: sunset
    offset: "-00:30:00"
condition:
  - condition: state
    entity_id: group.somebody_home
    state: home
action:
  - service: light.turn_on
    data:
      transition: 1800
      brightness_pct: 40
    target:
      entity_id: light.hue_infuse_ceiling_1
mode: single```

Thanks in advance folks!
robust lintel
#

That will turn on the light 30min before sunset if someone is home. Do you want it to also turn on the light when someone comes home if it is less than 30min before sunset?

visual sierra
robust lintel
#

Then your automation should be structured like this pseudocode:

trigger:
  - 30min before sunset
  - group.somebody_home changes to home
condition:
  - sunset - now <= 30min
  - group.somebody_home has state home
action:
  - turn on light
visual sierra