I found two posts both by @jms3000, he has written the code to do this I just figure it needs someone to cast their eye over it, see it doesnât break any rules and merge it in.
and
Basically, I think ALL standard entities should have friendly_name_template 's
To maintain backward compatibility, attributes named âxxxxxxâ and âxxxxxx_templateâ are equivalent and should not be used together. Eventually this can be deprecated in favour of phasing out the â_templateâ.
TL;DR There should be no distinction between template and non-template attributes.
quite. like it is on the custom: button-card after some development
just have a look at the icon, which needs to be icon_template for the template sensor. Forcing us to use a fake icon_template, or even setting the icon in customize.
A fine illustration of what the future for attributes should be, not matter the name. âSimplyâ use or not use a template, and forget about the configuration variables names ending in _template or not.
in fact, the distinction for all _template entities would become superfluous, a (current) template sensor would simply be a sensor using templates in 1 of its configuration variables fieldsâŚ
Thatâs exactly what I would love to see. The forum is riddled with people wondering why their templates donât work only to find that they used data: instead of data_template:.
I like the train of thought in this topic but I wonder how difficult it would be to implement. Especially when considered in light of how it works now: even a small modification to an entity (change its device_class) requires restarting the entire application. That kind of architecture implies there may be some aspects of an entityâs definition that might be challenging to make dynamic (via templates).
Nevertheless, itâs a worthwhile goal because, I agree, the current state of what can and cannot be templated is not readily self-evident. It should be comprehensive and transparent.
The sensors are defined in configuration.yaml at system start time. Even if you use a template, the sensor is defined only once. Hence this is not dynamic. You canât reconfigure the sensor.
Thereâs no debating the fact that youâve described the status quo (entities are created at startup and remain fairly static thereafter). I believe the discussion is about altering it.
As I say, I may have missed something but you would have to give the interpreter a decent whack at distigushing the difference in the absence of the â_templateâ bit ???
though this FR has grown somewhat into a more general discussion about the need for a distinction between regular sensor and template sensorâŚ,
you are right, my proposal would be to include the friendly_name_template for binary_sensors.
Not really sure what you mean with your final sentence, because as it stands, I was simply proposing to add friendly_name_template: to the binary sensor.
If and when this would develop, it wouldnât matter any more, and we would be allowed to simply write a template after the variable friendly_name:
to the format of the template itself: both would fit the bill, just as we can write service_templates or other templates in different ways to reach the same goal:
service_template: >
script.turn_{{'on' if states('sensor.example') == 'on' else 'off'}}
Marius, you are correct and have provided some excellent examples.
I am considering Steveâs suggestion that any entity attribute - should be template able (if thatâs even a word) and without the _template suffix.
But, without taking anything away from your proposal, when we use those examples you gave, the interpreter âknowsâ a template is coming because we tell it so, with the â_templateâ at the end of the item listing.
The ânormalâ way has just a text string and this loads a static piece of text into memory for that entity attribute.
When it is a template it has do do something different, it observes entities within the template that will have to be monitored and it loads the template that will have to be evaluated (a completely different method)
I merely suggest (because I like the proposal endorsed by yourself and extended by Steve) that we should be able to use a template anywhere (that does not affect the entity_id or its place in the ecosystem) but the interpreter will need to know the difference. And I would suggest the best way to do that is to âensureâ that we give it a clue by using a full jinja interpretable expression.
I would not be coding this, it would probably need several different coders if this is spread across different entity types, they need to implement this in a consistent manner and I am merely âsuggestingâ a method.
Actual implementation is going to be upto a committee of a select few (if it happens at all) and Iâm trying to plan ahead.
The general proposal (in its current form) is the child of yours but also of Steve for the extension and it is simply a brilliant and (in hindsight) obvious step for HA to make.
Thank you both for your time and efforts
well, I seem to be missing the point of your extensive post, other than that we would agree on the fact that we hope/feel that all entity attributes should be templatable, and that we shouldnât need the suffix _template to tell the interpreter, but that the underlying code would recognize a template automatically.
But, that was summarized already before your post
and, as I hope my previous post would illustrate, a full interpretable template is anything in valid Jinja between {{ }}. That doesnât need to be the full resulting string, but can be just a small part of it. As long as it follows Jinja definitions.
I would even think icon_template: mdi:homeassistant would pass, and, as a matter of fact, have seen people use that in the template sensor