Hi,
I am a beginner and am trying to integrate the myStrom Switch into my openhab environment and since I dont want to use a mystrom account I dont use the existing myStrom binding. I want to control the switch “offline” via openhab and additionally want to detect if the user changed the state by manual pressing the button on the device:
To Control the switch there are two easy http-get commands like http://IP/relay?state=1 (or 0). To get the state, the device creates a json file at http://IP/report like:
{
“power”: 28.355360,
“relay”: true
}
Switch control is working:
Switch myStrom "myStrom Steckdose" <poweron> (Switches) { http=">[ON:GET:http://192.168.168.20/relay?state=1] >[OFF:GET:http://192.168.168.20/relay?state=0]" }
Switch state is displayed in a separate “String” item on openhab (which is updated every second)
String myStrom_State "State:[%s]" (Switches) { http="<[http://192.168.168.20/report:1000:JSONPATH($.relay)]" }
But how do I integrate the state into my openhab-switch item? I tried adding
<[http://192.168.168.20/report:1000:JSONPATH($.relay)]
to my switch item but it does not seem to work. I guess I somehow have to transform “true” to ON and “false” to OFF.
I used mqtt bindings before where you can tranform the content of the mqtt package by adding ON:1 or OFF:1 at the end. But this doesnt seem to work either.
<[http://192.168.168.20/report:1000:JSONPATH($.relay):OFF:false]
Do you have any idea what I have to change to get it working?
thx in advance