Another sunrise/sunset topic

Hello! Its me again…

After finally getting z-stick to work, i’ve been moving on to main goal; turning outside lights on and off according to sunrise/sunset.

I’ve tried the example docs and many other automations found on google and the community with no luck…

please help :smiley:

  - alias: 'Utelys AV'
trigger:
  platform: sun
  event: sunrise
action:
  - service: switch.turn_off
    entity_id: switch.qubino_zmnhadx_flush_1_relay_switch
  
  
  

  - alias: 'Utelys PÅ'
trigger:
  platform: sun
  event: sunset
  offset: '00:00:00'
action:
  - service: switch.turn_on
    entity_id: switch.qubino_zmnhadx_flush_1_relay_switch
  - service: switch.turn_on
    entity_id: switch.qubino_zmnhadx_flush_1_relay_switch

The formatting is quite off, which might be the problem. I’d expect the following to work:

- alias: 'Utelys AV'
  trigger:
    - platform: sun
      event: sunrise
  action:
    - service: switch.turn_off
      entity_id: switch.qubino_zmnhadx_flush_1_relay_switch
  
- alias: 'Utelys PÅ'
  trigger:
    - platform: sun
      event: sunset
  action:
    - service: switch.turn_on
      entity_id: switch.qubino_zmnhadx_flush_1_relay_switch

I use these automations to turn an outside light on at dusk, on in the morning, and off at either midnight or sunrise.

Thank you for your response.

I’ve tried this now with offsets and still no luck. nothing happens!(the light turns on and off if i push trigger)

But, if i go to states and “sun.sun” it reads 16:04, but its actually setting 18:08 here in oslo. The timezone is correct in the config…

automations using time is working fine… Im really confused right now!

the SUN component should not have a time as its state.
Make sure your latitude and longitude are right in configuration.yaml.
Make sure your timezone is right in configuration.yaml.
Make sure you have a line in configuration.yaml that says
sun:

Then when this is all set up, go to the developer tools, states page and you should see something like this in the sun.sun attributes.

next_dawn: 2017-10-15T12:00:02+00:00
next_dusk: 2017-10-16T00:06:58+00:00
next_midnight: 2017-10-16T06:03:07+00:00
next_noon: 2017-10-15T18:03:30+00:00
next_rising: 2017-10-15T12:26:53+00:00
next_setting: 2017-10-15T23:40:07+00:00
elevation: -10.13
azimuth: 93.23
friendly_name: Sun

I use the solar angle for my automations istead of sunrise and sun set

  - platform: template
    sensors:
      solar_angle:
        value_template: '{{ "%+.1f"|format(states.sun.sun.attributes.elevation) }}'
        friendly_name: 'Sun Angle'
        unit_of_measurement: '°'
- alias: 'Switch on lights when we are out'
  hide_entity: False
  trigger:
    platform: numeric_state
    entity_id: sensor.solar_angle
    below: 1.0
  condition:
    condition: state
    entity_id: group.family
    state: 'not_home'
  action:
     - service: light.turn_on
       entity_id: light.living_room_colour,light.landing
       data:
         rgb_color: [255, 255, 255]
         brightness: 190