weado
January 8, 2022, 4:14pm
1
Hello,
I created a website with a Json with 0 result or 1, 2 or 3 value. I found a solution if I have 1 value, but how can I do if 2 or 3 different values like that :
[{"name":"name1","price1":4,"price2":3.09},{"name":"name2","price1":29,"price2":28.5}]
or sometime just one or zero :
[{"name":"name1","price1":4,"price2":3.09}]
When I use this sensor, HA found just one of two :
- platform: rest
resource: https://xxx.com/ha.php
name: website_json
scan_interval: 30
json_attributes:
- price1
- price2
value_template: '{{ value_json.name }}'
Thanks a lot for your help
FPro
(Florian)
January 8, 2022, 4:26pm
2
Consider that you are working with a list and not just a map.
See a code example in another project I made:
Recently I did some digging how to incorporate Austrian fuel prices into HA. Since there might be others interested in this topic I decided to share my findings.
Where to get the data
Every site that you can check fuel prices on (like ÖAMTC, ARBÖ,…) bases its data on those by Spritpreisrechner.at . You can query this data via the E-Control Sprit API.
The first step is to go to the API documentation and build yourself a request URL. You can either do that by region (Bezirk or Bundesland) or by …