Hi all
I want to turn on and off the lights of my terrarium based on some calculations.
On: time of sunset
Off: time of sunset + duration
I want to calculate the duration based on the number of the day in the year. My reference day is 21/12 = day 355. This is the middle of winter → duration = 720 minutes (12 hours of light). Every day that is more or less than this day needs an additional 1.32 minutes of light.
Example 20/12 and 22/12 are 1 day different → duration is 720 + 1.32 = 721.32 minutes.
I simulated this calculation in Excel, where the formulas work. Now I need to apply that logic in HASS and that is the difficult part for me.
I started by creating 3 helpers in Settings - Helpers:
- template sensor to save the ‘Lights On’ time = {{ states(‘sensor.sun_next_rising’) }}
- template sensor to save the ‘Lights Off’ time = {{ states(‘sensor.sun_next_rising’) + timedelta(minutes=duration) }}
- number = 720 (static value for now)
The first issue I have is that I can’t seem to add the duration to the On Time. Even {{ states(‘sensor.sun_next_rising’) + timedelta(minutes=720) }} is not working (sensor unavailable).
What am I doing now?
When this is working I want to calculate the duration.
Any feedback and tips are welcome!
2 posts - 2 participants