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
73.24k stars 30.59k forks source link

Entity sensor.smartdry_battery <ESPHome> is using native unit of measurement 'None' <snip> device class ('battery') #86053

Closed KenKilty closed 1 year ago

KenKilty commented 1 year ago

The problem

A possible false positive for an ESPHome device with what I believe is a proper configuration below, note the unit_of_measurement is '%' in the ESPHome YAML. Possible false positive?

sensor:
  - platform: template
    name: "SmartDry Temperature"
    device_class: 'temperature'
    unit_of_measurement: "°C"
    accuracy_decimals: 4
    id: temp_sensor
  - platform: template
    name: "SmartDry Humidity"
    device_class: 'humidity'
    unit_of_measurement: "%"
    accuracy_decimals: 4
    id: hum_sensor
  - platform: template
    name: "SmartDry Shake"
    id: shake_sensor
  - platform: template
    name: "SmartDry Battery"
    device_class: battery
    unit_of_measurement: "%"
    id: batt_sensor

Logs from Core:

Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:980
Integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 7:55:36 PM (2 occurrences)
Last logged: 7:55:52 PM

Entity sensor.smartdry_battery (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) is using native unit of measurement 'None' which is not a valid unit for the device class ('battery') it is using; 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.dryer_dry (<class 'homeassistant.components.template.sensor.SensorTemplate'>) is using native unit of measurement 'None' which is not a valid unit for the device class ('humidity') it is using; 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+template%22

What version of Home Assistant Core has the issue?

Home Assistant 2023.1.4 Supervisor 2022.12.1 Operating System 9.4 Frontend 20230110.0 - latest

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

ESPHome

Link to integration documentation on our website

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

Diagnostics information

config_entry-esphome-41ecba6545e56f31234f565af27c6d4e.json.txt

Example YAML snippet

esphome:
  name: smartdry-hub-esp32

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "REDACTED"

ota:
  password: "REDACTED"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Smartdry-Hub-Esp32"
    password: "REDACTED"

captive_portal:

esp32_ble_tracker:
  on_ble_manufacturer_data_advertise:
    - manufacturer_id: "01AE"
      then:
        - lambda: |-
            id(raw_sensor).publish_state(format_hex(x));
            uint32_t temp = (x[0] + (x[1] << 8) + (x[2] << 16) + (x[3] << 24));
            uint32_t hum = (x[4] + (x[5] << 8) + (x[6] << 16) + (x[7] << 24));
            uint16_t shake = x[8] + (x[9] << 8);
            uint8_t batt = x[10];
            uint8_t wake = x[11];
            id(temp_sensor).publish_state((*(float *) &temp));
            id(hum_sensor).publish_state((*(float *) &hum));
            id(shake_sensor).publish_state(shake);
            id(batt_sensor).publish_state(batt);
            id(wake_sensor).publish_state(wake);

sensor:
  - platform: template
    name: "SmartDry Temperature"
    device_class: 'temperature'
    unit_of_measurement: "°C"
    accuracy_decimals: 4
    id: temp_sensor
  - platform: template
    name: "SmartDry Humidity"
    device_class: 'humidity'
    unit_of_measurement: "%"
    accuracy_decimals: 4
    id: hum_sensor
  - platform: template
    name: "SmartDry Shake"
    id: shake_sensor
  - platform: template
    name: "SmartDry Battery"
    device_class: battery
    unit_of_measurement: "%"
    id: batt_sensor
  - platform: template
    name: "SmartDry Awake"
    id: wake_sensor
text_sensor:
  - platform: template
    name: "SmartDry Raw"
    id: raw_sensor

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (sensor) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `sensor` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign sensor` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


sensor documentation sensor source (message by IssueLinks)

home-assistant[bot] commented 1 year ago

Hey there @ottowinter, @jesserockz, 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` Change the title of 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.

(message by CodeOwnersMention)


esphome documentation esphome source (message by IssueLinks)

TBobsin commented 1 year ago

Hello, same for me with gas

core log: WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.energie_momentan_gas (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) is using state class 'measurement' which is impossible considering device class ('gas') it is using; expected None or one of 'total_increasing', 'total'; 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

