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

map_state example from documentation not working #138

Open
yesterdayshero opened this issue Feb 16, 2022 · 1 comment
Open

map_state example from documentation not working #138

yesterdayshero opened this issue Feb 16, 2022 · 1 comment

Comments

@yesterdayshero
Copy link

Trying to use the map_state function based on the example in the documentation and it isn't working.

If I apply the same settings in Home Assistant, I still get the media player title showing in the Banner Card, rather than the values entered in the map_state code.

entity: media_player.office
map_state:
  playing: mdi:disc-player
  not_playing:
    value: mdi:stop
    name: A custom entity heading

media player in banner card

@luixal
Copy link

luixal commented Feb 19, 2022

I'm hitting the same problem. In my case, I'm using the banner card to show some simple on/off switches (used for sprinklers) this way:

type: custom:banner-card
heading:
  - mdi:sprinkler-variant
  - Garden Irrigation
background: '#EDE7BA'
entities:
  - entity: switch.sprinkler_3
    name: '3'
    map_state:
      'on':
        value: mdi:sprinkler-variant
        name: 'on'
      'off':
        value: mdi:sprinkler-variant
        name: 'off'

In my case, the name field is showing right ("on" when switch is on and "off" when it's off) but icon nevers shows up. I've tried removing the name field (just in case it has priority over the icon or something); icons are still not showing.

I've also tried removing all name fields (the entity one too) and then entity's name is showed.

Any ideas on this?

Thanks!

-- UPDATE --

I had a look at the code and I've seen the following (just a quick look around, maybe this isn't related to this bug):

  • renderEntities function uses the renderAsToggle function to render any entity of type light, switch (my case) or input_boolean.
  • renderAsToggle function has no code related to the value field and just uses the mwc-switch tag.
  • renderValue function seems to be directly related to this issue, but it's only used in renderDomainDefault and renderCustom but not in renderAsToggle.

Maybe this is all intended and the value field is only to be used with custom elements. In that case, would be great to have that info in the docs :)

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

2 participants