Switch off the light at sunrise

Hello,

Fore sure I did something wrong with the automation that turns off the lights around the house at sunrise. This is the yaml code:

  • id: ‘1728314982955’
    alias: Licht Dakgoot UIT
    description: ‘’
    trigger:
    • platform: sun
      event: sunrise
      offset: 0
      condition:
      action:
    • service: switch.turn_off
      metadata: {}
      data: {}
      target:
      entity_id: switch.licht_dakgoot18
      mode: single

I wonder why the lamp switches off 34 minutes after sunrise. Today sunrise was at 7h24’. The light switches off at 7h56’. Why?

Sincerely,

Eduard

Copy-paste the following template into the Template Editor and confirm it reports the correct current time and the next sunrise time.

Time now: {{ now() }}

Next sunrise: {{ states('sensor.sun_next_rising') | as_datetime | as_local }}

Could this be a problem of different sunrise Civil or astronomical?

There is just over 34mins between Dawn and sunrise where I am.


Sun integration.

Suggest change event to dawn

Also remember that HAs sun integration was bugged from using the elevation value on the user setting page.
The elevation in the sun algorithm is the elevation from the actual surface and not from the sea level.

Use Sun2 instead to get a better sun integration.

According to the documentation, the Sun Trigger supports two events, sunrise and sunset.

The OP’s example uses sunrise which corresponds to the value of sensor.sun_next_rising.

But sunrise and sunset is based on the latitude, longitude and elevation in the user settings.
The problem is that the elevation is used wrongly, so if you have like 500m in elevation in the settings, because your position is that high over the sea level, then the sunrise and sunset will be off by a lot.
There is a thread on the forum about it.

  - trigger: numeric_state
    entity_id:
      - sensor.sun_solar_elevation
    above: 0

I think OP is in the Netherlands and highest point is 322.7 m above sea level (average 30m).
so just change the trigger to sun elevation and and adjust the level to whatever they want to that corresponds to a level of sunlight that they want light to be switched off based on what the sensor.sun_solar_elevation is at.
I am assuming the OP wants the light to turn off when it gets light rather than just to be alerted when it’s sunrise by the light being turned off.

Hello Taras,

Templates are new te me. I am seaching how to start with Home Assistant. It takes some time to become familiar with the most important features of this large program. For sure Templates will be a nice tool. I’ll take lookt at it now.

Thanks for Your help.

The kernel of my question has been resolved in adding the right offset to sunrise/sunset. The lights outside and the roller shutters are now working fine. Next step is reading how to do this in a better way.

Sincerely,
Eduard

The purpose the templates I provided you was to simply confirm that the times reported by your system (current time and sunrise) were correct. I wasn’t suggesting that you use templates in your automation’s trigger.

Because if either of the two times is incorrect, the Time Trigger and Sun Trigger will never work properly for you and force you to use offsets to fix them.

If either time is incorrect, you need to check the timezone you have set in Settings → System → General.