NorthernMan54 / homebridge-rtl

Homebridge Plugin for rtl_433 devices
MIT License
22 stars 10 forks source link

Deactivate battery warning in Home app #10

Open freinbichler opened 3 years ago

freinbichler commented 3 years ago

I have successfully added a thermometer, however the device reports a battery level of 0 and therefore a warning is constantly displayed in the Home app. Is there a way to disable the battery level or hardcode it to 100%?

NorthernMan54 commented 3 years ago

It should be handled automatically if the device doesn't return a value for battery

https://github.com/NorthernMan54/homebridge-rtl/blob/a433e4d6f4a2102bb18e57888eabd7d39f247394/sensor.js#L156

What does the message for your device look like ?

freinbichler commented 3 years ago

Thanks, I saw that part in the code, however my device reports a battery value of 0, not undefined.

NorthernMan54 commented 3 years ago

So the code is working as designed, just your device has a borked design and returns a battery value of zero even though the battery is okay ( is their a chance with your device 0 is okay and a different value is low battery ? )

If you want to add a config option to ignore battery values, I can merge a pull request.

freinbichler commented 3 years ago

Yes, for this one device which reported battery 0 the code works as designed and the device is the problem.

However, I have now added another device which reports battery levels between 0 and 100 (percentage). It reports a battery level of 95 and in the home app it is shown as "low battery", because the code doesn't check for battery levels reported like this. I have checked the rtl_433_tests repository which contains a lot of signal recordings and found that some other devices also report battery levels like this.

So there seem to be 3 ways of battery reporting:

Here is my sensor:

time      : 2021-05-11 13:28:54
model     : Inkbird ITH-20R                        id        : 41592
Battery   : 95           sensor_num: 8             Integrity : CRC
Temperature: 25.9 C      Temperature2: -1623.8 C   Humidity  : 0.1 %

The example from the repo: https://github.com/merbanan/rtl_433_tests/blob/f13628c524dd228299bc52c1b94082bea515302d/tests/IKEA_Sparsnas/01/g004_867.95M_250k.json

NorthernMan54 commented 3 years ago

If you want to submit a pull request with this advanced logic for battery I would gladly review and merge it. As I don't have a device with this behaviour it may take a while to get to it.