Only a week into this but have something working
The Goal is turn on my garage Lights ON when the garage door is open and it nite time for 10MIN
This is MARK 1
First i had to work out nite So i used the astro plug
// put this at top of page
var Timer Timer_Bla=null
rule "OpenHAB system started - astro"
when
System started
then
createTimer(now.plusSeconds(180)) [ |
if (now.isAfter((Sunset_Time.state as DateTimeType).calendar.timeInMillis) ||
now.isBefore((Sunrise_Time.state as DateTimeType).calendar.timeInMillis)
) {
postUpdate(NightState, ON)
} else {
postUpdate(NightState, OFF)
}
]
end
rule "Update NightState"
when
Item SunElevation changed
then
if(SunElevation.state > 0){
if(NightState.state != OFF) postUpdate(NightState, OFF)
} else {
if(NightState.state != ON) postUpdate(NightState, ON)
}
end
dont under stand it yet but getting there it WORKS
next the rule for the Sensor_Garage
rule "Turn on garage Light when Night time"
when Item Sensor_Garage changed from CLOSED to OPEN
then
if (NightState.state == ON) {
Garage_light.sendCommand(ON)
Timer_Bla = createTimer(now.plusMinutes(10), [|
Garage_light.sendCommand(OFF)
])
}
end
Done
i come from windows using VBscript for everything
the hard bit been dealing with the {} [] () and the case naming
me HAPPY CAMPER