This is an important binding, thanks @J-N-K for the effort! I made a OH3 build of the current version, for those interested.
I tried it because I need to query some Yamaha devices with an JSON/RPC API, currently I use rules to do the polling and send commands, which works fine, but doing it with a proper binding instead of triggering a rule every 5 seconds is far better.
For example I can retrieve the volume in the response to /main/getStatus
which looks like this:
$ http http://192.168.1.xxx/YamahaExtendedControl/v1/main/getStatus
HTTP/1.1 200 OK
Content-Length: 473
Content-Type: application/json
Server: Network_Module/1.0 (RX-V479)
{
"actual_volume": {
"mode": "db",
"unit": "dB",
"value": -47.0
},
"contents_display": true,
"direct": false,
"disable_flags": 0,
"distribution_enable": true,
"enhancer": true,
"input": "spotify",
"link_audio_delay": "audio_sync",
"link_audio_quality": "uncompressed",
"link_control": "standard",
"max_volume": 161,
"mute": false,
"power": "on",
"response_code": 0,
"sleep": 0,
"sound_program": "5ch_stereo",
"surr_decoder_type": "dolby_pl2x_music",
"tone_control": {
"bass": 0,
"mode": "manual",
"treble": 0
},
"volume": 67
}
but to update the volume I need to do a GET (for some reason?) like /main/setVolume?volume=67
So I found the Command method advanced parameter of the Thing which I changed to GET (and reduced the polling to every 5 seconds):
And created a Number channel (read only) with the
JSONPATH:$.volume
transformation:
I then created & linked an item to verify the volume was properly retrieved and parsed into the item’s state:
Next I wanted the same item to also control the volume when receiving commands, so I created a second write-only channel. Oddly enough I made a mistake and set the “State URL Extension” instead of “Command URL Extension” to
/main/setVolume?volume=%2$d
but it still worked:
Then I linked the same item to that channel (you can do that in a number of ways, from the Thing page, the Model page, or the item details page):
I saw
@mstormi’s solution which is better only after doing that - a single channel would have sufficed!
Finally since this Number item is controllable I set the “Default Standalone Widget” metadata to override the default which is a simple label card for this type of items, selected “Slider Card”, and changed some options.
Now the item represents the current volume in a slider with its default control, and operating that slider changes the volume as expected. Great!
Next I saw there’s support for Image items, which is great for cameras and album art, so I’ll try to retrieve it and see how it works (there is no support for images in the OH3 UI yet btw, it’s probably time to add it).
Hope that helps.