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

Styles are not applied when used with auto-entities #184

Closed
4 tasks done
Mariusthvdb opened this issue Feb 28, 2022 · 15 comments
Closed
4 tasks done

Styles are not applied when used with auto-entities #184

Mariusthvdb opened this issue Feb 28, 2022 · 15 comments

Comments

@Mariusthvdb
Copy link

Mariusthvdb commented Feb 28, 2022

My Home Assistant version: 2022.4.0.dev20220228

My lovelace configuration method (GUI or yaml): YAML

What I am doing:

showing badge card which is auto-filled by auto-entities and justify the badges

What I expected to happen:

immediate effect (as before, somehow latest are releases frustrate correct operation)

What happened instead:

need a resize window in the browser to have the mod be effective, ast least showing the mod is ok.

Minimal steps to reproduce:

# The least amount of code possible to reproduce my error
type: custom:mod-card
card_mod:
  style:
    badge-card:
      $: |
        div#badges {
          display: flex;
          justify-content: space-around;
        }
card:
  type: custom:auto-entities
  card:
    type: custom:badge-card
  filter:
    include:
      - domain: person

# End of code

using a fixed set of badges:

  - type: custom:badge-card
    card_mod:
    style: |
      div#badges {
        display: flex;
        justify-content: space-around;
      }
    badges:
      - sensor.weather_animated_icon
      - sensor.badge_wind_compass
      - sensor.wind_bft

always works, proving the mod to be correct

Error messages from the browser console:

no errors

By putting an X in the boxes ([]) below, I indicate that I:

  • Understand that this is a channel for reporting bugs, not a support forum (https://community.home-assistant.io/).

  • Have made sure I am using the latest version of the plugin.

  • Have followed the troubleshooting steps of the "Common Problems" section of https://github.com/thomasloven/hass-config/wiki/Lovelace-Plugins.

  • Understand that leaving one or more boxes unticked or failure to follow the template above may increase the time required to handle my bug-report, or cause it to be closed without further action.

@skynet01
Copy link

skynet01 commented Mar 9, 2022

I think I might be experiencing the same issue. I am trying to remove a background/make it transparent on a card with auto entities and once the card updates with another entity the background comes back. I am pretty sure its the same issue.

card:
  type: entities
  style: |
    ha-card {
       background: none !important;
       box-shadow: none;
     } 

@ildar170975
Copy link
Contributor

ildar170975 commented Mar 9, 2022

There is a problem with card-modding a card inside auto-entities.

Example 1 - style is defined for the internal card itself (result OK):

type: custom:auto-entities
card:
  type: entities
  card_mod:
    style: |
      .card-content {
        padding: 0px;
      }
filter:
  include:
    - domain: device_tracker
sort:
  count: 5

image

Example 2 - style is defined from the auto-entities level (result WRONG):

type: custom:mod-card
card_mod:
  style:
    hui-entities-card:
      $: |
        .card-content {
          padding: 0px;
        }
card:
  type: custom:auto-entities
  card:
    type: entities
  filter:
    include:
      - domain: device_tracker
  sort:
    count: 5

or

type: custom:mod-card
card_mod:
  style:
    auto-entities hui-entities-card:
      $: |
        .card-content {
          padding: 0px;
        }
...

image
image

But sometimes even w/o resizing the window etc - just after F5 - the style seems to be applied.

So, the problem is about using card-mod for elements inside auto-entities.

Since the badge-card does not have a ha-card element we need to place the card inside the mod-card - but we cannot style it anyway from the auto-entities level.


Another example - with fold-entity-row:
W/o auto-entities it works OK:

type: entities
entities:
  - type: custom:fold-entity-row
    head:
      type: section
      label: device_tracker
    open: true
    entities:
      - device_tracker.iiyama
card_mod:
  style:
    fold-entity-row:
      $: |
        div#head {
          color: red;
        }

image

This does NOT work when using auto-entities:

type: entities
entities:
  - type: custom:auto-entities
    filter:
      include:
        - domain: device_tracker
    sort:
      count: 5
    card:
      type: custom:fold-entity-row
      head:
        type: section
        label: device_tracker
      open: true
card_mod:
  style:
    fold-entity-row:
      $: |
        div#head {
          color: red;
        }

or

...
card_mod:
  style:
    auto-entities fold-entity-row:
      $: |
        div#head {
          color: red;
        }

image

@Mariusthvdb
Copy link
Author

