I’m trying to load data from an CSV feed into a sensor. I’m only interested in the latest record. I am using a Restful Sensor and I am already at the point where I have the data in my hands thanks to the value_template attribute. What I want to do now is to map these variables to the attributes of the sensor so that I can use them else there like:
state_attr('sensor.csv', 'some_attribute')
But I don’t know if this is at all possible since I am only thus far that I can set the value of the sensor, but whatever I do, I don’t seem to be able to set the attributes.
I don’t understand what you mean. value_json is a variable used in value_template to access the received JSON-formatted data. The received data must already be in JSON-format in order to use value_json.
I thought that perhaps I could get it to work by setting value_json from within value_template but that does not work. Just letting you know what I have tried.
The variable called value is used within a value_template to access the received data. It’s normally used when the data is not in JSON format. If the data is in JSON format (specifically a dictionary, where the data is structured in key-value pairs) then you can use value_json to access each key’s value.
Using the previous example, is this is the received data: