I’m trying to configure a switch on a Hue behaviour. Reading works, writing does not. I tried the documentation, but even as a software engineer, I do not understand how this is supposed to work.
I simply need it to post {"enabled": true} or {"enabled": false} depending on the switch state. There’s a only a single example in the docs for dynamic urls, but that’s a GET edge case. Can somebody please provide an example on how to work a REST API?
Toggling a switch on this thing leads to an internal object reference to be posted. Is this a bug or a missing configuration? I cannot see which configuration item might produce this.
Requesting 'https://<hidden>/clip/v2/resource/behavior_instance/adc2736e-f3fd-465c-8206-f061ae50115c' (method='PUT', content='org.eclipse.jetty.client.util.StringContentProvider@1acd7f1') failed: 400 Bad Request
IMO this should be done by a proper transformation. If the required format is more complex than the one presented above, it’s not so easy to put it in one input field.
Thanks. So the stateContent is only used to build a request body in the Pull-Case, but commandTransformation forms the body in the reverse direction.
I put in a jinja transformation JINJA:{"enabled": {{value}} }. This works for my case.
The Jinja transformation has value_json for json-structured values. Leaves the question how more complex states would be represented (e.g. brightness, color) towards the transformation plugin.
This part should be documented both better and with a more complex example.
Just a warning. The OpenHab Jinja transformation “JinJava” seems to be very limited, if not crippled. Most functions or even string formatting doesn’t work. So while Jinja would be a good and powerful tool for this kind of problem, the Jinja transformation seems not to be.
The Javascript transformation is working for other cases but you have to create a file per snippet and plain Javascript is very inefficient to write.
I have a need to POST a string from a String Item, but embedded within some JSON. I’m currently doing this with a proxy Item and a rule, but am looking to get rid of these extras. This JINJA transformation might be what I need, so thanks for sharing!
I’m trying to avoid JS transformation as you can’t define this within the UI, as you say.
EDIT: Well, that worked a treat! Thanks again for sharing this - I’ve put in a PR to the JINJA documentation to give an outgoing transformation example.
I ma using openhab since more than a yer now, and i would be interested in this type of command sending (i acquired a oekofen boiler, which is working through json api). Could you post the JINJA path you used for this “complex” elgato thing ?