benleb / sureha

SureHA 🐾 monitor & control your Sure Petcare devices via Home Assistant
Apache License 2.0
21 stars 12 forks source link

Battery Level -> state differs from attribute #51

Open ChristophCaina opened 10 months ago

ChristophCaina commented 10 months ago

The State of the Battery Entity is different to the attribute "battery level"

grafik

Also, the for the state the UnitOfMeasurement is missing.

MechEng70 commented 10 months ago

The "Sure Petcare" HA addon is able to display the battery levels. Can confirm that they are broken in Sure HA

If you want to add them back, you can use template helpers.

Helpers - Template -> sensor. Use this for the template section: {{ state_attr('sensor._battery_level','battery_level')}} % and Battery and measurement.

This will get you the bettery percentage for graphs or automations (need to change those though)

ChristophCaina commented 10 months ago

The problem here is, that the package you install via HACS has an older code base. The files which are available here in the repo are newer than what you install through HACS...

So I would recommend to update the files with the ones provided here then, you should see the battery value (without a unit of measurement) ... and it is reporting a different value than the attribute (as you can see in my screenshots)...

BUT: With the files replaced, you will also get some deprication warnings in HomeAssistant with the 2024.1. release... I've submitted some PRs to address this... they just needs to be changed.

The major problem here is, that it seems, that:

  1. the repo is not really up to date -> manifest.json still pointing to an older surepy version, instead of the 0.9.0
  2. the install package (release) is still older than the source
  3. no updates for two years on the source codes

Right now, I am using this integration + the core integration in parallel, since the core integration does provide LOCK entities... This integration "just" provides a sensor, showing the current lock state - but has other advantages compared to the core integration, such as the device_tracker for the pets and the extended attributes.

I would consider, to refactor the code - according to the HA documentation some information given in the attributes should be their own sensors...

Yet - I was not able to dive into the code deep enough to provide more changes than the submitted PRs for compatibility with the upcomming 2024.1 Version of HA.

MechEng70 commented 10 months ago

How is that possible when the version on HACS is the 0.4.2 version that is on here?

ChristophCaina commented 10 months ago

I can't explain how it is possible, but it is also mentioned here: #31

ChristophCaina commented 10 months ago

after observing the battery state for some time, it seems, that there's a gap of around 10% between the sensors state and its attribute. grafik

ChristophCaina commented 4 months ago

unfortunately, still an issue. could this be related to the settings for the "battery options"? image