how exactly did you do that?
it’s always great to complement statement like that with your code if you would like the community to help as it’s just guesswork otherwise.
that’s exactly what I tried to convey earlier, you are creating a(n unnecessary ) template sensor for the exact same entity as the binary_sensor ping.
The picture you’re showing has 2 different Tv’s though, you’d best show us your group ?card definition
I remember you saying about 2 sensors this way but Im happy its working but now I have it working, if I can get it to 1 sensor per device, then thats even better
can only repeat my words: customize the binary_sensor, and you’re set. I’ve already provided you with a template example.
no need for a template sensor, no need to hide anything in that case.
that’s it.
btw, your spacing of the word sensors: and the rest is off, it should be:
binary_sensor:
- platform: template
sensors:
living_room_tv_power:
friendly_name: LG TV (Living Room)
icon_template: >
{% if is_state('binary_sensor.living_room_tv_status','on') %} mdi:television
{% else %} mdi:television-off
{% endif %}
device_class: power
value_template: >
{% if not is_state('binary_sensor.living_room_tv_status', 'off') and not
is_state('binary_sensor.living_room_tv_status','unavailable') %}
true
{% endif %}
you still have the unavailable test in your template. Given this is a binary sensor, either being on or off, why is that? Have you ever seen in being unavailable?
I advise you to enclose any HA code between a pair of 3 backquotes to prevent formatting.
Yes, it should do the trick and actually I can see no that binary_sensor on your screenshots.
If you provide all the relevant config and screenshots in one post, I’m pretty sure even you yourself will be able to solve the puzzle.
Let’s do it
Me here too, fallen in this rabbit hole decided to invest some time to figure out what is available.
The only home assistant only way of doing this seems to be the platform template_sensor however this has the drawback of you just adding another sensor just to have a dynamic icon, this sounds odd to me.
By using community stuff I found a few other options:
Looks like @Mariusthvdb has made a fork of unmaintained custom-ui stuff, this is quite old, I was looking at the code and seems like the js was minified and now it is formatted again. This relies on setting customization attributes that are later parsed on the UI itself by a js module.
Yet another option is the templatable lovelace card this is a row only component for the entities card, which promises to allow to change the icon.
And last, but not least is the config-template-card which seems to be one of the best options, I ended up using this now.
Are there other options?
Do somebody know why icon_template: isn’t supported on all sensors? Or at least a icon_on:, icon_off: for all binary sensors? Seems quite common specially with the mdi icon library having several version of icons with the “off” state.
Because the only binary_sensor I have is the one with template and I get the following error:
Logger: homeassistant.components.template.binary_sensor
Source: helpers/config_validation.py:752
Integration: template (documentation, issues)
First occurred: 12:59:52 (1 occurrences)
Last logged: 12:59:52
The 'entity_id' option is deprecated, please remove it from your configuration
Home Assistant עלה!
That is a change mentioned in the breaking changes for 115: entity_id is no longer required for template sensors to find the states it needs to listen to.
It has never been required for your binary_sensor because it is right there in the template anyway.
So, take out the entity_id line and you will be fine
You’re sure this is the correct template to see if the sun is up