Since the 0.115 update the below icon_template does not work anymore. If I test it in the Template editor it works, it detects the state and updates. The icon however is not updated on the frontend.
Superfluous as in âunnecessaryâ? Itâs just how I named it.
Doesnât have anything to do with the fact that the icon is not updating anymore, expecially because it seemed to work before 0.115.
I understand it looks weird. But theyâre linked and the same. This was to give Homekit a reversed state so it would show up correctly in Homekit. cover.awning is the actual intergration while cover.awning_homekit is the switch that I control. Both in Lovelace and Homekit on my phone.
Your template cover doesnât have a value template, so it never knows if it is on or off. Your icon_template is based on itself and because we donât know whether itâs on or off, the icon doesnât know which to show.
You need cover.awning in your template, not cover.awning_homekit so that the icon has a state to monitor.
Except that it does. The cover.awning_homekit switches on/off based on cover.awning.
Unless in order for it to work since 0.115 the icon_template needs to be in the same automation as the entity it references. So in my example only cover.awning would work.
I understand what your saying and it certainly is better then my automation, Iâm maybe just trying to understand where the problem suddenly comes from.
Iâm trying to change the icon based on the entityâs own state.
The code above worked fine untill release 0.115.
Iâve read the huge release note for 0.115 but canât find any answer why i doesân work anymore.
Can you please edit your post so I can check the code?
I solved it by changing cover.awning_homekit to cover.awning as that one is referenced in the automation. Itâs not a problem for me as cover.awning_homekit changes state based on cover.awning. /u/mf_social was right, something changed in 0.115 that this icon_template couldnât read the state of cover.awning_homekit as that is a different automation/entity then the one referenced.
âcovers:â needs to be in line with âplatform: templateâ, your yaml lint didnât check out. You can test this by using http://www.yamllint.com/ for example.
The code blow works checks out. You didnât fill any data after open_cover and close_cover, did you leave that out?
Changed the yaml typo but itâs still not changing the icon based on the state of the cover switch in hassio.
I didnt fill in any data for open_cover or close_cover as it is a dummy switch which i handle from node-red. If node-red sees a change on the entity cover.slaapkamer_stef then node-red fires a http command to the custom build cover controller.
I handle all automations and stuff in node-red as it is easier to use for me with my limited programming knowledge.
In node-red the msg.payload says open or closed after activating the cover switch in hassio. So the state of the cover switch seems ok in hassio and node-red.
If i load the code in Hassio > Developer Tools > template like :
{%- if is_state("cover.slaapkamer_stef", "open")-%}mdi:window-shutter-open{% else %}mdi:window-shutter{%endif %}
The preview pane of the template tools show the correct text mdi:window-shutter or mdi:window-shutter-open corresponding to the state of the cover switch.
Could the problem be that i donât have any data in open_cover and close_cover or is there another problem or bug in hassio with the template and changing the icon. ?
That makes sense tbh. The template for the icon relies on the state of the entity itâs part of. So you close the cover, the state object updates, the template re-evaluates, the icon changes thus updating the state object, so the template re-evaluates in an infinite loop.
In fairness though, there should never have been a time when templates were referencing the entities they were a part of, you were just lucky it worked before.