marcokreeft87 / room-card

Show multiple entity states, attributes and icons in a single card in Home Assistant's Lovelace UI
MIT License
228 stars 38 forks source link

Allow icon in title without an entity, make entity optional (rooms without a single entity for the room state) #230

Closed efaden closed 1 year ago

efaden commented 1 year ago

For most of my rooms there isn't a single entity that represents the room, but rather the state/icon may be a hybrid based off of the state of a bunch of different things. For example in my garage there are two doors. I built a set of custom icons that show the states of both doors (e.g. open-open, open-closed, closed-open, closed-closed). Example of a jinja template to select the icon:

                      {% set stateSingle = states('sensor.single_garage_door_position') %}
                      {% set stateDouble = states('sensor.double_garage_door_position') %}
                      {% if (stateSingle == 'Closed' and stateDouble == 'Closed') %}
                        emf:garage-dual-closed-closed
                      {% elif (stateSingle == 'Cracked' and stateDouble == 'Closed') %}
                        emf:garage-dual-closed-cracked
                      {% elif (stateSingle == 'Open' and stateDouble == 'Closed') %}
                        emf:garage-dual-closed-open
                      {% elif (stateSingle == 'Closed' and stateDouble == 'Cracked') %}
                        emf:garage-dual-cracked-closed
                      {% elif (stateSingle == 'Cracked' and stateDouble == 'Cracked') %}
                        emf:garage-dual-cracked-cracked
                      {% elif (stateSingle == 'Open' and stateDouble == 'Cracked') %}
                        emf:garage-dual-cracked-open
                      {% elif (stateSingle == 'Closed' and stateDouble == 'Open') %}
                        emf:garage-dual-open-closed
                      {% elif (stateSingle == 'Cracked' and stateDouble == 'Open') %}
                        emf:garage-dual-open-cracked
                      {% elif (stateSingle == 'Open' and stateDouble == 'Open') %}
                        emf:garage-dual-open-open
                      {% else %}
                        mdi:alert
                      {% endif %}

I suppose the alternative would be to build a template sensor that combines those into a single entity.

marcokreeft87 commented 1 year ago

Why not use a group or template entity? Or use the icon template in room card