Problem with rule which is executed within a time period

Hi all,

I would like to get following rule working in OH3, but all I get is an error…
Any idea?

rule "Duschlicht"
when
	Item Bad_Motion changed
then
var Number hour = now.getHour
if ((hour >= 00) && (hour <= 6)) {
	if (Bad_Motion.state == ON) {
		sendCommand(Dusche_Licht_Switch, ON)
		timer = createTimer(now.plusMinutes(2)) [|
        sendCommand (Dusche_Licht_Switch, OFF)	]
     }
	}		
end

Error

2022-01-06 04:04:27.843 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'duschlichtOH3-1' failed: An error occurred during the script execution: Couldn't invoke 'assignValueTo' for feature JvmVoid:  (eProxyURI: duschlichtOH3.rules#|::0.2.0.2.0.1.1.0.0.1.0.1::0::/1) in duschlichtOH3

Try replacing with
Dusche_Licht_Switch.sendCommand(ON)
or
sendCommand(Dusche_Licht_Switch.name, "ON")

The Action sendCommand() works reliably with two strings, but has trouble with some combinations of objects.

That kind of error is often about something not getting as many arguments as it expected, like logInfo(xx), but I can’t see anything like that.
I doubt it is being funny about 00 instead of 0 either.

Add some logging. You’ve only two assignments in that rule (i.e. =). Add some logging to see which of those lines it’s failing on. That might prove informative.

hmm… the error message is still there, but in the events.log I can see it was executed, so its not really clear what failed here.

@rickoshak: please apologise, but I would not know what exactly to log.
what is the right expression?
logInfo(“duschlichtOH3.rules”, ???)


2022-01-07 05:26:45.517 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'duschlichtOH3-1' failed: An error occurred during the script execution: Couldn't invoke 'assignValueTo' for feature JvmVoid:  (eProxyURI: duschlichtOH3.rules#|::0.2.0.2.0.1.1.0.0.1.0.1::0::/1) in duschlichtOH3
2022-01-07 05:26:45.519 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Dusche_Licht_Switch' received command ON
2022-01-07 05:26:45.522 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Dusche_Licht_Switch' predicted to become ON
2022-01-07 05:26:45.525 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Dusche_Licht_Switch' changed from OFF to ON

thx!

It didn’t matter what you log. Just log something. When you see your log statement appear in the logs you know that log statement was executed.

So put one before and after each line with an = and you will know which line the rule fails on

This is what I see in the log. “Motion = ON” and rule works as “NODE 56” becomes “ON”.

I still don´t understand what the error message wants to say…

2022-01-08 02:06:22.946 [DEBUG] [ding.zwave.handler.ZWaveThingHandler] - NODE 57: Updating channel state zwave:device:67a2e0064a:node57:alarm_motion to ON [OnOffType]
2022-01-08 02:06:22.946 [DEBUG] [ternal.converter.ZWaveAlarmConverter] - NODE 57: Alarm converter processing NOTIFICATION
2022-01-08 02:06:22.946 [DEBUG] [ternal.converter.ZWaveAlarmConverter] - NODE 57: Alarm converter NOTIFICATION event is 8, type OnOffType
2022-01-08 02:06:22.947 [DEBUG] [nal.protocol.ZWaveTransactionManager] - NODE 57: Commands processed 1.
2022-01-08 02:06:22.947 [DEBUG] [nal.protocol.ZWaveTransactionManager] - NODE 57: Checking command org.openhab.binding.zwave.internal.protocol.ZWaveCommandClassPayload@577920b6.
2022-01-08 02:06:22.947 [DEBUG] [nal.protocol.ZWaveTransactionManager] - Transaction completed - outstandingTransactions 1
2022-01-08 02:06:22.947 [DEBUG] [nal.protocol.ZWaveTransactionManager] - Transaction completed - outstandingTransactions 1
2022-01-08 02:06:22.947 [DEBUG] [nal.protocol.ZWaveTransactionManager] - ZWaveReceiveThread queue empty
2022-01-08 02:06:22.947 [DEBUG] [nal.protocol.ZWaveTransactionManager] - Transaction SendNextMessage 1 out at start. Holdoff false.
2022-01-08 02:06:22.955 [INFO ] [org.openhab.core.model.script.diag  ] - Rule triggered1
2022-01-08 02:06:22.981 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'duschlichtOH3-1' failed: An error occurred during the script execution: Couldn't invoke 'assignValueTo' for feature JvmVoid:  (eProxyURI: duschlichtOH3.rules#|::0.2.0.2.0.3.1.0.1.1.0.1::0::/1) in duschlichtOH3
2022-01-08 02:06:22.986 [DEBUG] [ding.zwave.handler.ZWaveThingHandler] - NODE 56: Command received zwave:device:67a2e0064a:node56:switch_binary1 --> ON [OnOffType]
2022-01-08 02:06:22.987 [DEBUG] [dclass.ZWaveBinarySwitchCommandClass] - NODE 56: Creating new message for application command SWITCH_BINARY_SET
2022-01-08 02:06:22.987 [DEBUG] [ng.zwave.internal.protocol.ZWaveNode] - NODE 56: Encapsulating message, instance / endpoint 1
2022-01-08 02:06:22.987 [DEBUG] [class.ZWaveMultiInstanceCommandClass] - NODE 56: Creating new message for command MULTI_CHANNEL_ENCAP endpoint 1
2022-01-08 02:06:22.987 [DEBUG] [ng.zwave.internal.protocol.ZWaveNode] - NODE 56: SECURITY NOT required on COMMAND_CLASS_MULTI_CHANNEL
2022-01-08 02:06:22.988 [DEBUG] [ng.zwave.internal.protocol.ZWaveNode] - NODE 56: Command Class COMMAND_CLASS_MULTI_CHANNEL is NOT required to be secured
2022-01-08 02:06:22.988 [DEBUG] [nal.protocol.ZWaveTransactionManager] - NODE 56: Adding to device queue
2022-01-08 02:06:22.988 [DEBUG] [nal.protocol.ZWaveTransactionManager] - NODE 56: Added 147 to queue - size 42

The rule doesn’t care about any zwave or node stuff, it is working from the Item.

Let us know when you’ve added more logInfo to pinpoint the message source.

This is the first or only rule in file duschlichtOH3.rules ?

no, there is no other rule with such name, just this one