Condition sun after 00:00 - (resolved)

condition to function after sunset

friends,
I have some cars that are conditioned only after sunset, they work perfectly before 00:00 …

After 00:00, it does not work .....

I tried to activate the option also before sunrise.

But it does not work … What am I missing?

- id: '1527478719908'
  alias: kodi stop
  trigger:
  - entity_id: media_player.kodi
    from: playing
    platform: state
    to: idle
  condition:
  - after: sunset
    before: sunrise
    condition: sun
  action:
  - data:
      event: luz-sala-todas-on
    service: ifttt.trigger

You could use a state condition on the sun instead:

condition:
  condition: state
  entity_id: sun.sun
  state: 'below_horizon'
1 Like

I had the same issue although I used the automation editor. My workaround was to use 2 separate automations. One for the after sunset condition and a separate automation for the before sunrise condition.

1 Like

Sunset and Sunrise don’t remain valid before/after 00:00. After sunset, is only from sunset to 00:00 and before sunrise is only 00:00 to sunrise.

You need to use two separate conditions, one after sunset, and another before sunrise, OR’ed together.

Here’s an example,

  • condition: or
    conditions:
    • condition: time
      after: ‘23:10:00’
    • condition: sun
      before: sunrise
      before_offset: ‘-00:15:00’
1 Like

I’ll give that choice and give you feedback.

He ran. This was the solution. Thank you all!!