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

Templates Issue: TypeError: Cannot read properties of null (reading 'state_on') #344

Closed lennon101 closed 2 months ago

lennon101 commented 2 months ago

Which version of Room Card?

1.08.04

Describe the bug

When trying to use the templates as described in the wiki, an error appears in the preview window:

To Reproduce n/a

Expected behavior

After adding the template code as provided by the wiki, I would expect the icon to turn yellow when the entities state is 'on'

Screenshots

Screenshot 2024-08-30 at 7 03 15 AM

Desktop (please complete the following information):

Additional context

Without templating, the icon turns yellow without any issues (just using the normal styles method per entity).

YAML

type: custom:room-card
title: BATHROOM
entity: light.bathroom_lights_group
show_state: false
tap_action:
  action: navigate
  navigation_path: /dashboard-rooms/bathroom
templates:
  - name: test_template
    template:
      show_icon: true
      state_color: true
      icon:
      template:
        styles: >
          if (entity.state == 'on') return 'color: yellow';  

entities:
  - entity: light.shellyswitch25_c8c9a3759e8b_channel_1
    name: Ceiling
    template: test_template
lennon101 commented 2 months ago

More info:

If I indent the template under icon then the error goes away but the icon does not change color:

templates:
  - name: test_template
    template:
      show_icon: true
      state_color: true
      icon:
        template:
          styles: |
            if (entity.state == 'on') return 'color: yellow';  
marcokreeft87 commented 2 months ago

Please check the state value. Because it gets parsed to javascript I'm sure it's a different value or a typo.

lennon101 commented 2 months ago

It is not. It is "on". I have checked. Please reopen this issue. And please don't consider it closed until we have confirmed it fixed.

Closing the issue so abruptly does not promote community engagement or support in my opinion

marcokreeft87 commented 2 months ago

Why arent you using : https://github.com/marcokreeft87/room-card/wiki/Configuration#icon-conditions ?

Rocka84 commented 2 months ago

@lennon101 Why did you request removal of this card from hacs? It works fine and has received updates when necessary. I'm sorry if you had a bad experience with it but why spoil the fun for everyone else too?

@ludeeus Please reconsider the removal of this card!