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.