value_template: >-
{% if is_state_attr('sensor.karionggosford', 'due', 'n/a') %}
No schedule found
{% else %}
{{ states.sensor.karionggosford.attributes.route }} in {{ states.sensor.karionggosford.attributes.due }}m ({{ states.sensor.karionggosford.attributes.delay }}m delay)
{% endif %}
Just added mine… I think my first suggestion isn’t right. The template editor in dev-tools works like mad in troubleshooting this stuff. If you go into states you will see all the key names for the sensor and then you can work it out from that normally.
The sensor returns some nested JSON and the only way I can find to read it is the way I am doing it now (as documented in the docs for the component) or by this
which works but still throws an error if next_trains[x] doesn’t exist. (also it’s a bugger to test as I can’t see a way to do it in the template tool!)
In my opinion this is a flaw in HA to not be able pre-empt this error. I think I’ll probably start a new thread. Maybe there is a way that I don’t know about?