Newly migrated from OH1 to OH2 and still working out all the differences. Question I came across - is it not OK/Possible/Proper to have multiple Things in a single file like so?
exec.things
Thing exec:command:outlet-power [
command="/home/pi/python_scripts/automation/v2/codesend %2$s",
interval=0,
autorun=true]
Thing exec:command:zigbee-bulb-power [
command="/home/pi/oh_custom_scripts/wink-as-pi.sh %2$s",
interval=0,
autorun=true]
I have 2 separate items files for the 2 different commands:
zigbee_bulbs.items
Switch zigbee_bulb_Lydias_lamp <lightbulb>
Switch zigbee_bulb_desk_lamp <lightbulb>
Switch Outlet_Power { channel="exec:command:zigbee-bulb-power:run" }
String Outlet_Power_Args { channel="exec:command:zigbee-bulb-power:input" }
String Outlet_Power_Out { channel="exec:command:zigbee-bulb-power:output" }
And rf_outlets.items
Switch rf_plug_LR_lamp <poweroutlet>
Switch Outlet_Power { channel="exec:command:outlet-power:run" }
String Outlet_Power_Args { channel="exec:command:outlet-power:input" }
String Outlet_Power_Out { channel="exec:command:outlet-power:output" }
rf_outlets.rules (will be changing the name of this to something that makes more sense later)
rule "Living Room Lamp"
when
Item rf_plug_LR_lamp received command
then
// wait for transmitter to be free
// state will be NULL if not used before or ON while command is executed
while(Outlet_Power.state == ON){
Thread::sleep(500)
}
if(receivedCommand == ON){
Outlet_Power_Args.sendCommand("5330371")
} else {
Outlet_Power_Args.sendCommand("5330380")
}
// wait for the command to complete
while(Outlet_Power.state != OFF){
Thread::sleep(500)
}
logInfo("RF Outlets","Result:" + Outlet_Power_Out.state)
end
rule "Lydias Lamp"
when
Item zigbee_bulb_Lydias_lamp received command
then
// wait for transmitter to be free
// state will be NULL if not used before or ON while command is executed
while(Outlet_Power.state == ON){
Thread::sleep(500)
}
if(receivedCommand == ON){
Outlet_Power_Args.sendCommand("-m 1 -u -t 1 -v ON")
} else {
Outlet_Power_Args.sendCommand("-m 1 -u -t 1 -v OFF")
}
// wait for the command to complete
while(Outlet_Power.state != OFF){
Thread::sleep(500)
}
logInfo("Zigbee Bulbs Lydias Lamp","Result:" + Outlet_Power_Out.state)
end
rule "Desk Lamp"
when
Item zigbee_bulb_desk_lamp received command
then
// wait for transmitter to be free
// state will be NULL if not used before or ON while command is executed
while(Outlet_Power.state == ON){
Thread::sleep(500)
}
if(receivedCommand == ON){
Outlet_Power_Args.sendCommand("-m 9 -u -t 1 -v ON")
} else {
Outlet_Power_Args.sendCommand("-m 9 -u -t 1 -v OFF")
}
// wait for the command to complete
while(Outlet_Power.state != OFF){
Thread::sleep(500)
}
logInfo("Zigbee Bulb Desk Lamp","Result:" + Outlet_Power_Out.state)
end
Essentially, when I flip the switch, BOTH of the commands in the Things file fire with the parameters of the specific item that was invoked. So, I get a successful action and the other one, of course fails with errors. This happens both ways and I am not sure where the issue is. The logs are quite long so I won’t post them here, so hopefully what I am saying makes sense.