just letting you know the update to 3.1.3 does not really help this issue (of the badges justify-content: space-around;, dont know about the others that have mentioned issues here).

What is bit different now, is that I can get the mod to work upon a reload of the view or 2. Before, this didnt work and I needed to resize the screen

@ildar170975
Copy link
Contributor

ildar170975 commented Mar 16, 2022

After update, my example with fold-entity-row + auto-entities still gives same unstable results:

But sometimes even w/o resizing the window etc - just after F5 - the style seems to be applied.

Probably the latest update was not purposed to fix this particular behaviour.

@Mariusthvdb
Copy link
Author

Mariusthvdb commented Mar 16, 2022

i have to agree with Ildar, and rewriting my auto-entities config in the opening post above to

type: custom:mod-card #needed for margin spread correctly (especially on iPhone)
card_mod:
  style:
    badge-card:
      $: |
        div#badges {
          display: flex;
          justify-content: space-around;
        }
card:
  type: custom:badge-card
  badges:
    - entity: person.marijn
      card_mod: &badge
        style: |
          :host {
              --ha-label-badge-label-color: black;
            {% set zones = states.zone|map(attribute='name')|list %}
            {% set id = config.entity.split('.')[1] %}
            {% set activity = states('sensor.' ~ id ~ '_app_activity') %}
            {% set cc = state_attr('sensor.' ~ id ~ '_app_geocoded_location','ISO Country Code')|lower %}
            {% if cc and cc != 'nl' %}
              --label-badge-red: white;
            {% elif is_state(config.entity,'home') %}
              --label-badge-red: green;
              --ha-label-badge-label-color: gold;
            {% elif 'bij' in states(config.entity) %}
              --label-badge-red: gold;
            {% elif activity in ['Automotive','Cycling','Walking'] or
                    states(config.entity) in zones %}
              --label-badge-red: mediumslateblue
            {% else %}
              --label-badge-red: #636B75;
            {% endif %}
          }
    - entity: person.2
      card_mod: *badge
    - entity: person.3
      card_mod: *badge
    - entity: person.4
      card_mod: *badge
    - entity: person.5
      card_mod: *badge
    - entity: person.6
      card_mod: *badge

makes it work immediately. but I guess thats what I already said in the opening post... nevermind, just to stress this is still happening then ;-)

@ildar170975
Copy link
Contributor

Marius, the issue should be renamed to "Styles may not be applied when using for auto-entities" probably...

@Mariusthvdb Mariusthvdb changed the title mod-card needs resize before kicking in when used with auto-entities Styles are not applied when used with auto-entities Mar 16, 2022
@Mariusthvdb
Copy link
Author

changed that. thx

@ildar170975
Copy link
Contributor

See no issues here:

image

type: custom:mod-card
card_mod:
  style:
    badge-card:
      $: |
        div#badges {
          background: red;
        }
card:
  type: custom:auto-entities
  card:
    type: custom:badge-card
  filter:
    include:
      - entity_id: input_boolean.test_boolea*
        sort:
          count: 5

@Mariusthvdb
Copy link
Author

Mariusthvdb commented Jan 21, 2024

not using this a anymore, but maybe also test the

    badge-card:
      $: |
        div#badges {
          display: flex;
          justify-content: space-around;
        }

mod, as that is what the issue was about?
seems those space-xxx options are somewhat peculiar, and I can not pinpoint the cause at all times.

tbh, I am not even sure now, this is an auto-entities thing in the first place, though we all believed it was above?
needs further inspection

@ildar170975
Copy link
Contributor

This is not about a particular CSS property. These "flex" attributes will definitely work (with or w/o !important).

@Mariusthvdb
Copy link
Author

so are you saying the original issue doesnt exit anymore?
then we can close?

@ildar170975
Copy link
Contributor

This is up to you to decide, you are the author.

@Mariusthvdb
Copy link
Author

Mariusthvdb commented Jan 21, 2024

yes sure, but what I meant to ask is, if you can confirm the original issue (which you also experienced) is no longer an issue, we can close.
as I dont use the specific config any longer (as a matter of fact I dont use those badges anymore at all) I would follow your conclusion here.

@ildar170975
Copy link
Contributor

At least the code I posted here works OK.

@Mariusthvdb
Copy link
Author

thx. since I dont use the badges from the opening post anymore, nor have any card_mod set directly via any of the other posted examples above (eg using the mod-card), I dont experience this issue anymore, and will close.

thanks for taking part

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