nathan-gs / ha-map-card

A Map Card for Home Assistant
https://community.home-assistant.io/t/map-card-a-slightly-improved-map-card/693088
MIT License
30 stars 9 forks source link

Fix card_mod support. #63

Closed thybag closed 3 months ago

thybag commented 3 months ago

Short version: card_mod (a HA plugin that allows you to define custom styling on cards) doesn't work when used on the Map card currently. It turns out this is due to the root config being set with the result of a Config class.

This PR fixes that by setting the internal config to _config instead.

Longer version: I'm not entirely certain why but setting a cards config to a Config class causes issues in home-assistants styling.

You can tell when this has happened as the class on the HA card is something like type-undefined, rather than "type-custom-map-card".

The primary repercussion of this bug is that card_mod styles don't get applied to the cards. I use card_mod quite a bit so had spent quite a while pulling my hair over while this wasn't working. I then ended up with same issue in my own card and after quite a bit of confusion came across https://github.com/thomasloven/lovelace-card-mod/issues/252

The fix worked perfectly when applied to https://github.com/thybag/ha-energy-entity-card/pull/2 and appears to work fine here on my testing (i can now get rid of the silly border on my full page map once and for all )

ildar170975 commented 3 months ago

Tested with card-mod a bit - seems to work stable!

card_mod:
  style:
    div#map map-card-entity-marker $: |
      .marker {
        border-color: transparent !important;
        background-color: transparent !important;
      }
    .: |
      ha-card {
        --ha-marker-border-radius: 10%;
      }

image