Simple autiomation with time and sun

Hi,

Trying to get a simple on/off to work:

  • Outdoor lamp that should turn on by sunset and off at sunrise
  • Certain indoor lamps to turn on by sunset
  • Certain indoor lamps to turn on by me but turn off at specific time example, 23:00

I just can’t figure it out, been reading examples… what am doing wrong ?

automation:
- alias: 'Turn on light when sun sets'
  
  trigger:
    platform: sun
    event: sunset
    offset: '-00:20:00'
  action:
    service: homeassistant.turn_on
    entity_id: switch.ute_trappa
- alias: 'Turn off light when sun raise'
  
  trigger:
    platform: sun
    event: sunrise
    offset: '-00:20:00'
  action:
    service: homeassistant.turn_off
    entity_id: switch.ute_trappa
# automation:
- alias 'Goodnight'
  trigger:
    - platform: time
      after: '23:00'
  condition:
    condition: state
    entity_id: group.all_home
    state: on
  action:
    service: homeassistant.turn_off
    entity_id: group.all_home

Any help would be apriciated…

i have on at sunset, and off at 11:30pm

automation:
- alias: "Lamp: Turn on at sun set"
  trigger:
    platform: sun
    event: sunset
  action:
    service: switch.turn_on
    entity_id: switch.lamp
- alias: "Lamp: Turn off at midnight"
  trigger:
    platform: time
    hours: 23
    minutes: 35
    seconds: 0
  action:
    service: switch.turn_off
    entity_id: switch.lamp

Hi,

Thanks for the input, If I want to have a lamp that turns on at sunset and off by sunrise, any suggestion on how todo that ?

Hi,

So I will try the following:

group:
  No_home:
    - switch.allrum_tavla
    - switch.allrum_slinga
  All_home:
    - switch.allrum_tv_bank
    - switch.vardagsrum_h_fonster
    - switch.vardagsrum_v_fonster
    
tellstick:

verisure:

automation:
- alias: "Lamp: Turn on at sunset"
  trigger:
    platform: sun
    event: sunset
  action:
    service: switch.turn_on
    entity_id: switch.ute_trappa
    
- alias: "Lamp: Turn off at sunrise"
  trigger:
    platform: sun
    event: sunrise
  action:
    service: switch.turn_off
    entity_id: switch.ute_trappa
    
- alias: "Lamp: Turn off at midnight"
  trigger:
    platform: time
    hours: 23
    minutes: 35
    seconds: 0
  action:
    service: switch.turn_off
    entity_id: group.All_home

Is there an easy way to test it instead of waiting for time/sunset to happen ?

1 Like