Turn on lights 14 hours before sunset unless the sun is already up?

I raise chickens and quail. Their egg laying ability is light dependent. They need a minimum of 14 hours of day light a day to produce eggs. What I would like to do is automate the coop light to turn on 14 hours before sunset and the turn off at sunrise. That way my birds get enough light to trigger laying and can go to roost naturally as the sun sets. They get stressed out and will not move or roost if the light suddenly turns of and it is dark which is why I can’t just set the light to turn off after sunset they need the natural reduction in light caused buy the sun setting to go to roost. This is why I need to add the light to go on before sunrise. So they still get 14 hours of light and can naturally go to roost with the setting sun. Please help me to find a solution.

There should definitely be a way to do it, but I’m confused by this description. You say “turn off at sunrise“. That would mean that the lights stayed on all night long, but that doesn’t sound like what do you want to have happen. It sounds like you want to have them turn off at sunset. But maybe with a gradual fade for another hour or so.

Could you check your post again and make sure that you have described what you want to have happen? They are actually several community members who keep chickens and I’ve done various kinds of automation, and some of them may chime in. But in any case, you should be able to get whatever schedule you want with smartthings. I just want to make sure that we are providing answers for the specific use case you are working with. :sunglasses: :hatching_chick:

We will need to know the brand and model of the lights in the chicken coop, or of the light switch which is controlling them. Some have the ability to do a gradual fade and some don’t.

1 Like

@JDRoberts, the OP asks for to turn on the light 14 hours before sunset, to have 14 hours of light. But to turn off the light at sunrise, because he doesn’t want to waste electricity when there is natural light available.

The only issue here is, if the daylight hours longer than 14 hours, from Sunrise to Sunset. But that could be handled by an exception maybe by WebCore or Sharptools.io, I believe the current Automations builder would not work with this, maybe if a Location Mode is defined as Daytime and Night time.
Anyhow, the point is, if daylight hours are less than 14, then provide extra light by automation before sunrise to make it 14.

Something like this

IF Sunset-Sunrise < 14 hours, THEN turn on light at Sunrise -(14 - (Sunset - Sunrise)) hours AND turn off light at Sunrise.

2 Likes

I see. I agree, it’s probably going to take one of the more powerful rules builders. Because we have two different situations.

A) The time between sunrise and sunset is less than 14 hours. In that case it’s easy, you just set a second rule that always turns the light off at Sunrise. So one rule turns them on 14 hours before sunrise and the second rule turns them off at sunrise.

B) The time between sunrise and sunset is more than 14 hours. Then you have a problem because the “turn off at sunrise“ rule would work, but then the lights will turn on again an hour or two later when it’s 14 hours before sunset. Which would leave them on all day, not what you want.

So, yeah, you need to be able to evaluate how long it is between sunset and sunrise and only turn on if that value is less than 14.

Again, you can just have a separate rule that always turns the light off at sunrise, that shouldn’t hurt anything. But it’s the not having the light turn on again if it’s a day when there is 16 hours of sunlight that is going to be trickier.

Tagging @joshua_lyon

2 Likes

You could use Smart Lighting or multiple Automations to turn on the lights 14 hours before Sunset, only if Location Mode is Night time.
Another rule to turn off the light at Sunrise.
And two Automations to change Location mode to Night time at Sunset, and Daytime at Sunrise.

Maybe you can do the light off and change of Location mode to Daytime at Sunrise in one Automation.

So total 3 rule/Automation would do the job.

(Considering that no other Location modes are in use, otherwise a virtual switch could do the same, if no other option to define Day and Night time.)

2 Likes

Did you ever find a solution for this? I’m trying to do the same thing for the same reason now and haven’t found a straight forward way of doing it yet.

This looks to be possible in the new “Smart lighting” app. It has a sunset condition with selectable hours (0-23) and minutes (0-59). It can even be set in the same setting to turn off at sunrise.

The new smart lighting app has the same features as the original Smart lighting app in this regard.

This use case is tricky: if you read the comments above carefully, you’ll see that the issue that needs to be managed is the time of year when there are more than 14 hours in between sunrise and sunset. There’s nothing in the smart lighting app that can handle this kind of or condition in one rule.

So the solution remains the three routine approach that Gabor gave in post #5 above.

Turn on lights 14 hours before sunset unless the sun is already up? - #5 by GSzabados

If you want to do it all in one rule, you have to go to a rules engine that supports more complex if/then structures than the ones in the SmartThings app. You could do it with the sharptools pro level, Ifttt pro level, or the official rules API from SmartThings.

1 Like

Doh! Pesky long days! :slight_smile:

I confirm that Sharptools does have sunrise/sunset triggers and configurable offsets either side of those triggers. Additionally, flow can have an if statement restricting the device operation if before/after sunrise as needed.

2 Likes

I was thinking, another way to do this that would probably only require one routine created in the smartthings app would be to add an additional device, a light sensor, and then use the light level as a pre-condition. That way the lights would only come on when it was dark outside. But that would be an additional device cost, so maybe not worth it.

If this is for a chicken coop, it would have the advantage of turning the light on if it’s a rainy/cloudy day, even if it’s after sunrise. :sun_with_face::umbrella:

1 Like

Perhaps one of the Edge drivers that do “calendar” functions (such as this one) might help? IIRC, one of them could tell you the sunrise/sunset times for a given day in the year. Then, if the light of day isn’t long enough, you could add light at either end to make up the 14 hours.

Note: all off the top of my head–no thoughts how to actually do it! :yum:

1 Like