var Timer timer
rule "Too much CO2"
when
Item_co2 received update
then
if (Item_CO2_.value > 700) {
if (timer === null) {
ventil.postUpdate("ON") // updates an item, sending MQTT
publish("ohbroker", "ventil", "ON") // sends MQTT command
//Item_Ventil.sendCommand(ON) //turn on the vent
timer = createTimer(now.plusMinutes(10), [ | //start and create the timer
Item_Ventil.sendCommand(OFF) //end of timer action
timer = null //reset the timer
] )
}
}
end
Last update of the rule after I found a typer CO2 in the code but that was just one problem, as the rule still doesnt trigger the item ventil. (i also set down the triggerlevel to 700 ppm as I dont want the sensor beeing overstressed with my breath…
I also still wonder as I tried to trigger the switch manually via mqtt-spy by topic:
cmnd/ventilator/POWER
with data “ON” which perfectly turned it on, resp. “OFF” to turn it off
hmmmm…
var Timer timer
rule "Too much CO2"
when
Item_co2 received update
then
if (Item_co2_.value > 700) {
if (timer === null) {
ventil.sendCommand(ON)
//Item_Ventil.sendCommand(ON) //turn on th$
timer = createTimer(now.plusMinutes(10), [ | //start and create the timer
ventil.sendCommand(OFF) //end of timer action
timer = null //reset the timer
] )
}
}
end
rule "Too much CO2"
when
Item_co2 received update
then
val co2value = Item_co2.state as Number
if (co2value > 700) {
if (timer === null) {
ventil.sendCommand(ON)
//Item_Ventil.sendCommand(ON) //turn on th$
timer = createTimer(now.plusMinutes(10), [ | //start and create the timer
ventil.sendCommand(OFF) //end of timer action
timer = null //reset the timer
] )
}
}
end
It seems that the command simply doesnt work at all.
Therefore I created another test rule to see if i can adress the item ventil directly by timer. The rule should toggle the switch every 3 sec
rule "Cron 3 Minuten"
when
Time cron "0 0/5 * * * ?"
then
ventil.sendCommand(ON)
createTimer(now.plusSeconds(3)) [| ventil.sendCommand(OFF) ]
end
Hey!!! Sucess I got it working! Final rule as follows:
var Timer timer
rule "Too much CO2"
when
Item co2 changed
then
if (co2.state > 1500) {
if (timer === null) {
ventil.sendCommand(ON)
//Item_Ventil.sendCommand(ON) //turn on th$
timer = createTimer(now.plusMinutes(1), [ | //start and create the timer
ventil.sendCommand(OFF) //end of timer action
timer = null //reset the timer
] )
}
}
end