I’m trying to monitor my Plex server with some rest sensors. I created a new sensor which connects but I get the attributes back prefixed with @ and can’t seem to get the one value I want into the state attribute. Can anyone advise where I am going wrong/what to try?
- platform: rest
name: Plex Unmatched Episodes
resource: http://192.168.0.100:32400/library/collections/14152
headers:
User-Agent: Home Assistant
Content-Type: 'application/json; charset=utf-8'
params:
X-Plex-Token: !secret plex_token
scan_interval: 600
json_attributes_path: '$.MediaContainer.Directory'
json_attributes:
- "@childCount"
- "@title"
- "@updatedAt"
value_template: '{{ value_json["MediaContainer"]["Metadata"][0]["childCount"] }}'
The JSON response is like this:
{
"MediaContainer": {
"size": 1,
"allowSync": true,
"identifier": "com.plexapp.plugins.library",
"librarySectionID": 1,
"librarySectionTitle": "TV Shows",
"librarySectionUUID": "a7c63d78-7147-4232-9493-fb02a6a12b4a",
"mediaTagPrefix": "/system/bundle/media/flags/",
"mediaTagVersion": 1679942722,
"Metadata": [
{
"ratingKey": "14152",
"key": "/library/collections/14152/children",
"guid": "collection://b5cb1bf2-78b1-4d41-aebc-f82e6563a15c",
"type": "collection",
"title": "TV Unmatched Episodes",
"librarySectionTitle": "TV Shows",
"librarySectionID": 1,
"librarySectionKey": "/library/sections/1",
"subtype": "episode",
"summary": "",
"index": 74443,
"content": "server://1ac33273264ae8842db17ca1ee54819/com.plexapp.plugins.library/library/sections/1/all?type=4&episode.unmatched=1",
"ratingCount": 104,
"thumb": "/library/collections/14152/composite/160433556?width=400&height=600",
"addedAt": 1668439156,
"updatedAt": 1680433556,
"childCount": "0",
"smart": "1"
}
]
}
}