If i change the esphome config file from gas to total i get from the validate

sensor.total_daily_energy: [source /config/esphome/espenergy.yaml:230] platform: total_daily_energy name: Energie Gas power_id: id_counter_gas id: id_tde_counter_gas icon: mdi:fire internal: False unit_of_measurement: m³

Unknown value 'total', valid options are '', 'apparent_power', 'aqi', 'battery', 'carbon_dioxide', 'carbon_monoxide', 'current', 'date', 'distance', 'duration', 'energy', 'frequency', 'gas', 'humidity', 'illuminance', 'moisture', 'monetary', 'nitrogen_dioxide', 'nitrogen_monoxide', 'nitrous_oxide', 'ozone', 'pm1', 'pm10', 'pm25', 'power', 'power_factor', 'precipitation_intensity', 'pressure', 'reactive_power', 'signal_strength', 'speed', 'sulphur_dioxide', 'temperature', 'timestamp', 'volatile_organic_compounds', 'voltage', 'volume', 'water', 'wind_speed', 'weight'. device_class: total

PhilippeP62 commented 1 year ago

Same thing with my phone ...

Logger: homeassistant.components.sensor Source: components/sensor/init.py:608 Integration: Sensor (documentation, issues) First occurred: February 13, 2023 at 21:56:30 (1 occurrences) Last logged: February 13, 2023 at 21:56:30

Sensor sensor.mi_9_se_high_accuracy_update_interval has device class None, state class None and unit seconds thus indicating it has a numeric value; however, it has the non-numeric value: (<class 'str'>); 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+mobile_app%22

atx32 commented 1 year ago

Seeing a similar issue with a Konnected alarm panel and ESPHome:

2023-03-02 14:33:02.213 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.alarm_panel_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 ['dBm', 'dB']

csszokolai commented 1 year ago

I have same error: Logger: homeassistant.components.sensor Source: components/sensor/init.py:597 Integration: Érzékelő (documentation, issues) First occurred: 21:10:28 (6 occurrences) Last logged: 21:10:28

Sensor sensor.spathiphyllum_conductivity has device class None, state class measurement and unit µS/cm thus indicating it has a numeric value; however, it has the non-numeric value: unknown (<class 'str'>); Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author. Sensor sensor.spathiphyllum_soil_moisture has device class moisture, state class measurement and unit % thus indicating it has a numeric value; however, it has the non-numeric value: unknown (<class 'str'>); Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author. Sensor sensor.spathiphyllum_temperature has device class temperature, state class measurement and unit °C thus indicating it has a numeric value; however, it has the non-numeric value: unknown (<class 'str'>); Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author. Sensor sensor.spathiphyllum_air_humidity has device class humidity, state class measurement and unit % thus indicating it has a numeric value; however, it has the non-numeric value: unknown (<class 'str'>); Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author. Sensor sensor.spathiphyllum_ppfd_mol has device class None, state class measurement and unit mol/s⋅m² thus indicating it has a numeric value; however, it has the non-numeric value: unknown (<class 'str'>); Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

atx32 commented 1 year ago

Still occurring with 2023.6.1 for signal_strength:

2023-06-12 20:44:55.578 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.alarm_panel_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

bdraco commented 1 year ago

Still occurring with 2023.6.1 for signal_strength:

2023-06-12 20:44:55.578 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.alarm_panel_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 home-assistant/core/issues (is:open label:"integration: esphome")

% is not a valid unit for signal strength. This error is correct

tefracky commented 1 year ago

I am using the code from the example and I have the same error: https://esphome.io/components/sensor/wifi_signal.html

Either your code or the documentation is wrong.

heythisisnate commented 1 year ago

FWIW I think that % is a valid unit for signal strength. Although not technically precise, it is a commonly approximated measurement because dBm stated as a negative number is difficult for many people to understand. WiFi signal strength on iOS and Android is commonly expressed in "bars" which in essence is a visual representation of percent.

Also the fact that this example in the ESPHome documentation is the source of (at least some) of the warning messages here.