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

(Gradient) Colors Not Applying for LQI (Link Quality Indicator - Zigbee2MQTT) Values (0–255) #753

Open
MarvinMynx opened this issue Dec 11, 2024 · 1 comment
Labels
question Further information is requested

Comments

@MarvinMynx
Copy link

MarvinMynx commented Dec 11, 2024

Describe what is wrong
I am using the Battery State Card to display Zigbee Link Quality Indicator (LQI) values with dynamic gradient colors and icons. While the icons work as expected, the gradient colors do not behave as intended. The card fails to reflect the gradient for the defined steps (red, yellow, green) even though my LQI values range from 0 to 255.

Here are the steps I have tried so far:

  • Set default_state_formatting: false to prevent default formatting from interfering.
  • Used state_map to scale the LQI range (0-255) to percentages (0-100).
  • Configured colors with and without gradient: true, as well as with different numbers of steps.
  • Defined steps using both color names (e.g., red) and HEX values (e.g., #FF0000).
  • Configured steps with and without value fields.
  • Changed the order of steps to ensure proper threshold interpretation.
  • Tested with and without value_override.
  • Attempted different min and max settings for the colors section.

None of these approaches resolved the issue. The colors remain static and do not dynamically reflect the defined thresholds or the gradient behavior.

YAML configuration

type: custom:battery-state-card
secondary_info: "{last_changed}"
icon: >-
  mdi:signal-cellular-{state| abs()| lessthan(64,outline)| between(64,128,1)|
  between(128,192,2)| greaterthan(191,3) }
#default_state_formatting: false
#value_override: "{state|thresholds(64,128,192,255)}"
#value_override: "{state| abs()}"
unit: LQI
#round: 0
colors:
  min: 0
  max: 255
  steps:
    - color: red
    - color: yellow
    - color: green
  gradient: true
state_map:
  - from: 0
    to: 0
  - from: 128
    to: 50
  - from: 255
    to: 100
filter:
  include:
    - name: entity_id
      value: sensor.*_linkquality
  exclude:
    - name: entity_id
      value: binary_sensor.*
    - name: entity_id
      value: sensor.2312dra50g*
sort:
  - by: state
    desc: false
collapse: 8
bulk_rename:
  - from: " Linkquality"
  - from: " Signal"
  - from: " strength"
  - from: " Rssi"
  - from: " numeric"
#debug: true

Screenshot
Screenshot 2024-12-11 162108

Version
Card Version: 3.2.1 (Installed via HACS)
Core 2024.12.2
Supervisor 2024.11.4
Operating System 14.0
Frontend 20241127.7

Debug Output from Example Sensor

{
  "entity_id": "sensor.bad_fenster_linkquality",
  "state": "120",
  "attributes": {
    "state_class": "measurement",
    "unit_of_measurement": "lqi",
    "icon": "mdi:signal",
    "friendly_name": "Bad Fenster Linkquality"
  },
  "context": {
    "id": "01JETMQ3AB9KN5830F1NYPNSV4",
    "parent_id": null,
    "user_id": null
  },
  "last_changed": "2024-12-11T10:37:27.755Z",
  "last_updated": "2024-12-11T10:37:27.755Z",
  "display": {
    "entity_id": "sensor.bad_fenster_linkquality",
    "device_id": "68309f1c029fc37dcb8f97cebfc9fb2a",
    "labels": [],
    "platform": "mqtt",
    "entity_category": "diagnostic",
    "name": "Linkquality"
  },
  "device": {
    "area_id": "bad",
    "configuration_url": null,
    "config_entries": [
      "01JDD9Q5J5XY8QTDKA8HSTYDXX"
    ],
    "connections": [],
    "created_at": 1733841376.788037,
    "disabled_by": null,
    "entry_type": null,
    "hw_version": null,
    "id": "68309f1c029fc37dcb8f97cebfc9fb2a",
    "identifiers": [
      [
        "mqtt",
        "zigbee2mqtt_0xa4c138fff7f46111"
      ]
    ],
    "labels": [],
    "manufacturer": "Tuya",
    "model": "Contact sensor (WL-19DWZ)",
    "model_id": null,
    "modified_at": 1733841438.72391,
    "name_by_user": null,
    "name": "Bad Fenster",
    "primary_config_entry": "01JDD9Q5J5XY8QTDKA8HSTYDXX",
    "serial_number": null,
    "sw_version": "0122052017",
    "via_device_id": "4885be2b1f71f0dbc262e14df82076c4"
  },
  "area": {
    "aliases": [],
    "area_id": "bad",
    "floor_id": null,
    "icon": "mdi:shower",
    "labels": [],
    "name": "Bad",
    "picture": null,
    "created_at": 1732391982.411868,
    "modified_at": 1733228755.959435
  }
}

I would greatly appreciate any guidance on how to resolve this issue. If there are additional settings or adjustments I may have overlooked, please let me know!

@MarvinMynx
Copy link
Author

MarvinMynx commented Dec 11, 2024

Converted my Feature Request into this Question and Closed the old Feature Request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant