home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.94k stars 29.02k forks source link

Entity sensor.athom plugplug_v2_*_wifi_strength using unit of measurement '%' not a valid unit - expected 'dBm'/'dB' #114205

Closed smart-shed closed 3 months ago

smart-shed commented 3 months ago

The problem

Home assistant logs show:

"Entity sensor.athom_smart_plug_v2_a78c29_wifi_strength (<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 ['dBm', 'dB']; 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"

These are new to me, ESP is new to me, so i used basic defaults, it all works though. New devices this month so unknown last working home assistant version.

ESPHome web on the device shows: "WiFi Strength | 88 %" seems fine but shows no 'Wifi signal' or variation of 'signal strength' in the ESPHome web gui

Home assistant/dev tools/states/device YAML shows this and seems fine:

state_class: measurement unit_of_measurement: "%" device_class: signal_strength friendly_name: Smart Plug 3 WiFi Strength

which in home assistant device info shows expected: "WiFi Strength 88%" and is working.

I have 3x new Athom Smart Plug V2's recently doing the same thing. I think its to do with this part of the backend templated defaults which arent specified in the actual ESPHome adopt/cfg section:

ESPHome yaml config if i click ESPHome/device/EDIT (athom-smart-plug-v2-a7f8a4.yaml):

substitutions: name: athom-smart-plug-v2-a7f8a4 friendly_name: Smart Plug 3 packages: Athom_Technology.Smart_Plug_V2: github://athom-tech/athom-configs/athom-smart-plug-v2.yaml esphome: name: ${name} name_add_mac_suffix: false friendly_name: ${friendly_name} api: encryption: key: DVbAu0LDmQjhxWAufsN+1EhZ1n/vHstrVavIddcpewM=

wifi: ssid: !secret wifi_ssid password: !secret wifi_password

This is from ESPHome/device/three dots/validate and copy the console running yaml config (partial):

sensor:

It seems to use the device_class: signal_strength correctly and uses the lambda calculation based of the prior wifi_signal_db so its all functioning as intended just that home assistant thinks it should be a db value instead of the calcualted % value, so the fix would be remove the log entry not change the variable as we already have the "wifi_signal_db" db and calculate the "signal_strength" % from it.

current release software on default green hardware.

What version of Home Assistant Core has the issue?

2024.3.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

ESPHome

Link to integration documentation on our website

https://www.home-assistant.io/integrations/esphome

Diagnostics information

config_entry-esphome-fb266b6288687cd78c7985ea1ec079bd.json

Example YAML snippet

default esphome cfg from adopting new athom smart plug v2:

INFO ESPHome 2024.3.0
INFO Reading configuration /config/esphome/athom-smart-plug-v2-a78c29.yaml...
substitutions:
  name: athom-smart-plug-v2-a78c29
  friendly_name: Washer
  room: ''
  device_description: athom smart plug v2
  project_name: Athom Technology.Smart Plug V2
  project_version: 2.0.1
  relay_restore_mode: RESTORE_DEFAULT_OFF
  sensor_update_interval: 10s
  current_limit: '16'
  dns_domain: ''
  timezone: ''
  wifi_fast_connect: 'false'
esphome:
  name: athom-smart-plug-v2-a78c29
  friendly_name: Washer
  area: ''
  name_add_mac_suffix: false
  min_version: 2024.2.1
  project:
    name: Athom_Technology.Smart_Plug_V2
    version: 2.0.1
  build_path: build/athom-smart-plug-v2-a78c29
  platformio_options: {}
  includes: []
  libraries: []
esp8266:
  board: esp8285
  restore_from_flash: true
  framework:
    version: 3.0.2
    source: ~3.30002.0
    platform_version: platformio/espressif8266@3.2.0
  early_pin_init: true
  board_flash_mode: dout
preferences:
  flash_write_interval: 5min
api:
  encryption:
    key: 6O7XrfusjriM2N51TkGYup/4v33mIKtsViFWA7HmjrA=
  port: 6053
  password: ''
  reboot_timeout: 15min
ota:
  safe_mode: true
  version: 2
  port: 8266
  reboot_timeout: 5min
  num_attempts: 10
logger:
  baud_rate: 0
  tx_buffer_size: 512
  deassert_rts_dtr: false
  hardware_uart: UART0
  level: DEBUG
  logs: {}
  esp8266_store_log_strings_in_flash: true
mdns:
  disabled: false
  services: []
web_server:
  port: 80
  version: 2
  enable_private_network_access: true
  include_internal: false
  ota: true
  log: true
  css_url: ''
  js_url: https://oi.esphome.io/v2/www.js
