Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using attributes in icon conditionals doesn't seem to work #45

Closed
gordallott opened this issue Sep 12, 2022 · 21 comments
Closed

Using attributes in icon conditionals doesn't seem to work #45

gordallott opened this issue Sep 12, 2022 · 21 comments

Comments

@gordallott
Copy link

Describe the bug

Using attributes in icon conditionals doesn't seem to work

To Reproduce

type: custom:room-card
title: Tester
entities: 
  - entity: update.home_assistant_core_update
    icon:
      conditions:
        - icon: mdi:radiator
          attribute: supported_features
          condition: above
          value: 0

the update.home_assistant_core_update attributes should look something similar to:

auto_update: false
installed_version: 2022.9.2
in_progress: false
latest_version: 2022.9.2
release_summary: null
release_url: https://www.home-assistant.io/latest-release-notes/
skipped_version: null
title: Home Assistant Core
entity_picture: https://brands.home-assistant.io/homeassistant/icon.png
friendly_name: Home Assistant Core Update
supported_features: 11

Expected behavior
The icon to be an mdi:radiator as we check the supported_features attribute for a value greater than 0

Screenshots
image

Desktop (please complete the following information):

  • OS: linux
  • Browser: firefox
  • Version: 104.0.2

Additional context
1, this card is great and exactly the kind of card that HA should be offering by default
2, setting an entity value in the conditional doesn't make any difference

@marcokreeft87
Copy link
Owner

You forgot to set show_icon to true. I will update the wiki so it says it more clearly

@gordallott
Copy link
Author

image
show_icon makes no difference unfortunately (and doesn't seem required for my other icon conditionals that don't use attributes)

@marcokreeft87
Copy link
Owner

image

Which version do you use?

@gordallott
Copy link
Author

v1.3.4 according to HACS, Should note in-case you missed it, this is specifically for conditionals that use the attribute key, regular non attribute using conditionals work absolutely fine

@marcokreeft87
Copy link
Owner

A good call! I see the issue :)

@marcokreeft87 marcokreeft87 reopened this Sep 12, 2022
@marcokreeft87
Copy link
Owner

Should be fixed with version 1.3.5

@marcokreeft87
Copy link
Owner

Oh not yet, but I have to go now. Workaround would be use v1.3.5 and set entity: update.home_assistant_core_update below attribute

@marcokreeft87
Copy link
Owner

Couldnt let it go. 1.3.6 has the real fix

@micium
Copy link

micium commented Sep 14, 2022

The icon state_on/off conditionals doesn't seem to work with input_boolean entity

@marcokreeft87
Copy link
Owner

Have you tried v1.3.7?

@micium
Copy link

micium commented Sep 14, 2022

Yes, I already installed the v1.37, the input_boolean entity icon change color on states but doesn't change the icon based on state_on/off

@marcokreeft87
Copy link
Owner

Can you share your yaml?

@micium
Copy link

micium commented Sep 14, 2022

Here below my yaml file, the problem in on entity: input_boolean.echo_sensor :

type: custom:room-card
title: Soggiorno
entities:

  • entity: input_boolean.echo_sensor
    name: Mov.Flex
    state_color: true
    tap_action:
    action: more-info
    icon:
    state_on: mdi:motion-sensor
    state_off: mdi:motion-sensor-off

@marcokreeft87
Copy link
Owner

You forgot show_icon: true

@micium
Copy link

micium commented Sep 14, 2022

You forgot show_icon: true

same problem with show_icon: true
picture

@marcokreeft87
Copy link
Owner

Can you set show_state to true for that entity and make another screenshot?

@micium
Copy link

micium commented Sep 14, 2022

picture

@marcokreeft87
Copy link
Owner

I think there is something wrong with your input_boolean. It has no state apparently or you have some javascript error.

image
Here is my test config. As you can see, it is working.

Is the input_boolean by any chance a template entity?

@micium
Copy link

micium commented Sep 14, 2022

Is the input_boolean by any chance a template entity?

No, I created it with helpers

state

I will try to remove and install custom-room, the show_state doesn't work with all entities (I'm sure, yesterday was ok)

@marcokreeft87
Copy link
Owner

const domain = computeStateDomain(stateObj);
    
    switch(domain) {
        case 'light':
        case 'switch':
        case 'binary_sensor':
        case 'input_boolean':
            return stateObj.state === 'on' ? icon.state_on : icon.state_off;
    }

This is the code for the icon in this case. As you can see the state of the input_boolean must be 'on' otherwise it would show the state_off icon. So the problem lies with the input_boolean.

@micium
Copy link

micium commented Sep 14, 2022

Good News, after remove the room-card and reinstall it on HACS, now it's ok:
picture

Many thanks for your support . I will pay a coffee !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants