Hi,
Bear with me - I am at the very start of using openhab2.
I would like to have different results depending on when the Switch (S1) ist pressed.
I have a test rule which fades out the lights slowly, when S1 is pressed.
I use the Scene to tell openhab that S1 was pressed and I let the rule check the dimmer state to know whether the light was turned on or off. Then it fades.
var int percent = 0
var Timer fade_Timer = null
rule "test scene"
when
Item zwave_device_zwave_usb_node4_scene_number received update 16 //or whatever numbers your device is creating
then
if (zwave_device_zwave_usb_node4_switch_dimmer.state==0)
{
logInfo("File", "Bad Licht AN geschaltet")
}
else
{ (zwave_device_zwave_usb_node4_switch_dimmer.state instanceof DecimalType) {
percent = ((zwave_device_zwave_usb_node4_switch_dimmer.state as DecimalType)/5).intValue * 5 //round to 5
fade_Timer = createTimer(now.plusMillis(500)) [|
zwave_device_zwave_usb_node4_switch_dimmer.sendCommand(percent)
if (percent > 0) {
percent = percent - 5
fade_Timer.reschedule(now.plusMillis(500))
}
]
logInfo("File", "Bad Licht AUS geschaltet")
}
}
end
It somewhat works BUT when I press S1 to turn off, the light turns off,immidiately on again and THEN fades out. I guess that is because S1 directly tells the Dimmer2 to switch off and only after that openhab kicks in. Quite a useful behaviour because that way the switch also works when openhab failed or is turned off. But it is not desirable in my case.
So what do I do? Is there some change in the parameter or do I have to use a completely different Actuator?
Thanks for helping me out here.