#Attribute as Tile Title

1 messages · Page 1 of 1 (latest)

delicate crater
#

I have a warnings sensor by my local weather service. It comes with a bunch of attributes as title, description, issuer, etc.
Is there the ability to set the tile card title to an entity attribute value?

wanton zodiac
#

If you mean the attribute instead of the "Warnung" title, I don't think that's possible. But you could give it a single space as a custom name in the card - that way the title would disappear, but the other test would not become bold.

#

You could create a template (binary) sensor with a dynamic templated friendly name attribute, the desired entity name as unique_id and no name value declared. 🤔

#

I opted for a binary sensor with a text attribute of the general highest warning level (e.g. Amtliche Warnung vor markantem Wetter) and a markdown card for full size presentation.

delicate crater
#

That does not work, it's still not readable. Basically I would like the headline attribute to be the title and the description attribute to be displayed below.

wanton zodiac
#

That would work with a seperate template entity with a dynamic friendly name.

delicate crater
#

Ok, I’ll have a look at that idea.

wanton zodiac
#

I did that with Tankerkönig gas price stuff. A sensor showing the nearest and cheapest gas station nearby. Its friendly name changes to the station name on each change.

delicate crater
#

Would you mind to share this?

#

I'm not that good at templating...

wanton zodiac
#

I can, but the templates themselves are for another integration.

delicate crater
#

Ok, I got a sensor now, with a custom friendly name. But seems that I cannot set attributes via the ui

#

looks a bit odd 😉

wanton zodiac
#

Do not set a name for the sensor, but a meaningful unique_id only. For example:

template:
  - sensor:
    - unique_id: wetterwarnung
      state: "{{ whatever template }}"
      attributes:
        friendly_name: "{{ name template }}"
#

What do you mean by set attributes via UI?

delicate crater
#

I used the template helper UI

#

But probably using yml is easier..

wanton zodiac
#

That only works in yaml.

delicate crater
#

Ok, thanks!

wanton zodiac
#

As I said, I only use a template binary sensor for basic warning info and a markdown card for all available weather warnings.

#

The end product looks like this

#

If additional warnings are available, they will be added to the markdown card automatically - a list of all warnings.

#

Older version with a list.

wanton zodiac
wanton zodiac
#

Oh... and you would have to place a DWD icon in /www/images/dwd.png or change that part. 😅

delicate crater
#

So it seems to work a:

- sensor:
  - unique_id: warnung_1
    icon: mdi:alert-circle
    state: "{{ states.binary_sensor.warning_hamburg_freie_und_hansestadt_1.attributes.description if state_attr('binary_sensor.warning_hamburg_freie_und_hansestadt_1', 'description') != none }}"
    attributes:
      friendly_name: "{{ states.binary_sensor.warning_hamburg_freie_und_hansestadt_1.attributes.headline if state_attr('binary_sensor.warning_hamburg_freie_und_hansestadt_1', 'headline') != none}}"
- sensor:
  - unique_id: warnung_2
    icon: mdi:alert-circle
    state: "{{ states.binary_sensor.warning_hamburg_freie_und_hansestadt_1.attributes.description if state_attr('binary_sensor.warning_hamburg_freie_und_hansestadt_2', 'description') != none }}"
    #state: "{{ states.binary_sensor.warning_hamburg_freie_und_hansestadt_2.attributes.description if state_attr('binary_sensor.warning_hamburg_freie_und_hansestadt_2', 'description') != none }}"
    attributes:
      friendly_name: "{{ states.binary_sensor.warning_hamburg_freie_und_hansestadt_2.attributes.headline if state_attr('binary_sensor.warning_hamburg_freie_und_hansestadt_2', 'headline') != none}}"
- sensor:
  - unique_id: warnung_3
    icon: mdi:alert-circle
    state: "{{ states.binary_sensor.warning_hamburg_freie_und_hansestadt_1.attributes.description if state_attr('binary_sensor.warning_hamburg_freie_und_hansestadt_3', 'description') != none }}"
    #state: "{{ states.binary_sensor.warning_hamburg_freie_und_hansestadt_3.attributes.description if state_attr('binary_sensor.warning_hamburg_freie_und_hansestadt_3', 'description') != none }}"
    attributes:
      friendly_name: "{{ states.binary_sensor.warning_hamburg_freie_und_hansestadt_3.attributes.headline if state_attr('binary_sensor.warning_hamburg_freie_und_hansestadt_3', 'headline') != none}}"
#

But seems that something is breaking while calculating the state...

#

sensor 1 works, but the texts from 2 and 3 fail the sensor. Is there something to sanitize the values?

wanton zodiac
#

Does the description have more than 255 characters? That's the limit.

fiery sparrow
#

hi

delicate crater
#

Yes, they do.

#

Ok, I cut them at 255 and it works, thank!

#

Not perfect.. but ok.