Hi,
I’m using the way to add fuel prices as described here: Benzinpreise in Home Assistant für Österreich - SmartHome yourself
I already see the sensors, but now I want to add them to the UI and set the display name of the sensor from the name attribute from the REST results. I tried to add this in the UI, but I don’t know the syntax for reading the name of the fuel station to put it as name in the display. I tried the following, but it didn’t work:
type: entities
entities:
- entity: sensor.fuel_price_die_1
secondary_info: none
icon: mdi:gas-station-outline
name: '{{state_attr(''sensor.fuel_price_bruck_1'', ''name'')}}'
title: Spritpreise
I solved it using GitHub - thomasloven/lovelace-template-entity-row: Display whatever you want in an entities card row.. With this it is possible to use the attributes of an entity, e.g. like this:
type: entities
title: Spritpreise
entities:
- type: custom:template-entity-row
icon: mdi:gas-station-outline
entity: sensor.fuel_price_bruck_die_1
state: '{{states.sensor.fuel_price_die_1.state_with_unit}}'
name: '{{state_attr(''sensor.fuel_price_die_1'', ''name'')}}'
secondary: >-
{{state_attr('sensor.fuel_price_die_1', 'location')['postalCode']}}
{{state_attr('sensor.fuel_price_die_1', 'location')['city']}},
{{state_attr('sensor.fuel_price_die_1', 'location')['address']|title}}