Hi
I have been tinkering with a remote for my home ventilation systyem, attached it to an arduino, added RFM to it so I can now influence the power of the fan (yay!). My regular rule setup to change the settings works fine:
rule "Select FAN level"
when
Item FAN_level received command
then
switch(receivedCommand) {
case 0 : postUpdate(itm_node4_fan, "1") // night
case 1 : postUpdate(itm_node4_fan, "2") // day
case 2 : postUpdate(itm_node4_fan, "3") // high
case 3 : postUpdate(itm_node4_fan, "4") // shower
}
end
So to take it a step further I am now measuring humidity in the shower and based on humidity levels am switching on the fan like this:
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.joda.time.*
var Timer timer4 = null
rule "Node 3 Humidity to FAN control"
when
Item itm_node3_hum_mqtt received update
then
if(itm_node3_hum_mqtt.state > 60 && Day_time.state == ON) {
if(timer4==null) {
sendCommand(postUpdate(itm_node4_fan, "4"))
timer4 = createTimer(now.plusMinutes(60.intValue)) [|
sendCommand(postUpdate(itm_node4_fan, "1"))
Thread::sleep(5000)
sendCommand(postUpdate(itm_node4_fan, "2"))
timer4 = null
]
}
}
end
The trouble is that the rule does get triggered, but only as far as the sendCommand(postUpdate(itm_node4_fan, “4”)) line, it seems the timer never starts up, as the actions within it do not get executed.
Been troubleshooting this for an entire weekend now and thought I’d try the collective intelligence of this board, thoughts?
thanks!