Sun condition not working as expected

Shouldn’t this test pass as true?
Running Home Assistant 2022.4.5

Few more tests

from Conditions - Home Assistant

Hoi,

i have the same issue and i live in the same city as yours, im curious how to fix it. maybe our city is not correct? lol :grinning:

1 Like

This tripped me up recently as well, looking forward to responses. The time between sunset and sunrise should pass IMO.

1 Like

What a coincidence :slight_smile:

As a quick test I moved my HA location to Paris, but having the same issue over there

Here is our answer, right in the documentation:

1 Like

Hmmm, but there is also this example in the same documentation.

That is an unfortunate error in the documentation, I’ll raise a PR to get it fixed. Thanks for pointing it out.

I have same issue in Amsterdam. Posted already that theme change automation not.work. Based on the sun. Still,didn’t find solution for.it.

I guess it’s linked to this problem.

- id: "7e98e973-70c1-4809-8fec-56dbf82b492b"
  alias: "System - Automatic Theme Change Day/Night"
  trigger:
    - platform: homeassistant
      event: start

    - platform: sun
      event: sunset

    - platform: sun
      event: sunrise

  condition: []

  action:
    - service: frontend.set_theme
      data:
        name: "{{ 'iOS Light Mode' if is_state('sun.sun', 'above_horizon') else 'iOS Dark Mode' }}"

The sunrise / sunset triggers work for me at 42°S. I’m not using the condition though.

Care to share your config or link to the post with your issue?

Added the yaml automation to my post

If the documentation is not correct then the UI also generates a incorrect yaml result

This:

Results in this:

No, it just doesn’t stop you generating a condition that won’t work. You could just as easily create a condition that requires a switch to be on and off, it won’t stop you. It’s not that smart.

You need to use an OR condition.

This is about conditions, not triggers. Probably best to start your own topic as it is almost certainly a different issue.

Hi All,

This automation is not working at all anymore for months now:
It was working always but now search for moths why its not working.
The 2 users that login into Dashboard have “Backend-selected” on
On FKB, HA iOS App, ANdroid App all not change the theme:

- id: "7e98e973-70c1-4809-8fec-56dbf82b492b"
  alias: "System - Automatic Theme Change Day/Night"
  trigger:
    - platform: homeassistant
      event: start

    - platform: sun
      event: sunset

    - platform: sun
      event: sunrise

  condition: []

  action:
    - service: frontend.set_theme
      data:
        name: "{{ 'Peter Light Mode' if is_state('sun.sun', 'above_horizon') else 'Peter Dark Mode' }}"

RPI4
Home Assistant Core 2022.5.5
Home Assistant Supervisor 2022.05.2
Home Assistant OS 8.0
Kernel version 5.15.32-v8
Agent version 1.2.1

Neither of these are valid theme identifiers.

This would never have worked.

Show me the first two lines of your themes.

When i do it manual in profile then i can select in pull-down both themes and then screen changes

Peter Dark Mode:
  iron-overlay-backdrop-filter: "blur(10px) grayscale(50%)"
  iron-overlay-backdrop-background-color: "rgba(41,128,185,0.25)"

Peter Light Mode:
  iron-overlay-backdrop-filter: "blur(10px) grayscale(50%)"
  iron-overlay-backdrop-background-color: "rgba(41,128,185,0.25)"

Will it help to change name to:

peter_dark_mode:
peter_light_mode:

Try it.

I have change it now. Will wait until sun become sunset state :slight_smile:

You can do that in the Developer Tools - State
Scrap that, doesnt look there is a way to test the sunset/sunrise trigger?

doesn’t work. Other automatons are react on change the sun.sun state but not the theme automation…

Did you change this as well as the theme names?

name: "{{ 'Peter Light Mode' if is_state('sun.sun', 'above_horizon') else 'Peter Dark Mode' }}"

Did you reload automations and themes?