flash3d
December 16, 2021, 6:36pm
1
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:
http://192.168.1.100:8080/jsonrpc?request= {“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:
sensor:
- platform: rest
name: media file
resource: http://192.168.1.100:8080/jsonrpc
params:
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
flash3d
December 16, 2021, 10:12pm
3
Thanks a lot, will try it in the weekend. Excuses for the not proper formatting, will keep that in mind for the next time.
flash3d
January 22, 2023, 10:36am
4
After updating to Core 2023.1.6 my sensor stopped working: https://community.home-assistant.io/t/rest-sensor-no-longing-loading/515700
With my limited knowledge I’m trying to solve it and put the Yaml code into a different format and made this:
rest:
- authentication: basic
username: "xxxx"
password: "xxxx"
resource: http://xxx.xxx.x.xxx:8080/jsonrpc
payload: '{"jsonrpc": "2.0", "id": 1, "method": "Player.GetItem", "params": {"properties": ["file"], "playerid": 1}}'
sensor:
- 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: https://github.com/home-assistant/core/issues/86346