I’ve been using Home Assistant for some time now.
Until now I was always able to help myself - also thanks to the community - and up to now I have managed all desired automations on my own.
Until now
With the help of the “RESTful Sensor” I try to read out an API of the German electricity provider “Awattar” and make it available as a sensor in HomeAsisstant.
This doesn’t really work.
Output Awattar-Json-API:
{
“object”: “list”,
“data”: [
{
“start_timestamp”: 1559116800000,
“end_timestamp”: 1559120400000,
“marketprice”: 46.41,
“unit”: “Eur/MWh”
},
{
“start_timestamp”: 1559120400000,
“end_timestamp”: 1559124000000,
“marketprice”: 45,
“unit”: “Eur/MWh”
},
{
“start_timestamp”: 1559124000000,
“end_timestamp”: 1559127600000,
“marketprice”: 40.89,
“unit”: “Eur/MWh”
},
{
“start_timestamp”: 1559127600000,
“end_timestamp”: 1559131200000,
“marketprice”: 39.9,
“unit”: “Eur/MWh”
},
{
“start_timestamp”: 1559131200000,
“end_timestamp”: 1559134800000,
“marketprice”: 39.92,
“unit”: “Eur/MWh”
},
{
“start_timestamp”: 1559134800000,
“end_timestamp”: 1559138400000,
“marketprice”: 38.29,
“unit”: “Eur/MWh”
},
{
“start_timestamp”: 1559138400000,
“end_timestamp”: 1559142000000,
“marketprice”: 40.53,
“unit”: “Eur/MWh”
},
{
“start_timestamp”: 1559142000000,
“end_timestamp”: 1559145600000,
“marketprice”: 45.52,
“unit”: “Eur/MWh”
},
{
“start_timestamp”: 1559145600000,
“end_timestamp”: 1559149200000,
“marketprice”: 50.27,
“unit”: “Eur/MWh”
},
{
“start_timestamp”: 1559149200000,
“end_timestamp”: 1559152800000,
“marketprice”: 53.43,
“unit”: “Eur/MWh”
},
{
“start_timestamp”: 1559152800000,
“end_timestamp”: 1559156400000,
“marketprice”: 53.92,
“unit”: “Eur/MWh”
},
{
“start_timestamp”: 1559156400000,
“end_timestamp”: 1559160000000,
“marketprice”: 47.76,
“unit”: “Eur/MWh”
},
{
“start_timestamp”: 1559160000000,
“end_timestamp”: 1559163600000,
“marketprice”: 40.77,
“unit”: “Eur/MWh”
},
{
“start_timestamp”: 1559163600000,
“end_timestamp”: 1559167200000,
“marketprice”: 34.55,
“unit”: “Eur/MWh”
}
],
“url”: “/de/v1/marketdata”
}
Target:
I would like to create a sensor (time series) that provides me with the current price for the current hour.
Time of Day: XX.XX Eur/MWh
Previous approach:
sensor:
- platform: rest
resource: https://api.awattar.de/v1/marketdata
name: Test
value_template: ‘{{ value_json.data[0] }}’
This creates a sensor with these values as the status of the sensor:
"start_timestamp": 1559120400000,
"end_timestamp": 1559124000000,
"marketprice": 45,
"unit": "Eur/MWh"
How do I get the individual points in time into a sensor?
Unfortunately that was it.
I really don’t have any experience in querying an API interface and am therefore grateful for any help.