Where I live, the longest day of the year provides over 15 hours of daylight. So simply offsetting 15 hours from sunrise sunset would mean the light is turned on after sunrise.
Perhaps the ‘turn on coop light’ automation needs a condition that ensures daylight hours are less than 15. If greater than 15, then the light doesn’t need to turn on.
I was think of something similar and the way I thought of the automations is :
Automation #1 : Turn ON the light at SUNSET, with an offset of -15 hours, and a condition that it is before SUNRISE
Automation #2 : Turn OFF the light at SUNRISE
Hang on, what balance is needed, if any e.g. should we just start 7.5 hours before noon? And off 7.5 hrs later? Then work out what to switch around the horizon transitions ? What are the predator criteria ? When are the predators most active ? Early evening or early morning? What overlap sunrise/sunset do you need with the daylight. Sunrise/sunset is still pretty bright. I only allow external lights on when sun lower than -4 degrees.
Do you have a dimmer, it it set with transitions? Would that be better or hard / on hard off
(noon is calculated as the sun’s highest point, not 12:00)
I think that this should be written up as a package and anyone should be able to use it we could call it care of chicken kind or cock for short.
That just seems waaay too simple. Why wouldn’t this work? It’s a conditional based on sunset, not a timer so even if a restart happened, the condition would still be tested.
If you don’t care if the light is on either before sunrise or after sunset you could easily just do something like this:
Trigger: CurrentTime = 15 - (Todays daylight in hours). Use this to turn on the light that many hours before sunrise.
Then turn off the light as soon as the sun is up.
In this case, you can easily make sure that your chickens always get 15h of light.
i.e.: Daylight Hours are 8h.
Sunrise is at 07:00
That would mean your automation would turn on the light @ 0:00 midnight (07:00 - ( 15:00 - 8:00 ))
And then turn off as soon as there is daylight at 7:00.
Another possibility would be a light sensor in the chicken coop Then you just check for the light level and turn on the light if the light level is below a certain threshold and has not been above a certain threshold for 15h already.
that’s kind of what my template is doing, except it uses sunset instead of daylight hours.
But it’s not as simple as a strict numerical calculation because you have to convert everything to a datetime object the do the calculation, then compare it to the current time. Or convert the current time hour into a number to compare. but then how do you handle the minutes?
if you just do the “15 - hours” you get a number similar to what jazzmonger got in this post
And that can’t be used for comparison to the time now to cause the trigger.
So the automation turns on the light 15 hours before sunset then turns it off 1 hour after sunrise. That’s it, that’s all.
The joke’s on us. This lengthy thread was all about accurately interpreting your requirements and precisely controlling the light’s duration (to the minute). In contrast, your chosen solution allows the light to remain on for a full hour after sunrise … or so it seems?
nowhere did I ever state that. in fact this was stated: ““Yes, I want to overlap and turn on an hour before sunrise and give the little guys 15 +/- hours of light. Each day.””
and as you can tell, there a numerous ways to do this, depending on how you approach it. some quite complex, others simple. And judging from the responses, it appears it was a worthwhile exercise where most learned something, esp about templating and an enhanced sun.sun. which makes the platform even more useful to folks like me.
I never claimed you did. Nevertheless, the efforts to create a solution aimed for that level of accuracy. It’s clear that your 1-hour overlap comment was overlooked by many contributors (including me).
Based on my experience (about a year of participation in many hundreds of posts), I’d say this was an exercise in a cluster-fudge. Something is amiss when it takes a small army and 40+ posts to devise an egg-timer.
Dollars to donuts this would’ve been a concise thread had the requirements been stated as ‘turn on the light 15 hours before sunset then turn it off 1 hour after sunrise’. And that’s no yolk.
Way to go. You’re doing a really great job of discouraging people from asking questions and even figuring out what question to ask and stumbling through a complicated system where one of the stated objectives is to simplify it.
On the contrary. It’s in everyone’s best interest to ask questions. In fact, there’s even a detailed explanation available of how to ask good questions.
I encourage everyone to read it and apply it when composing their questions. They’re more likely to get a faster, better answer.