Skip to content

Allow falsey values for attribute value in a picture-elements card element.#8943

Merged
bramkragten merged 3 commits intohome-assistant:devfrom
boralyl:allow-falsey-attribute
Apr 19, 2021
Merged

Allow falsey values for attribute value in a picture-elements card element.#8943
bramkragten merged 3 commits intohome-assistant:devfrom
boralyl:allow-falsey-attribute

Conversation

@boralyl
Copy link
Copy Markdown
Contributor

@boralyl boralyl commented Apr 18, 2021

Proposed change

Allow attribute values that are falsey (0, false, '') for picture elements when using the attribute key. e.g.

cards:
  -   type: picture-elements
      image: "/local/tp-04.png"
      elements:
      - type: state-label
        entity:  air_quality.master_bedroom
        attribute: particulate_matter_2_5
        suffix: ' PM2.5'
        style:
          # ...

In this example the value of 0 is completely valid, but the card will show a warning instead of the value of 0.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

cards:
  -   type: picture-elements
      image: "/local/tp-04.png"
      elements:
      - type: state-label
        entity:  air_quality.master_bedroom
        attribute: particulate_matter_2_5
        suffix: ' PM2.5'
        style:
          # ...

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue or discussion:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@boralyl boralyl changed the title Allow falsey values for attribute value. Allow falsey values for attribute value in a picture-elements card element. Apr 18, 2021
Comment thread src/panels/lovelace/elements/hui-state-label-element.ts Outdated
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
Comment thread src/panels/lovelace/elements/hui-state-label-element.ts Outdated
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
@bramkragten bramkragten merged commit b398727 into home-assistant:dev Apr 19, 2021
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants