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

style templating of binary_sensor, state not matching #331

Closed idkpmiller closed 6 months ago

idkpmiller commented 6 months ago

Which version of Room Card? 1.08.04

Describe the bug A clear and concise description of what the bug is. Using the4 configuration guide as an example for the template styles. The example shows a switch entity, I would like to make some icon changes to a binary_sensor entity. I heve the following yaml, and the 'Windows' entity always falls through to the default outcome if no match is fouund for both color and iicon used. I have trid matches of the state as off, Off, OFF, closed, Closed and CLOSED None of these create a match.

To Reproduce

use the following yaml

  - entity: binary_sensor.office_windows
    icon:
      template:
        styles: >
          if (entity.state == 'off') return 'color: blue';  
          if (entity.state == 'on') return 'color: yellow';  
          else return 'color: white';
        icon: >
          if (entity.state == 'off') return 'mdi:window-closed';  
          if (entity.state == 'on') return 'mdi:window-open';  
          else return 'mdi:window-shutter-auto';
    show_icon: true
    name: Windows

Expected behavior When the windows grrop state is Open then the color of the icon should be yello and the icon displayed should be for window-open. When they are closed the icon should be blue and the icon should be window-closed. the white colow and the neither stae is always being displayed when the cuurrent state of the group entitiy is Closed or Open.

YAML

type: custom:room-card title: Office entity: binary_sensor.office_epl_occupancy icon: mdi:motion-sensor show_icon: true info_entities:

rows:

marcokreeft87 commented 6 months ago

Hey! Check out : https://github.com/marcokreeft87/room-card/wiki/Configuration#icon and especially the icon conditions

idkpmiller commented 6 months ago

Managed to fix it, not exactly sure how, but happy its working. I am sorry but I fing the configuration guide of limited assistance due to its form. I seem to have to muddle my way through. Thanks for an excellant card Paul