Hey Guys,
I’m trying to create a sensor with the rest platform to call an API (grocy)
This API returns a JSON array (at the moment with to record set a 0 & 1
In the value_template I can extract picking either [1] or [0], I’m trying to do the same in the json_attributes for then later to create sensors with the platform template to make only one API call.
Logger: homeassistant.components.rest.sensor
Source: components/rest/sensor.py:251
Integration: rest (documentation, issues)
First occurred: 15:32:46 (2 occurrences)
Last logged: 15:33:18
JSON result was not a dictionary or list with 0th element a dictionary
I believe @natureboss89’s issue is that he’s using 0.xyz as the json_attributes attribute name. If he just moved the 0 and the 1 into the json_attributes_path selector, it should work.
Hi ,
I think I have a possilbe solution, I shared the same in an other post but this one I think is also about the exact same case and was not resolved…
I faced same issue by getting all google calendar of current day which come as a json array and store them in a sensor (by default only next callendar event is stored in the calendar attribute…)
I did fix it by using command line sensor to get the json array in a json with one direct attribute.
This way it is possible to have in json_attributes one attribute which contain all the array and can be used for later porcessing by any sensor or automation.
In value_template I store the number of entries in the array