Change case in Tiles template

HI,

Using this template in my Tiles setup:

    style_template: >
      return 'background-image: url(\"/local/modes/' + state + '75.png\")';

the system uses the state of the entity, which is capitalized, eg Kiosk, Developer, Normal, Full house.


I need these to change into lowercase, and filter out the spaces, so it renders kiosk.png, full house.png etc etc
in python this is done by replace(' ', '').lower()) . Can something like that be done in Yaml also?

Pleas have a look,
Marius

dum question why not match the filename to the match the state name make the same case you only have to do it once

sure ive made that workaround for now, creating dedicated folder with dedicated .png’s.
Im using the current .png’s in other scripts/settings as well and dont like to create separate images for each of these uses.

so, workaround for now, but hope to be able to create a template doing what i want, maybe something like:

style_template: >
      return 'background-image: url(\"/local/modes/' + state + '75.png\" | replace(' ', '').lower() )';
1 Like

like you work around and you must be a windows person as windows does not care about the case of the filename

:wink: lol
I’m human… willing to forgive the computers idiosyncrasies for once, by setting it in a more intelligent template, and not having to hardcode it for each and every setting…

on a Mac btw.

made it:

    style_template: >
      return 'background-image: url(\"' + attributes.entity_picture + '\")';