core: state_class missing for Android battery sensors after Home Assistant core update or restart

The problem

The state_class attribute for the battery_level, battery_temperature and battery_power sensors of my Android phone has disappeared since Home Assistant 2022.12.

This causes the sensor data to be now longer recorded into the long term statistics.

afbeelding

I have confirmed that the state_class attribute reappears when downgrading Home Assistant to 2022.11.5.

What version of Home Assistant Core has the issue?

core-2022.12.1

What was the last working version of Home Assistant Core?

core-2022.11.5

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Mobile App

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 36 (10 by maintainers)

Most upvoted comments

For me it helped to set the state_class manually in the configuration.yaml. It took some time but now i have statistics for my android devices:

homeassistant:
  customize:
    sensor.redmi10_battery_level:
      state_class: measurement

83716-statistics-for-android

Seeing same issue again.

Last date for getting state was just prior update: https://ss.codeone.pl/ss-2023-06-13-22-30-49-1686688249-aTMenRla.png And after that: https://ss.codeone.pl/ss-2023-06-13-22-31-26-1686688286-EfruXX0W.png

Same for battery temperature as well as other sensors from phone (OnePlus LE2123)

For a long time, including the last version I am getting the following warnings in the logs:

2023-04-24 14:52:11.795 WARNING (MainThread) [homeassistant.components.sensor] Sensor sensor.mobile_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: full (<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

I am using:

  • Home Assistant Core 2023.4.6
  • Frontend 20230411.1 - latest
  • Home assistant companion app 2023.3.0-full on Android 13

Can this please get fixed?

Suffering from this for months, being redirected from https://github.com/home-assistant/android/issues/2847#issuecomment-1346869360.

Now that the entity popup only shows statistics and not the raw data anymore, thanks to this bug NOTHING is shown for affected entities (in short: things got worse):

image

image