Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support command value in content-body #108

Open
relghuar opened this issue Sep 14, 2018 · 0 comments
Open

Support command value in content-body #108

relghuar opened this issue Sep 14, 2018 · 0 comments

Comments

@relghuar
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant