I use a card_mod in Homeassistant to define the color on the dashboard depending on the state of my covers. For instance:
card_mod:
style: |
:host {
{% if state_attr('cover.woonkamer_covers', 'current_position') >= 99 %}
--card-mod-icon-color: var(--green-color);
{% elif states('cover.woonkamer_covers') == 'opening' %}
--card-mod-icon-color: var(--yellow-color);
{% elif state_attr('cover.woonkamer_covers', 'current_position') < 15 %}
--card-mod-icon-color: var(--grey-color);
{% elif state_attr('cover.woonkamer_covers', 'current_position') > 90 %}
--card-mod-icon-color: var(--green-color);
{% else %}
--card-mod-icon-color: var(--yellow-color);
{% endif %}
}
This works perfect although I receive an error message in the logs, stating: “Homeassistant: TypeError: ‘>’ not supported between instances of ‘NoneType’ and ‘int'”
Is there anyway to fix this?
It seems it has something to do with the fact that Python doens’t define the percentage as an integer and I should convert it to an int first.
Anyone?
I’ve Googled on this message but don’t really know how to fix this. Any help is much appreciated.
Perry van Dijk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.