I have been searching for a couple of weeks now and can’t seem to find the answer. It seems like it should be easy…and probably is, I just can’t find it. I want to use to different icons “garage-open” and “garage” and possibly “garage-alert” depending on the state. Any help to point me in the right direction would be appreciated.
quite remarkable really that the example uses the entity_id for updating the binary_sensor template. It doesn’t need it at all, since the entity to update is quite clear in the value_template…
This confuses readers of that documentation, thinking every template sensor would need those added entity_id’s.
On that same page is described when in fact we need to use the added entity_id.
btw note this is an example of an icon_template referencing itself in the template
I read the page given what you said (to align perspectives)
And though I agree that the entity id is not required (sun.sun is a tracked entity and obvious to the interpreter from the template) it positions the concept of entities that ‘may’ be referenced to update the template, so it’s not ‘wrong’
The self referencing in the icon template is also valid and I’ve done this myself, typically when the value template is ‘complex’. Why repeat a long template (possibly with a mistake in it) to evaluate when you can just reference it’s result ?
This also means you can copy a sensor and just change a minimal amount
of course you are right, I merely think it would have been a better educational insight to show the entity_id on a sensor that truly needs it. Most useful might have been a template using now(), which is done on most HA installations I would think.
As an example that wouldn’t need it, this would be the case…
Yes, I see…
But that is a special case where you are iterating over a group???
I think by the time a beginner gets there, he may have the skills to do some more digging ???
Having said that, you had issues (as I would have done) so putting another example in the entity update would be sensible (with an explanation as to why)
And a caution note about the self referencing in the case of groups, would be of value.
You argue well, and your English, syntax and grammar is amazing.
Sumbit a pull request to update the docs as you suggest, I’m sure it will be approved
I would also like to change state of icon in front of Shutter.
Where do I have to place the if loop?
Should this be done at the Configuration.yaml of the cover or in the Lovelace UI entities?
Unfortunately the icon is not shown for first items, only placing fix icon e.g. for second item works!
You have to put your template under icon_template: in an item that will accept icon_template:
(ie. not sure where you are putting that and I’m not sure that cover. will accept it (I don’t have covers))
Sometimes you have to create a sensor (template) to display the desired value AND the desired icon.
Also your template makes no sense. That is not permissible python.
you’d need something like : -
icon_template: "{{ 'mdi:television' if is_state('binary_sensor.tvfr', 'on') else 'mdi:television-off' }}"
From what you’ve said, I would say you need advice from someone who a) has covers b) uses mqtt to talk to them
I also would suspect that your cover is returning an ‘unexpected’ value of 9. I have no idea what this means, you will have to read the documentation that comes with your device.