Parse CSV returned from REST

Hi guys,

I’m trying to set up a sensor to extract data from PVoutput which isn’t returned by the built in component.
I’ve been messing with a Rest sensor but cant import the data in a useable format. The raw data returned by the Get request is as comma separated values. Example :


If I set the value_template to value_json, the sensor state is unknown and no json is added to the sensor attributes.
If I set the value_template to value, the sensor STATE becomes the string of CSV, and I’m still unsure of how to parse it.
I’m particularly after the last two values.

Any pointers would be greatly appreciated.

Some nice example for the Templates Tool.

{% set value = '3217521,2827732,35357,8479,51668,4.677,91,20180822,20181120,6.834,20181108,1674386,111904,1056049,118644,0,18399,7201,41663,363.68,437.60' %}
{{ value.split(',')[-1] }}

Returns the last value.

{{ value.split(',')[-2] }}

the one before.


You my friend are a magician !

Thankyou, you’ve saved whats left of my hair :slight_smile:

This is awesome. Was just working out how to get some more values from PVOutput as my system doesn’t have them. I was doing ok until I got the result and found out that the rest sensor didn’t like it too much.


It really helped to me! And it is not the first time with one of your post :slight_smile: