Add energy sensors to outdoor plug
Add total and daily energy sensors to the outdoor plug.
As requested here https://github.com/SecKatie/ha-wyzeapi/issues/425 forever ago and finally ready.
Upstream: https://github.com/SecKatie/wyzeapy/pull/79
A couple notes:
Power usage is combined from both outlets just like in the app. The power use is displayed on the device called Wyze Plug Outdoor. If you have more than one of these plugs they all show up named the same thing, but you can change that in device settings. Updates only happen 1-2 times an hour, so if you're comparing to the app there might be slight differences based on when HA pulled the latest usage. Because of above, the hourly data in the energy dashboard will not be accurate. It only looks at current and last hour’s usage. So when you first install it’ll be at 0 and count up from there. Add it to the energy dashboard to see day/month etc usage. Now also has a daily usage sensor that resets at midnight.
When I originally looked at this a long while back... Wyze's delay/random updates for the hourly usage made it basically impossible to update Home Assistant's hourly power usage, because it only lets you update the current usage for the current hour, when you update it. Meaning you'd get different numbers than Wyze showed.
Does this implementation not have that problem? If it does, implementing it will get just as many "this sensor is wrong" reports as requests to implement it.
It’s darn close, within .01KWh, and that is probably rounding error.
What I did was take current and last hour values at every update and calculate the change from the previous update, then add that to a running total restore sensor.
It’s darn close, within .01KWh, and that is probably rounding error.
I think you're just taking about the daily total. The code looks like it added the hourly sensor as well from my quick scan over the code... That's what I was saying would end up incorrect.
There is no hourly sensor. That wouldn’t work for the reasons you said. Just a total (never resetting) and a daily sensor that resets at midnight.
One more example of what’s actually shown in HA:
Thanks for reviewing @JoeSchubert!
Right... That bottom image is what I was talking about that all always be incorrect.
The hourly bars, not the total.
Yea it will, I guess I’m hoping that since I made the sensors daily and total that the understanding will be that’s the accuracy we’re going for. The only place to see hourly will be the energy dashboard.
It seems like we might need some more checks. I can see multiple places where we could have bad data in the json and it could cause issues.
@SecKatie can you point me in the direction of what needs changed?
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.
Keep
@SecKatie can you point me in the direction of what needs changed?
I added review comments that point to a couple places. Basically I am wondering what will happen if the indexes don't exist. They change random things like that so often I am concerned that this will break in a bad way.
Sorry about that, for some reason I cant see any of those review comments..
I have no idea why but as soon as you closed this your review comments finally showed up! 😆