wifi:
  ap:
    ap_timeout: 1min
  fast_connect: false
  domain: ''
  reboot_timeout: 15min
  power_save_mode: NONE
  output_power: 20.0
  passive_scan: false
  enable_on_boot: true
  networks:
  - ssid: jabb-i
    password: notrealpassword
    priority: 0.0
  use_address: athom-smart-plug-v2-a78c29
captive_portal: {}
dashboard_import:
  package_import_url: github://athom-tech/athom-configs/athom-smart-plug-v2.yaml
  import_full_config: false
uart:
- rx_pin:
    number: 3
    mode:
      input: true
      output: false
      open_drain: false
      pullup: false
      pulldown: false
      analog: false
    inverted: false
  baud_rate: 4800
  rx_buffer_size: 256
  stop_bits: 1
  data_bits: 8
  parity: NONE
globals:
- id: total_energy
  type: float
  restore_value: true
  initial_value: '0.0'
binary_sensor:
- platform: status
  name: Status
  entity_category: diagnostic
  disabled_by_default: false
  device_class: connectivity
- platform: gpio
  pin:
    number: 5
    mode:
      input: true
      pullup: true
      output: false
      open_drain: false
      pulldown: false
      analog: false
    inverted: true
  name: Power Button
  disabled_by_default: true
  on_multi_click:
  - timing:
    - state: true
      min_length: 0ms
      max_length: 1s
    - state: false
      min_length: 200ms
    then:
    - switch.toggle:
        id: relay
    invalid_cooldown: 1s
  - timing:
    - state: true
      min_length: 4s
    then:
    - button.press:
        id: Reset
    invalid_cooldown: 1s
sensor:
- platform: uptime
  name: Uptime Sensor
  id: uptime_sensor
  entity_category: diagnostic
  internal: true
  disabled_by_default: false
  force_update: false
  unit_of_measurement: s
  icon: mdi:timer-outline
  accuracy_decimals: 0
  device_class: duration
  state_class: total_increasing
  update_interval: 60s
- platform: wifi_signal
  name: WiFi Signal
  id: wifi_signal_db
  update_interval: 60s
  entity_category: diagnostic
  internal: true
  disabled_by_default: false
  force_update: false
  unit_of_measurement: dBm
  accuracy_decimals: 0
  device_class: signal_strength
  state_class: measurement
- platform: copy
  source_id: wifi_signal_db
  name: WiFi Strength
  filters:
  - lambda: !lambda |-
      return min(max(2 * (x + 100.0), 0.0), 100.0);
  unit_of_measurement: '%'
  entity_category: diagnostic
  disabled_by_default: false
  force_update: false
  accuracy_decimals: 0
  device_class: signal_strength
  state_class: measurement
- platform: cse7766
  current:
    name: Current
    filters:
    - throttle_average: 10s
    - lambda: !lambda |-
        if (x < 0.060) return 0.0; else return x;
    on_value_range:
    - above: 16.0
      then:
      - switch.turn_off:
          id: relay
    disabled_by_default: false
    force_update: false
    unit_of_measurement: A
    accuracy_decimals: 2
    device_class: current
    state_class: measurement
  voltage:
    name: Voltage
    filters:
    - throttle_average: 10s
    disabled_by_default: false
    force_update: false
    unit_of_measurement: V
    accuracy_decimals: 1
    device_class: voltage
    state_class: measurement
  power:
    name: Power
    id: power_sensor
    filters:
    - throttle_average: 10s
    - lambda: !lambda |-
        if (x < 3.0) return 0.0; else return x;
    disabled_by_default: false
    force_update: false
    unit_of_measurement: W
    accuracy_decimals: 1
    device_class: power
    state_class: measurement
  energy:
    name: Energy
    id: energy
    unit_of_measurement: kWh
    filters:
    - throttle: 10s
    - multiply: 0.001
    on_value:
    - then:
      - lambda: !lambda |-
          static float previous_energy_value = 0.0;
          float current_energy_value = id(energy).state;
          id(total_energy) += current_energy_value - previous_energy_value;
          previous_energy_value = current_energy_value;
          id(total_energy_sensor).update();
    disabled_by_default: false
    force_update: false
    accuracy_decimals: 3
    device_class: energy
    state_class: total_increasing
- platform: template
  name: Total Energy
  id: total_energy_sensor
  unit_of_measurement: kWh
  device_class: energy
  state_class: total_increasing
  icon: mdi:lightning-bolt
  accuracy_decimals: 3
  lambda: !lambda |-
    return id(total_energy);
  update_interval: 4294967295
  disabled_by_default: false
  force_update: false
- platform: total_daily_energy
  name: Total Daily Energy
  restore: true
  power_id: power_sensor
  unit_of_measurement: kWh
  accuracy_decimals: 3
  filters:
  - multiply: 0.001
  disabled_by_default: false
  force_update: false
  device_class: energy
  state_class: total_increasing
  method: right
