Hi
I have been struggling for a few hours now and can’t seem to get my REST Sensor JSON parsing to work could someone please help?
this is my JSON response
[
{
"id":4442,
"name":"Test API",
"macaddress":"f8:f0:05:e5:1b:1a",
"xpercent":56.432434,
"ypercent":96.63537,
"inuse":false,
"standby":false,
"faulty":false,
"registered":true,
"lastocc":1527105145,
"lastonl":1527348011,
"hidden":false
}
]
I would just like to get the following out of it.
id :
name :
macaddress :
inuse :
I think the cause of my problem is the square bracket “[” but I’m not sure.
I have tried the following with no success
value_template: ‘{{ value_json.state.id }}’
this results in a blank sensor
here is the error in the log
Error parsing value: ‘list object’ has no attribute ‘state’ (value: [{“id”:4442,“name”:“Test API”,“macaddress”:“f8:f0:05:e5:1b:1a”,“xpercent”:56.432434,“ypercent”:96.63537,“inuse”:false,“standby”:false,“faulty”:false,“registered”:true,“lastocc”:1527105145,“lastonl”:1527362645,“hidden”:false}], template: ‘{{ value_json.state.id }}’)
any ideas?
thank you