#Sun

26 messages · Page 1 of 1 (latest)

steel wigeon
#

Hi all,

I am at a loss as to why my automation is not matching these conditions, I want to identify when it is 'day time' (after sunrise, before sunset):

conditions:

  • condition: sun
    after: sunrise
    before: sunset

Here is the trace, its patently within the 'wanted' times.

Executed: 26 September 2024 at 06:28:56
Result:
wanted_time_before: '2024-09-26T17:54:53.332838+00:00'
wanted_time_after: '2024-09-26T06:00:30.220630+00:00'
result: false

What am I missing?

steel wigeon
#

This template condion works, however:

{{
as_timestamp(state_attr('sun.sun', 'next_rising')) - 86400
and now().timestamp() <= as_timestamp(state_attr('sun.sun', 'next_setting'))
}}

The same thing, no? (except the slight change in next_rising day to day)

midnight wave
#

Hey, @steel wigeon I have a suggestion

#

instead of combining both conditions into one sun condition block,

#

try breaking them into separate conditions

#

make sense?

unborn wing
#

Why not use the state of sun.sun being above_horizon?

#

Also...

wintry emberBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

midnight wave
#

Hey @steel wigeon haven't you fixed it yet?

steel wigeon
midnight wave
#

@steel wigeon If you have any issue more, you can let me know anytime. even in case of DM, I will be okay.

spice sandal
steel wigeon
spice sandal
#

Every state is stored as UTC in the backend. You don’t have to worry about it. You can do direct comparisons between different time zones. HA (actually Python) is smart enough to handle the conversion

#

The automation didn’t trigger because the sun had either set or not risen yet. It should be working as intended.

steel wigeon
spice sandal
#

If you download the trace and look at it, I would expect the comparisons to all be done in UTC. It’s just a front end thing that is showing your local time

steel wigeon
#

I know what's happened. Sunrise is 0700 local time. Its been blacker than night until then in england so I just took the 6am value as 'sunrise' and expected it to be 'true' @ 6:28..

#

Essentially, I'm an idiot

spice sandal
#

Yes, HA knows how to handle the time zones. It’s just that you didn’t know how to interpret them when you read the trace 😋

unborn wing
#

The time on the clock isn't relevant

steel wigeon
#

I see where you are coming from - and I agree, except when you are looking at HA logs 😄

unborn wing
#

Well... that's a human problem 😛