Automation flowers with Sun

HI I’m trying to secure a switch to turn on the lights for flowers that are inside the garage in the winter.
For example: when the sun rises, after 1 hour the switch should trigger and turn on the light, for 8 hours, then should turn off
Have tried sun integration but have not succeeded. What is it that is wrong.

- alias: 'Automatic flowers with Sun'
  trigger:
    - platform: numeric_state
      entity_id: sun.sun
      value_template: "{{ state_attr('sun.sun', 'elevation') }}"
      above: 1.00
    - platform: state
      entity_id: switch.telldus_tzwp_102_plug_in_switch_switch_4
      to: 'on'
      for: '08:00:00'
  action:
    choose:
      sequence:
        service: switch.turn_off
        entity_id: switch.telldus_tzwp_102_plug_in_switch_switch_4

This should be an action, not a trigger.

That is not “sun is up for an hour” it is “sun above horizon by 1 degree”

You have two triggers to your action that are in an “either/or” setup. If one or the other happens, the switch is turned off.

You want a trigger that fires the action, and that trigger could be any state or attribute of the sun.sun platform.

Then, your action would be to turn on the light, delay for 8 hours, then turn off the light.

Should I change to is better now?
I’m a little confused, could you help me?
Thank you.

- alias: 'Automation Flower with Sun'
  trigger:
  - event: sunrise
    platform: sun
    offset: '00:60:00'
  action:
  - service: switch.turn_on
    entity_id: switch.telldus_tzwp_102_plug_in_switch_switch_4
    
  trigger:
  - event: sunrise
    platform: sun
    offset: '07:00:00'
  action:
  - service: switch.turn_off
    entity_id: switch.telldus_tzwp_102_plug_in_switch_switch_4

If you want to stay with the elevation, try this

- alias: Light on for 8 hours
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sun.sun
    above: '1'
    value_template: '{{ state.attributes.elevation }}'
  condition: []
  action:
  - service: switch.turn_on
    data: {}
    entity_id: switch.officedesk
  - delay: 08:00:00
  - service: switch.turn_off
    data: {}
    entity_id: switch.officedesk
  mode: single

You have one trigger: the sun elevation.
There is no condition and there are two (three actions), one action for turning on, followed by a delay of 8 hours and an action to turn the switch off after that delay time.

Thanks, I’ll try this tomorrow when the sunrise is up

It works with your automation.
Thanks again

1 Like

You’re welcome.