konnected-esphome icon indicating copy to clipboard operation
konnected-esphome copied to clipboard

WiFi Signal % is using the wrong `device_class`

Open ptr727 opened this issue 10 months ago • 0 comments

HA reports:

Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:709
integration: Sensor (documentation, issues)
First occurred: 6:25:07 PM (1 occurrences)
Last logged: 6:25:07 PM

Entity sensor.konnected_f0f5bd51a9e0_wifi_signal_2 (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) is using native unit of measurement '%' which is not a valid unit for the device class ('signal_strength') it is using; expected one of ['dB', 'dBm']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+esphome%22

In code:

  - platform: copy
    source_id: wifi_signal_db
    id: wifi_signal_pct
    name: WiFi Signal %
    filters:
      - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
    unit_of_measurement: "%"
    entity_category: diagnostic

WiFi signal is copied from source with a device class that requires dB as unit.
Set an explicit device class to make HA happy.

E.g. in ESPHome docs the device class of the % is set to "":

  - platform: copy # Reports the WiFi signal strength in %
    source_id: wifi_signal_db
    name: "WiFi Signal Percent"
    filters:
      - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
    unit_of_measurement: "Signal %"
    entity_category: "diagnostic"
    device_class: ""

ptr727 avatar Jan 28 '25 02:01 ptr727