Hi, I’m completely new to HA so forgive me if this is an easy question - I’m just finding my feet. I’m moving over from SmartThings as it’s now really hard to do anything useful now that webcore is done.
One of my most useful pistons used to calculate a time based on a dynamic offset from sunrise/sunset. The idea being that during the year it changes how quickly it gets dark.
So what I would like is a toggle/switch which is set dynamically by an automation (or similar), following this logic.
IsItDark=
Time is after {addMinutes($sunset, - (2.5 * $month ** 2 - 30 * $month + 120)))
OR
Time is before (addMinutes($sunrise, (2.5 * month ** 2 - 30 * $month * 120))}
I then want to be able to use the toggle/switch to run other logic/automations from.
Sun elevatiin will give you the same result and you can use standard values for twilight… It will change the durante n Iver the year, but will always be related to the sun elevation.
If you have the Sun integration you can take a look at the entity sun.sun for its attribute named elevation:
You want a helper (Devices and Services, Helper). Make a toggle helper which becomes an input_boolean.your_device entity. You can test or set this entity from any automation or ESPHome program.
OK thanks for the tips. I’ve found the helpers and now have a toggle… I’ve worked out how to create the automation, re-evaluate it every minute, and I can control the toggle. The only bit missing is the maths bit in the middle. How would I evaluate an expression similar to the above?