Not possible to template out the device_class state?

hi,

Using device_class safety (on a binary_sensor in my question, but could be any device_class) changes the state display from on/off to Safe/Unsafe.

Id like to show that displayed state in another template, but realize now that isn’t possible at all? Without creating yet another template sensor creating that for value_template…

usecase: the meteoalarm sensor is either on or off, but shows like:

31
So, Id like to create a markdown card showing Unsafe by using [[ binary_sensor.meteoalarm_brabant.state ]] which then of course shows On, where Id like it to show Unsafe …

58

Bro, you gotta stop using device classes when you are placing these items into custom cards. None of the custom cards properly display the state ever. There are a few that do, like the custom button card. But most do not translate properly. Either you handle the phrasing yourself or use cards that properly translate. Also, templating will never show the translated state, you always have to handle that yourself.

well, tbh, I didn’t use that at all, it is the integration Meteoalarm that uses that…

Alright then, you just need to know that under the hood there is no translation for states ever. Only reason I’m saying it like this is that we’ve had this conversation before. Translation is always handled by the UI. The business layer thinks in english with true/false/on/off/home/not_home etc.

yes, understood.
thanks.
silly thought that while the device_classes are there to take a lot of effort out of our hands, creating automatic presentation in the frontend, because of the fact an integration uses that device_class, we still have to create an extra template sensor to display that state in a card somewhere.

No profit gained after all …

Not true, if you are using a regular card it handles the translation. If you are doing stuff that is outside the ordinary (which is all you do), you have to handle it.

haha, maybe true. But you got to admit the ‘ordinary’ is reason for all those custom cards. Ordinary Lovelace is really very basic, and needs some extra custom care.

having said that, displaying the state of an integration, which in your terms should be called an ordinary part of HA, on a simple markdown card (admitted, custom, but the native card is rather plane and can’t show the state of another entity), already goes astray. I wouldn’t call that ‘outside the ordinary’, but ‘still-lacking-basic-features-hoping-to-soon-arrive’