I am just getting started and having a problem with a basic rule problem.
What I wish to do is send a mqtt alert when a pir sensor is activated and nest is away.
my mqtt pi sensor displays correctly in site map as does nest away.
I am getting a bit frustrated.
my items are
Number GRLight "Garage Light [MAP(binary.map):%S]" (All) { mqtt="<[broker:jpfy/house/sensor/garage/PIR:state:default]" }
Switch GarageAlarm "Garage Alarm" { mqtt=">[broker:jpfy/house/warning/GarageAlarm:command:ON:1],>[broker:jpfy/house/warning/GarageAlarm:command:OFF:0]" }
String home_away "Home/Away [%s]" <present> (Nest) { nest="=[structures(Home).away]" }
binary map is:
0=OFF
1=ON
OFF=0
ON=1
And my rule file is
//jpfy rules file v0.01
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
// If away from home and motion sensor in garage on send message
var Timer timer = null
rule "garageintruder"
when
Item GRLight==1 and
Item home_away==away
then
if(timer==null){
sendCommand(GarageAlarm, ON)
timer = createTimer(now.plusSeconds(60)
}
else {
if(timer!=null) {
timer.cancel
timer = null
sendCommand(GarageAlarm, OFF)
}
}
end
Thank you for any advice as its driving me mad.
Phil