button:
- platform: restart
  name: Restart
  entity_category: config
  disabled_by_default: false
  device_class: restart
- platform: factory_reset
  name: Factory Reset
  id: Reset
  entity_category: config
  disabled_by_default: false
  icon: mdi:restart-alert
  device_class: restart
- platform: safe_mode
  name: Safe Mode
  internal: false
  entity_category: config
  disabled_by_default: false
  icon: mdi:restart-alert
  device_class: restart
switch:
- platform: gpio
  name: Switch
  pin:
    number: 12
    mode:
      output: true
      input: false
      open_drain: false
      pullup: false
      pulldown: false
      analog: false
    inverted: false
  id: relay
  restore_mode: RESTORE_DEFAULT_OFF
  disabled_by_default: false
  interlock_wait_time: 0ms
light:
- platform: status_led
  name: Status LED
  id: blue_led
  disabled_by_default: true
  pin:
    inverted: true
    number: 13
    mode:
      output: true
      input: false
      open_drain: false
      pullup: false
      pulldown: false
      analog: false
  restore_mode: ALWAYS_OFF
text_sensor:
- platform: wifi_info
  ip_address:
    name: IP Address
    entity_category: diagnostic
    disabled_by_default: false
    update_interval: 1s
  ssid:
    name: Connected SSID
    entity_category: diagnostic
    disabled_by_default: false
    update_interval: 1s
  mac_address:
    name: Mac Address
    entity_category: diagnostic
    disabled_by_default: false
- platform: template
  name: Last Restart
  id: device_last_restart
  icon: mdi:clock
  entity_category: diagnostic
  disabled_by_default: false
  update_interval: 60s
- platform: template
  name: Uptime
  entity_category: diagnostic
  lambda: !lambda |-
    int seconds = (id(uptime_sensor).state);
    int days = seconds / (24 * 3600);
    seconds = seconds % (24 * 3600);
    int hours = seconds / 3600;
    seconds = seconds % 3600;
    int minutes = seconds /  60;
    seconds = seconds % 60;
    if ( days > 3650 ) {
      return { "Starting up" };
    } else if ( days ) {
      return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
    } else if ( hours ) {
      return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
    } else if ( minutes ) {
      return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
    } else {
      return { (String(seconds) +"s").c_str() };
    }
  icon: mdi:clock-start
  disabled_by_default: false
  update_interval: 60s
time:
- platform: sntp
  id: sntp_time
  timezone: ''
  update_interval: 360min
  on_time_sync:
  - then:
    - if:
        condition:
          lambda: !lambda |-
            return id(device_last_restart).state == "";
        then:
        - text_sensor.template.publish:
            id: device_last_restart
            state: !lambda |-
              return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");
  servers:
  - 0.pool.ntp.org
  - 1.pool.ntp.org
  - 2.pool.ntp.org
output: []

INFO Configuration is valid!

Anything in the logs that might be useful for us?

Main log header info:

Log details (WARNING)
Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:737
integration: Sensor (documentation, issues)
First occurred: March 25, 2024 at 11:04:21 PM (3 occurrences)
Last logged: March 25, 2024 at 11:04:21 PM

Entity sensor.athom_smart_plug_v2_a78c29_wifi_strength (<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 ['dBm', 'dB']; 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
Entity sensor.athom_smart_plug_v2_a7f8a4_wifi_strength (<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 ['dBm', 'dB']; 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
Entity sensor.athom_smart_plug_v2_a78a6b_wifi_strength (<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 ['dBm', 'dB']; 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

Additional information

new user to ESPHome so i havent fiddled/got custom, just checking logs to clean up issues.

home-assistant[bot] commented 3 months ago

Hey there @ottowinter, @jesserockz, @kbx81, @bdraco, mind taking a look at this issue as it has been labeled with an integration (esphome) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `esphome` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign esphome` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


esphome documentation esphome source (message by IssueLinks)

joostlek commented 3 months ago

Signal strength device class requires the unit of measurement to be in decibels. If that isn't doable, the entity should not be marked as signal strength device class.

smart-shed commented 3 months ago

sure does. so then maybe the work around here thats still required is to remove this from home assistant so i dont waste my time doing what it tells me to do for no result: see the very last line.

Logger: homeassistant.components.sensor Source: components/sensor/init.py:737 integration: Sensor (documentation, issues) First occurred: March 25, 2024 at 11:04:21 PM (3 occurrences) Last logged: March 25, 2024 at 11:04:21 PM

Entity sensor.athom_smart_plug_v2_a78c29_wifi_strength (<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 ['dBm', 'dB']; 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