Closed renestein closed 4 years ago
@CodeBardian Thanks for your kind words. My three HS110 devices do not return the 'energy' property at all and 'energy_wh' property returns watt (hours)/ I am not sure if there is some device with ''energy' property that contains value in 'kWh' Oficial Kasa application for Android shows value in kWh, so the value is likely converted in the application.
I just checked the output of my HS110 again. It returns the energy
property in kWh. That's why I wrote it that way :)
It depends on the hardware version of the plug. mine is an old one, yours will probably be version 2.
I already mapped power values to kWh for the current power consumption (shown below), so I suggest it should be done here too https://github.com/CodeBardian/tplink-smartdevices-netstandard/blob/3169be6299bed60f226d7e079c6eb992046ef52a/tplink-smartdevices/Data/PowerData.cs#L38-L41
My HS 110 plugs have HW revision 4.0. Firmaware version: 1.0.4 As you have suggested, if the presence of the property 'energy_wh' means newer HW revision and data in wh, it is better to convert a value in the energy_wh to kWh. And I will change the PR. I hope that the following combinations do not appear in the wild: Property 'energy' with wh value. Property 'energy_wh' with kWh value.
Done.
Thanks again. I didn't even know hardware versions up to 4.0 exist. Hopefully nothing else is different on them. Anyway, I'll merge this for now.
Thanks for your contribution! I'm not quite sure about the units of measurement at the moment. If
month_stat.energy
returns kilowatthours, it should bemonth_stat.energy_wh / 1000d
to keep the units consistent. Otherwise if both return watthours, i am happy to accept this PR as it is.