oyvindwe / connectlife-ha

ConnectLife integration for Home Assistant
GNU General Public License v3.0
62 stars 24 forks source link

Energy consumption not shown correctly #125

Closed enrico1036 closed 2 months ago

enrico1036 commented 2 months ago

I'm using device 009-100 and I want to know device's daily energy consumption. I run dump and I can see the same value reported by ConnectLife App. This is the dump: 009-100.json The problem is when the consumption is below 1. In home assistant I can only view the integer part of the number. Not the decimals. Since this is a daily consumption it will reset every day resulting to be always 0 or sometimes 1 at the end of the day. I tried to scroll the source code but I cannot find an explicit cast to integer. How can this be fixed? I can create the pull request and test on my own but I need help if you can point me to the right place in source code.

Thanks

oyvindwe commented 2 months ago

Ah - this is the first time I have seen a value above 0 for daily_energy_kwh - I'll look into parsing it as a decimal number instead of integer!

oyvindwe commented 2 months ago

This had to be fixed in the upstream library: https://github.com/oyvindwe/connectlife/pull/17

oyvindwe commented 2 months ago

Fixed in version 0.18.1

enrico1036 commented 2 months ago

Perfect! I tested it and works good. Thanks for the fast fix and for the whole work you did in this integration. If you agree, later I'll create a PR to update data dictionary and set daily_energy_kwh state_class to total_increasing, kWh

oyvindwe commented 2 months ago

Ah, yes, this should be total_increasing and kWh. I have seen this property on all devices I have received JSON dumps for - would you care to update all the mapping files?

enrico1036 commented 2 months ago

@oyvindwe Sure, I can do it. Do you think is better to update all the data_dictionaries containing daily_energy_kwh or just the 009-100 where it is used for sure? In all other dumps I see 0 as value. And, always referring to 009-100, there are lot of sensors that are always 0 and unused (I guess). Should I disable them? In the same PR or a separate one?

oyvindwe commented 2 months ago

@enrico1036 That is a fair point. I suggest you make a PR with all the changes for 009-100 first.

daily_energy_kwh is also the only property I've seen that is a number and not a string on JSON, so it is clearly different from all other properties. Perhaps is should be treated in a generic way, but that would require some code change.