rule "Put KDS into Standby"
when
Item KDS_Power received command
then
val new_state = 'Action Preamp/Product 2 SetStandby "' + if (KDS_Power.state == ON) '0"' else '1"'
logInfo("Linn", "State=" + new_state)
KDS_Command.postUpdate(new_state)
end
rule "Put KDS into Standby"
when
System started
then
val new_state = 'Action Preamp/Product 2 SetStandby "' + if (Virtual_Switch_1.state == ON) '0"' else '1"'
logWarn("Rules", new_state)
Virtual_String_1.postUpdate(new_state)
end
13:34:01.442 [WARN ] [clipse.smarthome.io.net.exec.ExecUtil] - Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "sudo /etc/openhab2/scripts/linn.sh" (in directory "."): error=2, No such file or directory)
The file is there as being executable.
13:34:01.136 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'KDS_Power' received command ON
13:34:01.150 [INFO ] [smarthome.event.ItemStateChangedEvent] - KDS_Power changed from NULL to ON
13:34:01.391 [INFO ] [smarthome.event.ItemStateChangedEvent] - KDS_Command changed from NULL to Action Preamp/Product 2 SetStandby "0"
I have no idea what that means . What’s in the script? Maybe add some logging to it? Or just comment out everything but a simple log to make sure that the rule runs OK.
14:47:11.461 [WARN ] [clipse.smarthome.io.net.exec.ExecUtil] - Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "sudo -u openhab /etc/openhab2/scripts/linn.sh" (in directory "."): error=2, No such file or directory)
14:47:11.462 [INFO ] [g.eclipse.smarthome.model.script.linn] - results:
rule "Put KDS into Standby"
when
Item KDS_Power received command
then
val new_state = 'Action Preamp/Product 2 SetStandby "' + if (receivedCommand == ON) '0"' else '1"'
logInfo("Linn", new_state)
KDS_Command.postUpdate(new_state)
val result = executeCommandLine("/etc/openhab2/scripts/linn.sh@@" + new_state, 5000)
logInfo("Linn", "result: {}", result)
end
I’ve put the script back to this and it works this is awesome! So why the change, what is it about the previous rule it didnt like?
Only issue is, it seems to only work once. Ie turns on/off, then wont go back on again. This might be because the unit can only accept 4 connections, if they are left open, it wont close them. So i think i need an ability for the script to disconnect (Control Z after it executes the command)
There were lots of changes from your original rule, but the last change was to remove the sudo. The openhab account had permissions to read and execute the script, so it wasn’t needed.
Before the DLNA binding, and even still now for some proprietary UPnP commands for my speakers, I use curl (and Jython)…