Getting json data in a sensor

Ok, not totally new with HA but pulling my hairs out to get the following to work:

When I open the following link in my browser:{“jsonrpc”: “2.0”, “id”: 1, “method”: “Player.GetItem”, “params”: {“properties”: [“file”], “playerid”: 1}}

I’m getting:

{“id”:1,“jsonrpc”:“2.0”,“result”:{“item”:{“file”:“smb://PC/Movies/Moviename (year)/Moviename (year) 1080p DTSHD-MA 235.mkv”,“id”:6612,“label”:“Moviename”,“type”:“movie”}}}

How do I get the “file” value into a sensor.
I know I probably have to use “Rest” and a template but I am searching already for a while and not getting it done. If somebody could help I would be very happy.

Probably something like this:

  - platform: rest
    name: media file
      request: '{"jsonrpc": "2.0", "id": 1, "method": "Player.GetItem", "params": {"properties": ["file"], "playerid": 1}}'
    value_template: '{{ value_json.result.item.file }}'

Also, please use the correct formatting next time you post code or json. See point 11 here. The double quotes got messed up in your previous post.

1 Like

Thanks a lot, will try it in the weekend. Excuses for the not proper formatting, will keep that in mind for the next time.

After updating to Core 2023.1.6 my sensor stopped working:

With my limited knowledge I’m trying to solve it and put the Yaml code into a different format and made this:

  - authentication: basic
    username: "xxxx"
    password: "xxxx"  
    payload: '{"jsonrpc": "2.0", "id": 1, "method": "Player.GetItem", "params": {"properties": ["file"], "playerid": 1}}'
      - name: CeBios now playing
        value_template: '{{ value_json.result.item.file }}'

But that is throwing me an error, any help would be appreciated.

Update: Not needed anymore, original method will be fixed in upcoming release: