Rule trigger at specific state?

Hello everyone, How can I make my rule only trigger when my door state was changed to CLOSED when it’s a specific time, this is the code i got right now

rule “nightLock”
when
Time cron “0/30 * 19-23 1/1 * ? *” or
Time cron “0/30 * 0-7 1/1 * ? *”
then
ZWaveNode006ID150ZWaveModuleForIDLock150And101_DoorLock.sendCommand(ON)
end

rule “dayLock”
when
Time cron “0 0 11 1/1 * ? *”
then
ZWaveNode006ID150ZWaveModuleForIDLock150And101_DoorLock.sendCommand(OFF)
end

On the night its draining my battery like crazy. and when the door closes and open this comes in the log file,

2020-05-15 16:43:52.293 [vent.ItemStateChangedEvent] - ZWaveNode006ID150ZWaveModuleForIDLock150And101_DoorState changed from CLOSED to OPEN

2020-05-15 16:43:58.566 [vent.ItemStateChangedEvent] - ZWaveNode006ID150ZWaveModuleForIDLock150And101_DoorState changed from OPEN to CLOSED

Is it possible to make it lock when the door state has changed to CLOSE than rather trying to close it every 30sec?:slight_smile:

Yes. What difficulty are you having with doing that?

1 Like

rule “nightLock”
when
Time cron “0/30 * 19-23 1/1 * ? *” or
Time cron “0/30 * 0-7 1/1 * ? *”
then
if (ZWaveNode006ID150ZWaveModuleForIDLock150And101_DoorState changed to CLOSED)
ZWaveNode006ID150ZWaveModuleForIDLock150And101_DoorLock.sendCommand(ON)
end

Tryed this but wont work

Well no, it’s not sensible syntax.
I thought you wanted the rule to run when the door is closed?

rule "nightLock"
when
   Item ZWaveNode006ID150ZWaveModuleForIDLock150And101_DoorState changed to CLOSED

and then maybe check time of day, like here -