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
72.76k stars 30.47k forks source link

Error in log for iPhones: iphone_battery_state has device class battery, state class None and unit None thus indicating it has a numeric value; however, it has the non-numeric value... #87410

Closed grantalewis closed 1 year ago

grantalewis commented 1 year ago

The problem

Seeing this entry in the logs:

2023-02-04 11:14:35.200 WARNING (MainThread) [homeassistant.components.sensor] Sensor sensor.<redacted>_iphone_battery_state has device class battery, state class None and unit None thus indicating it has a numeric value; however, it has the non-numeric value: Not Charging (<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

(note that a portion of the actual entity name has been <redacted> in the above)

What version of Home Assistant Core has the issue?

2023.2.0

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

No response

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

See above

Additional information

No response

epenet commented 1 year ago

The device class should be removed.

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 (mobile_app) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `mobile_app` 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 mobile_app` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


mobile_app documentation mobile_app source (message by IssueLinks)

GitHubxtsnl commented 1 year ago

I'm having the same issue. running: Home Assistant 2023.2.2 Supervisor 2023.01.1 Operating System 9.5

Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:608
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: 3:11:18 PM (2 occurrences)
Last logged: 3:11:18 PM

Sensor sensor.<removed>_battery_state has device class battery, state class None and unit None thus indicating it has a numeric value; however, it has the non-numeric value: Not Charging (<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
Sensor sensor.<removed>_battery_state_4 has device class battery, state class None and unit None thus indicating it has a numeric value; however, it has the non-numeric value: Not Charging (<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
epenet commented 1 year ago

I'm having the same issue. running: Home Assistant 2023.2.2 Supervisor 2023.01.1 Operating System 9.5

Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:608
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: 3:11:18 PM (2 occurrences)
Last logged: 3:11:18 PM

Sensor sensor.<removed>_battery_state has device class battery, state class None and unit None thus indicating it has a numeric value; however, it has the non-numeric value: Not Charging (<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
Sensor sensor.<removed>_battery_state_4 has device class battery, state class None and unit None thus indicating it has a numeric value; however, it has the non-numeric value: Not Charging (<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

You need to remove the invalid device class.

Icexist commented 1 year ago

Same here on android using mobile_app.

If I have done no manual configuration of the mobile app integration, what device class is there to remove?

Icexist commented 1 year ago

I think this issue should be renamed more generally since it's not just battery_state and not just iPhone mobile app. It seems like there are a bunch of different sensors that have this issue with the mobile_app integration.

Seems like all sensors in mobile_app need to be updated to include the correct state class and device class or the respective apps need to update.

Home Assistant 2023.2.2
Supervisor 2023.01.1
Operating System 9.5
Frontend 20230202.0 - latest
Logger: homeassistant.components.sensor.recorder
Source: components/sensor/recorder.py:382 
Integration: Sensor (documentation, issues) 
First occurred: February 7, 2023 at 12:35:10 AM (1 occurrences) 
Last logged: February 7, 2023 at 12:35:10 AM

Entity sensor.<>_phone_app_rx_gb from integration mobile_app has state class total_increasing, but its state is not strictly increasing. Triggered by state 0.019 (0.0191) with last_updated set to 2023-02-07T08:32:23.031399+00:00. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mobile_app%22

Related: https://github.com/home-assistant/iOS/issues/2277 https://github.com/home-assistant/android/issues/3202

erik3rik commented 1 year ago

You need to remove the invalid device class

This comes automatically from the non-community integrations and the moble app. The sensors are automatically set up by Home Assistant / the app. So not even the core developers of such things can keep track of all the changes. There are many cases where we are encouraged to contact the external developers of whatever-integration-that-is-missbehaving and they often get the blame for not following (the ever breaking-changing) docs. This time the Home Assistant App was unable to follow the docs of Home Assistant, I guess...

wmn79 commented 1 year ago

Same here with a Pixel 5 on Android 13 using the Android mobile app.

Sensor sensor.pixel_5_batterij_status has device class battery, state class None and unit None thus indicating it has a numeric value; however, it has the non-numeric value: charging (<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
julessilve commented 1 year ago

I have the same errors on my HAos phone sensor: 2023-03-05 18:58:24.639 WARNING (MainThread) [homeassistant.components.sensor] Sensor sensor.jules_galaxy_a12_battery_state has device class battery, state class None and unit None thus indicating it has a numeric value; however, it has the non-numeric value: discharging (<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...

but also on all these sensors too: 2023-03-05 18:58:24.652 WARNING (MainThread) [homeassistant.components.sensor] Sensor sensor.zeem_galaxy_battery_state has device class battery, state class None and unit None thus indicating it has a numeric value; however, it has the non-numeric value: charging (<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... 2023-03-05 19:03:11.979 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.tasmota_energy_apparentpower (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using native unit of measurement 'VA' which is not a valid unit for the device class ('power') it is using; expected one of ['W', 'kW']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues... 2023-03-05 19:03:11.983 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.tasmota_energy_today (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using native unit of measurement 'kWh' which is not a valid unit for the device class ('power') it is using; expected one of ['W', 'kW']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues... 2023-03-05 19:03:11.986 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.tasmota_energy_yesterday (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using native unit of measurement 'kWh' which is not a valid unit for the device class ('power') it is using; expected one of ['W', 'kW']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues... 2023-03-05 19:03:11.990 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.tasmota_energy_total (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using native unit of measurement 'kWh' which is not a valid unit for the device class ('power') it is using; expected one of ['W', 'kW']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues... 2023-03-05 19:03:11.994 WARNING (MainThread) [homeassistant.components.sensor] Sensor sensor.tasmota_energy_totalstarttime has device class None, state class None and unit thus indicating it has a numeric value; however, it has the non-numeric value: 2022-02-03T14:31:51 (<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... 2023-03-05 19:03:17.990 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.sonoffpowr2wh1_energy_reactivepower (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using native unit of measurement 'VAr' which is not a valid unit for the device class ('power') it is using; expected one of ['W', 'kW']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues... 2023-03-05 19:03:17.999 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.sonoffpowr2wh1_energy_apparentpower (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using native unit of measurement 'VA' which is not a valid unit for the device class ('power') it is using; expected one of ['W', 'kW']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues... 2023-03-05 19:03:18.002 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.sonoffpowr2wh1_energy_today (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using native unit of measurement 'kWh' which is not a valid unit for the device class ('power') it is using; expected one of ['W', 'kW']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues... 2023-03-05 19:03:18.006 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.sonoffpowr2wh1_energy_yesterday (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using native unit of measurement 'kWh' which is not a valid unit for the device class ('power') it is using; expected one of ['W', 'kW']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues... 2023-03-05 19:03:18.009 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.sonoffpowr2wh1_energy_total (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using native unit of measurement 'kWh' which is not a valid unit for the device class ('power') it is using; expected one of ['W', 'kW']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues... 2023-03-05 19:03:18.012 WARNING (MainThread) [homeassistant.components.sensor] Sensor sensor.sonoffpowr2wh1_energy_totalstarttime has device class None, state class None and unit thus indicating it has a numeric value; however, it has the non-numeric value: 2022-02-03T15:39:00 (<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...

The problem has persisted for at least 4 weeks thru last months version. i was hoping this version would fix the problem: Home Assistant 2023.3.1 Supervisor 2023.01.1 Operating System 9.5 Frontend 20230302.0 - latest

Sarnog commented 1 year ago

I got this error as well with high accuracy update interval and buienradar.

Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:597
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: 19:20:03 (2 occurrences)
Last logged: 19:20:17

Sensor sensor.nancy_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
Sensor sensor.buienalarm_next_rain_forecast_min has device class None, state class None and unit min 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 create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+template%22
teskanoo commented 1 year ago

bump - over a month now - this is out of our control - I'm willing to try to add the following customization to [attempt to] suppress the error, but this should be a quick fix for the developers

sensor.phone_xxx_battery_state:
      friendly_name: Xxx Phone Battery State
      # https://github.com/home-assistant/core/issues/87410
      device_class: enum
antonio-fiol commented 1 year ago

Indeed, same error without having customized the integration. Android.

Sensor sensor.sm_j510fn_battery_state has device class battery, state class None and unit None thus indicating it has a numeric value; however, it has the non-numeric value: discharging (<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 
bakerkj commented 1 year ago

I am having the same issue with 2023.5.2

2023-05-08 16:42:34.964 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up mobile_app platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 579, in state
    numerical_value = int(value)
ValueError: invalid literal for int() with base 10: 'Not Charging'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 312, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 455, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 731, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 846, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 585, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 649, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 591, in _stringify_state
    if (state := self.state) is None:
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 583, in state
    raise ValueError(
ValueError: Sensor sensor.<redacted>_iphone_battery_state has device class battery, state class None unit None and suggested precision None thus indicating it has a numeric value; however, it has the non-numeric value: Not Charging (<class 'str'>)
Xitro01 commented 1 year ago

2023.5.4 and still an issue. Any devs that have an update on this? This is going on for almost 4 months now.

SamuelCarson commented 1 year ago

still a problem on 2023.5.4. Please get someone assigned to this and get it fixed

erik3rik commented 1 year ago

It will not get fixed. Since it kind of is, already. But the problem is that it was not fixed properly.

As per my observation there is already a fix applied. Fix, as in that the problem will not occur again. Thus devs don't see the problem and it cannot really be replicated and no attention will be given to it. But the fix did not retroactively fix the problem for the people that already had the problem. So that you will have to do yourself.

The problem gets solved if you take note of the entity id's that have these errors, and delete them. Some will then get re-created if they are still provided by the integration. And when re-created, they will have the correct options applied to them. Sad to see that it was "fixed" in such a sloppy way.

grantalewis commented 1 year ago

The problem gets solved if you take note of the entity id's that have these errors, and delete them.

Is the suggestion to remove the entity (for example, sensor.stevejobs_iphone_battery_state) or the entire device? When I try to remove just the entity, I see:

Only 0 selected entities can be removed. You can only remove 0 of the selected 1 entities. Entities can only be removed when the integration is no longer providing the entities. Sometimes you have to restart Home Assistant before you can remove the entities of a removed integration....

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.

ti-mo commented 1 year ago

Still an issue as of 2023.9.2. This is polluting my logs. Any workarounds available in the short term?

erik3rik commented 1 year ago

If you would just read my comment 2 posts up. The workaround was mentioned there. You will have to do this yourself, there is no other fix to this problem and it will not be in the future either as it is considered to be fixed already.

julessilve commented 1 year ago

Thank you erik3rik. However it is not clear "How" to actually delete the entity id's. I have tried and I was not able. Please share if you know how to complete the operation you have suggested.

erik3rik commented 1 year ago

Copy the problematic entity id from the logs, go to entities, search for the entity with that id, click the entity, click the cogs-icon and then delete.