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

Allow default icons to be used in badges #71

Merged
merged 2 commits into from
Jun 9, 2020
Merged

Allow default icons to be used in badges #71

merged 2 commits into from
Jun 9, 2020

Conversation

drzony
Copy link
Contributor

@drzony drzony commented Apr 29, 2020

This change allows to use default icons in badges.

Example below will show temperature, battery icon (changing based on value) and battery %

title: Devices
type: entities
entities:
  - entity: sensor.some_temperature
    type: 'custom:multiple-entity-row'
    name: Temp sensor
    secondary_info: last-changed
    entities:
      - entity: sensor.some_temperature_battery
        name: false
        icon: null
      - entity: sensor.some_temperature_battery
        name: false

Possibly fixes # 61

@benct
Copy link
Owner

benct commented May 6, 2020

This should already work by using icon: true..?

@benct benct added the question Further information is requested label May 6, 2020
@drzony
Copy link
Contributor Author

drzony commented May 6, 2020

Not exactly, when icon: true, the icon is taken from attributes.icon which is undefined (I think it's only defined when icon is overridden in entity settings) in case of default entity icons (MQTT batterry and link-quality). This means that in else if (entity.icon) return this.renderIcon(entity); the property entity.icon is undefined and the icon is not rendered at all.

I made above change not to break current behavior. But it also can be done by adding additional property like use_default_icon or something

@drzony
Copy link
Contributor Author

drzony commented May 7, 2020

Here is an image of how this works:
Config

@benct benct merged commit 6b83f4c into benct:master Jun 9, 2020
@benct benct removed the question Further information is requested label Jun 9, 2020
@benct
Copy link
Owner

benct commented Jun 9, 2020

Changed this slightly so that it should be possible to use icon: true to achieve the same thing. I'll release a new version later today if I get the time.

Thanks for the contribution, let me know if it somehow doesn't work as expected.

@i00 i00 mentioned this pull request Jun 10, 2020
@drzony
Copy link
Contributor Author

drzony commented Jun 16, 2020

Had some time to update the card, everything works as expected :)

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

Successfully merging this pull request may close these issues.

2 participants