Json or Xpath expression to extract volume value


I've managed to find all the Json commands I need to get my Kodi (Wetek Play) box to work, including the queries for volume and track titles etc

This command

http://openelec/jsonrpc?request={"jsonrpc": "2.0", "method": "Application.GetProperties", "params": {"properties": ["volume"]}, "id": 1}

Returns this data


So my question today is...

What do I need to enter in the Xpath of Json Expression sections of the OpenRemote command to pass just the volume value to a sensor?



I'll post all of the Json commands I've got working if anyone wants them.

Including how the all important "Radio & TV channel list" one :wink:

Using this website


And this query


I got this result


Would this be the same as OpenRemote would get with this query?
(Which I assume wouldn't work with the level sensor)

try $.result.volume

Using the same website and this Json query

{"id":"AudioGetItem","jsonrpc":"2.0","result":{"item":{"album":"","artist":["BBC Radio 4 Ex"],"duration":4200,"fanart":"","id":21,"label":"BBC Radio 4 Ex","thumbnail":"","title":"What Happened, Miss Simone?","type":"channel"}}}

This query


The output is

["What Happened, Miss Simone?"]

So I guess I'm looking for a way to strip out the [] and "" parts.

Any help would be very welcome.

Hi Michal,

Thanks for the input :slight_smile:

Can I check something with you....

I seem to remember you saying previously that the HTTP command isn't great at handling multiple tags.

So is the following possible?

Can the full text from a http / Json query be pushed into a custom sensor, so that a rule could strip out the various elements and push them into different in-memory commands ?

For example, the Audio status query from Kodi returns things like this :-

{"id":"AudioGetItem","jsonrpc":"2.0","result":{"item":{"album":"","artist":[],"duration":0,"fanart":"","file":"http://radio.virginradio.co.uk/stream","label":"Now Playing: Take Your Mama - Scissor Sisters","thumbnail":"","title":"Now Playing: Take Your Mama - Scissor Sisters","type":"song"}}}

Can a rule strip out the :

thumbnail URL - for use in a webview
fanart URL - for use in a Webview

label, title, artist & album - for use in UI labels?

Or am I looking at this the wrong way?

Sure you can. I'm doing this all the time, especially when a protocol is a bit more complicated - think about OAuth2, more than a single param, dynamic query, etc. I was even able to implement non trivial Smappee cloud protocol purely by rules. Didn't used even the HTTP protocol but shell exec with curl. You can look at these rules in wiki under Smappee integration.