Help with turning lights on when garage door opens

Create an Item and link it to the civilDusk Channel. Then you can do something like…

rule “Shop Light On”
when
    Item contact_GarageDoor1 changed from 0 to 1
then
    if (now > new DateTime(civilDuskStart.state.toString) or now < new DateTime(civilDawnStart.state.toString)) {
        sendCommand(“ShopLight_Switch” , “ON”)
    }
end

You may also want to look into using something like the TimeOfDay DP, so you could just be comparing to the TimeOfDay Item.

And please use code fences.

Edit: I should have mentioned that this will not work if the garage door is opened after midnight, when the Astro binding will update the time of civil dusk. I’ve update the rule example I gave to tak ethis into consideration, but you’d need to also add an Item for civil dawn.

1 Like