Hi,
I admit I’m having an hard time trying to use templates…
I’m trying to display in a card the JSON from the bus stop arrivals data.
The url is something like “http://www.mysite.com/data.php?stop=$number”, where $number is the code for the bus stop.
The json produced by the query is something like this:
[{"line":"18","hour":"15:01","realtime":"true"},{"line":"18","hour":"15:08","realtime":"true"},{"line":"18","hour":"15:15","realtime":"true"},{"line":"49","hour":"15:18","realtime":"true"},{"line":"49","hour":"15:29","realtime":"true"},{"line":"49","hour":"15:44","realtime":"true"}]
I created a test sensor with a fixed bus stop:
- platform: rest
name: Arrivals
scan_interval: '00:30'
resource: 'http://www.mysite.com/data.php?stop=755'
value_template: '{{ value_json.line }}'
json_attributes:
- line
- hour
- realtime
After I have used a sensor card in lovelace to display the data:
type: sensor
entity: sensor.arrivals
First question: I don’t see any data but a graph bar in the sensor card, I need to click the bar to see the data, how can I display directly the “line”, “hour” and “realtime” values?
Second question: with my “template” I only see the first set of values, but the JSON contains more: how can I iterate through all the data and display all values?
Third question: is there any way to interactively change the $number value which gets passed to the url to generate the JSON?