Hello everyone,
I have a problem that is only marginally related to the flex-table. 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,
"id": 2,
"mileage": 447.6,
"speed_average": 23.1711145996861,
"start_at": "Mon, 05 Aug 2024 15:12:40 GMT"
},
{
"altitude_diff": -22,
"consumption": 1.38,
"consumption_km": 12.3214285714285,
"distance": 11.2,
"duration": 18.7333333333333,
"id": 3,
"mileage": 463.1,
"speed_average": 35.8718861209966,
"start_at": "Tue, 06 Aug 2024 05:37:48 GMT"
},
{
"altitude_diff": 31,
"consumption": 2.3,
"consumption_km": 14.7435897435898,
"distance": 15.6,
"duration": 22.7166666666667,
"id": 4,
"mileage": 479.2,
"speed_average": 41.2032281731474,
"start_at": "Tue, 06 Aug 2024 15:18:52 GMT"
}
]
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
. 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
- distance
- duration
- id
- mileage
- speed_average
- start_at
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.
Can someone help me how I can either get the JSON into a property or what I have to adjust so that I can display the trips in a table?
Thank you all very much!
Edit: If someone could try it out and adjust it themselves, that would help me a lot.
The JSON data would be available here: https://my-json-server.typicode.com/tobilektri/hassio-json/corsae