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