Hello everyone,
I have a problem with the RESTful Sensor.
I want to create a table of my car trips with psa_car_controller and flex-table-card. However, I can't get the trips of my car into the home assistant as a table.
Under the URL http://192.168.2.207:5000/vehicles/trips there is a list of all trips. It looks like this, for example:
[
{
"altitude_diff": 0,
"consumption": 1.38,
"consumption_km": 12.5454545454545,
"distance": 11,
"duration": 22,
"id": 1,
"mileage": 431.2,
"speed_average": 30,
"start_at": "Mon, 05 Aug 2024 05:09:43 GMT"
},
{
"altitude_diff": 15,
"consumption": 2.76,
"consumption_km": 16.8292682926829,
"distance": 16.4,
"duration": 42.4666666666667,
....
},
and so on...
]
I would now like to display this data in a table, with time, distance and consumption.
But I can't manage to transfer the data to a sensor using a RESTful sensor.
I have already tried the following:
- platform: rest
name: corsa_e_trips
resource: http://192.168.2.207:5000/vehicles/trips
scan_interval: 60
value_template: "{{ value_json }}"
Then the sensor is unknown. Because of the result length longer than the max 255 chars.
State max length is 255 characters.
The same occours if i use
value_template: "{{ value }}"
What works a little is the following:
- platform: rest
name: corsa_e_trips
resource: http://192.168.2.207:5000/vehicles/trips
scan_interval: 60
value_template: "{{ value_json | length }}"
json_attributes:
- altitude_diff
- consumption
- consumption_km
- id
...
But then I only get the first value in the status attributes, not a list of all values. This of course means that the table-card cannot render a list.