You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I'm trying to connect to the OpenHAB2 REST API, and apparently the only way to change the ON/OFF state of the switch is to POST the text "ON" or "OFF" into the item's URL (or PUT to the /state).
Example: curl -vk 'http://localhost:8080/rest/items/MySwitch' -H 'Content-Type: text/plain' -d 'ON' curl -vk 'http://localhost:8080/rest/items/MySwitch/state' -X PUT -H 'Content-Type: text/plain' -d 'ON'
This means echo-bridge cannot turn switches on/off through the REST API, as there is no way to put values for different states into content, at least as far I as can tell from the source code. It cannot even be done as easily as the intensity replacement, because the state can be represented by many different values in different target systems (on can be "on", "ON", 1, ... same for off). OpenHAB2 for example accepts for simple switches the values "ON" and "OFF" all upper-case, nothing else.
One solution to this might be changing the whole onUrl/offUrl concept to the more general url+onValue+offValue combination, with possibility to inject the value of current state into both URL and contentBody via a placeholder similar to intensity (something like '${state.value}').
This system should still manage to reproduce current behavior easily - worst case onValue==onUrl, offValue==offUrl, url="${state.value}" if the URLs are really completely different :-)
When I'll have a bit time I might start developing it myself (with a subsequent pull request when I'm done), unless anyone comes with a better idea?
The text was updated successfully, but these errors were encountered:
Hello, I'm trying to connect to the OpenHAB2 REST API, and apparently the only way to change the ON/OFF state of the switch is to POST the text "ON" or "OFF" into the item's URL (or PUT to the /state).
Example:
curl -vk 'http://localhost:8080/rest/items/MySwitch' -H 'Content-Type: text/plain' -d 'ON'
curl -vk 'http://localhost:8080/rest/items/MySwitch/state' -X PUT -H 'Content-Type: text/plain' -d 'ON'
This means echo-bridge cannot turn switches on/off through the REST API, as there is no way to put values for different states into content, at least as far I as can tell from the source code. It cannot even be done as easily as the intensity replacement, because the state can be represented by many different values in different target systems (on can be "on", "ON", 1, ... same for off). OpenHAB2 for example accepts for simple switches the values "ON" and "OFF" all upper-case, nothing else.
One solution to this might be changing the whole onUrl/offUrl concept to the more general url+onValue+offValue combination, with possibility to inject the value of current state into both URL and contentBody via a placeholder similar to intensity (something like '${state.value}').
This system should still manage to reproduce current behavior easily - worst case onValue==onUrl, offValue==offUrl, url="${state.value}" if the URLs are really completely different :-)
When I'll have a bit time I might start developing it myself (with a subsequent pull request when I'm done), unless anyone comes with a better idea?
The text was updated successfully, but these errors were encountered: