Hi eveyrone - I have been working hard on importing fuel data into HA to let us know where to stop and fill up when going to work. I have a number of local service stations with a price being captured. I created a template for a new sensor which simply shows the cheapest one form the list. It works perfectly. I was adding in the last sensor though and because the API imports the names the service station starts with a 7 as in states.sensor.7_eleven_kingswood_p95. If you take this out the template works, as soon as you put it in the configuration fails. Does anyone know how to restructure this into working code. I have tried various other published formats but it doesn’t seem to be working.
- platform: template
sensors:
lowest_entity:
friendly_name: "Cheapest Unleaded Petrol"
value_template: >-
{% set entities = [
states.sensor.ampol_cambridge_park_p95,
states.sensor.ampol_eastern_creek_eastbound_p95,
states.sensor.ampol_foodary_werrington_p95,
states.sensor.bp_werrington_p95,
states.sensor.eg_ampol_kingswood_p95,
states.sensor.7_eleven_kingswood_p95
] %}
{% set lowest_entity = entities | min(attribute="state") %}
{{ lowest_entity.attributes.friendly_name }}: {{ lowest_entity.state }}