I’m trying to get a simple exec binding to work to work in OH2. I’ve followed this guide as a basis.
The exec binding runs a bash script that turns ON or OFF a 433mhz mains power switch. The switches work both with the hardware remote and if I run the script manually via SSH.
Here’s my setup.
lights.things
Thing exec:command:PowerSwitch1Switch-control [ command="/usr/local/bin/openhab2/433-3pin-switch-1.sh %2$s", interval=0, autorun=true ]
Thing exec:command:PowerSwitch1Switch-status [ command="/usr/local/bin/openhab2/433-3pin-switch-1.sh status", interval=0, timeout=5 ]
//433Switch2
Thing exec:command:PowerSwitch2Switch-control [ command="/usr/local/bin/openhab2/433-3pin-switch-2.sh %2$s", interval=0, autorun=true ]
Thing exec:command:PowerSwitch2Switch-status [ command="/usr/local/bin/openhab2/433-3pin-switch-2.sh status", interval=0, timeout=5 ]
//433Switch3
Thing exec:command:PowerSwitch3Switch-control [ command="/usr/local/bin/openhab2/433-3pin-switch-3.sh %2$s", interval=0, autorun=true ]
Thing exec:command:PowerSwitch3Switch-status [ command="/usr/local/bin/openhab2/433-3pin-switch-3.sh status", interval=0, timeout=5 ]
//433Switch4
Thing exec:command:PowerSwitch4Switch-control [ command="/usr/local/bin/openhab2/433-3pin-switch-4.sh %2$s", interval=0, autorun=true ]
Thing exec:command:PowerSwitch4Switch-status [ command="/usr/local/bin/openhab2/433-3pin-switch-4.sh status", interval=0, timeout=5 ]
lights.items
Switch PowerSwitch1Switch "Power Switch 1" <poweroutlet> (grp_PowerSwitches) [ "Switchable" ] { channel="exec:command:PowerSwitch1Switch-control:input", channel="exec:command:PowerSwitch1Switch-status:output", autoupdate="true" }
Switch PowerSwitch2Switch "Power Switch 2" <poweroutlet> (grp_PowerSwitches) [ "Switchable" ] { channel="exec:command:PowerSwitch2Switch-control:input", channel="exec:command:PowerSwitch2Switch-status:output", autoupdate="true" }
Switch PowerSwitch3Switch "Power Switch 3" <poweroutlet> (grp_PowerSwitches) [ "Switchable" ] { channel="exec:command:PowerSwitch3Switch-control:input", channel="exec:command:PowerSwitch3Switch-status:output", autoupdate="true" }
Switch PowerSwitch4Switch "Power Switch 4" <poweroutlet> (grp_PowerSwitches) [ "Switchable" ] { channel="exec:command:PowerSwitch4Switch-control:input", channel="exec:command:PowerSwitch4Switch-status:output", autoupdate="true" }
Group grp_PowerSwitches "Power Switches" <poweroutlet>
Switch PowerSwitch1Switch "Power Switch 1" <poweroutlet> (grp_PowerSwitches) [ "Switchable" ] { channel="exec:command:PowerSwitch1Switch-control:input", channel="exec:command:PowerSwitch1Switch-status:output", autoupdate="true" }
Switch PowerSwitch2Switch "Power Switch 2" <poweroutlet> (grp_PowerSwitches) [ "Switchable" ] { channel="exec:command:PowerSwitch2Switch-control:input", channel="exec:command:PowerSwitch2Switch-status:output", autoupdate="true" }
Switch PowerSwitch3Switch "Power Switch 3" <poweroutlet> (grp_PowerSwitches) [ "Switchable" ] { channel="exec:command:PowerSwitch3Switch-control:input", channel="exec:command:PowerSwitch3Switch-status:output", autoupdate="true" }
Switch PowerSwitch4Switch "Power Switch 4" <poweroutlet> (grp_PowerSwitches) [ "Switchable" ] { channel="exec:command:PowerSwitch4Switch-control:input", channel="exec:command:PowerSwitch4Switch-status:output", autoupdate="true" }
.sitemap
sitemap home label="Home Panel" {
Frame label="Power Switches" {
Switch item=PowerSwitch1Switch mappings=[ "ON"="ON", "OFF"="OFF" ]
Switch item=PowerSwitch2Switch mappings=[ "ON"="ON", "OFF"="OFF" ]
Switch item=PowerSwitch3Switch mappings=[ "ON"="ON", "OFF"="OFF" ]
Switch item=PowerSwitch4Switch mappings=[ "ON"="ON", "OFF"="OFF" ]
Switch item=grp_PowerSwitches mappings=[ "ON"="ON", "OFF"="OFF" ]
}
}
.sh
#!/bin/sh
if [ "$1" = "off" ] || [ "$1" = "0" ] || [ "$1" = "OFF" ]; then
/usr/local/bin/433Utils/RPi_utils/codesend 8944270
else
/usr/local/bin/433Utils/RPi_utils/codesend 8944271
fi
I’ve use Karaf console to up the LOG level (via Karaf SSH Console openhab> log:set:INFO followed by log:tail to monitor the output) to INFO but I don’t get any meaningful errors or indications that the script has been executed via the Exec Binding.
Is there any other way to set logging that would detail what’s going wrong?