gcobb321 / icloud3

iCloud3 v3 - iCloud3 is an advanced iDevice tracker that uses Apple iCloud account and HA Companion App data for presence detection and location based automations.
MIT License
546 stars 54 forks source link

set correct `state_class` value #281

Closed JeanMertz closed 12 months ago

JeanMertz commented 12 months ago

state_class can be one of measurement, total or total_increasing.

It was incorrectly set to battery.

See: https://developers.home-assistant.io/docs/core/entity/sensor/#available-state-classes

Choosing measurement is based on its description, and also this part of the description for the total variant:

This (total) state class should not be used for sensors where the absolute value is interesting instead of the accumulated growth or decline, for example remaining battery capacity or CPU load; in such cases state class measurement should be used instead.

I ran into this as I was working on a hass library in Rust, which tries to codify all relevant types, including device_class (which does have a battery variant), and state_class (which does not).

gcobb321 commented 12 months ago

This change will be made to the master sensor.py on my local computer and incorporated in the next update. It fails to pass several HA checks which, if configured, creates other poblems.