This a weird problem that I can’t figure out. My simple config is:
Thing exec:command:monitor [command="/packages/OpenHAB/scripts/monitor.sh %2$s", interval=0, timeout=30, autorun=true]
Switch Monitor_Run { channel="exec:command:monitor:run" }
String Monitor { channel="exec:command:monitor:input" }
Switch Test
rule "Test"
when
Item Test received command
then
Monitor.sendCommand(receivedCommand)
end
If I send ON to the item Monitor via curl it works fine:
13:25:19.966 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Monitor' received command ON
13:25:19.995 [INFO ] [smarthome.event.ItemStateChangedEvent] - Monitor changed from OFF to ON
13:25:20.030 [INFO ] [smarthome.event.ItemStateChangedEvent] - Monitor_Run changed from OFF to ON
13:25:20.049 [INFO ] [smarthome.event.ItemStateChangedEvent] - Monitor_Run changed from ON to OFF
If I send ON to the item Test the Monitor item gets updated to it but the autorun (& hence the script) doesn’t fire:
13:25:33.721 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Test' received command ON
13:25:33.750 [INFO ] [smarthome.event.ItemStateChangedEvent] - Test changed from OFF to ON
13:25:33.772 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Monitor' received command ON
No, it needs to be the input item to set the ON or OFF argument for the %2$s in the run item. Also, as I mentioned sending ON/OFF directly to the Monitor item via curl works fine and triggers the Monitor_Run item via autorun.
The problem here is the parser (interpreter of the rules language). In your case it has not enough information about what to pass in the sendCommand as an argument. To force the issue, because sendCommand always accepts a string, you need to apply the .toString method to clarify the instruction for the parser.