I sort of got it to turn on and off now. But i am still at a complete loss how I am supposed to marry status check with this switch object. Here is a working config i have now for the TPLink hs200:
Things file:
Thing exec:command:pluglight [command=“/opt/openhab2/conf/scripts/hs100.sh 192.168.10.42 9999 %2$s”, interval=0, timeout=5, autorun=true]
Thing exec:command:pluglightcheck [command=“/opt/openhab2/conf/scripts/hs100.sh 192.168.10.42 9999 check”, interval=1, timeout=5]
Items:
String PlugOne “Lamp One” {channel=“exec:command:pluglight:input”}
Sitemap:
Switch item=PlugOne mappings=[“on”=“on”,“off”=“off”]
So all this above allows to go into basicUI, find ‘Lamp One’ in there and toggle it off and on and it turns off an on fine, very good. Half way there.
Now, what should be done to update status of ‘Lamp One’ in the interface using this other thing ‘exec:command:pluglightcheck’ when lamp switch is flipped by hand?
OK, i solved that too.
items:
String PlugOne “Lamp One” {channel=“exec:command:pluglight:input”}
String PlugOneState “Plug One Status” {channel=“exec:command:pluglightcheck:output”}
things:
Thing exec:command:pluglight [command=“/opt/openhab2/conf/scripts/hs100.sh 192.168.10.42 9999 %2$s”, interval=0, timeout=5, autorun=true]
Thing exec:command:pluglightcheck [command=“/opt/openhab2/conf/scripts/hs100.sh 192.168.10.42 9999 check”, interval=1, timeout=5]
sitemap:
Switch item=PlugOne mappings=[“ON”=“ON”,“OFF”=“OFF”]
//Text item=PlugOneState label=“Plug One State [%s]”
rule:
rule “Plug One”
when
Item PlugOneState changed from ON to OFF
then
postUpdate(PlugOne,“OFF”)
logInfo(“Network”, "Switching Plug Off: " )
end
rule “Plug Two”
when
Item PlugOneState changed from OFF to ON
then
postUpdate(PlugOne,“ON”)
logInfo(“Network”, "Switched Plug On: " )
end
This way it flips PlugOne in the sitemap according to the status. All works, switch switches, all good.