Closed mansbo closed 3 years ago
This is a kind of me too but with a little more info.
I initially manually installed as a custom component and that has been working perfectly. I decided with the 2FA bits now being part of the main Home Assistant repo that I'd update to use that so I:
Afterwards I updated a few lovelace bits and all seemed ok however, like the OP, the current_power_w attribute is not available for my Active Plugs which I discovered because I have a sensor template, so it was flagged in the logs.
I attempted to undo by removing the built-in integration and re-installing the custom component from here but the code in this repo now seems to import the code from the built-in integration in Home Assistant as of 2021.4 so I got the same result.
To get myself working again, I had to go back to the old code, which I think might have been beta01 - I didn't try any other release.
Directly comparing the current code in core/homeassistant/components/hive/switch.py with the code in this repo before it starts importing from core (2021.3.1) shows only minor changes:
@property
def current_power_w(self):
"""Return the current power usage in W."""
return self.device["status"].get("power_usage")
@property
def current_power_w(self):
"""Return the current power usage in W."""
return self.device["status"]["power_usage"]
May be useful information, may be complete cobblers.
Well spotted @lwsrbrts - I was staring at the code trying to spot differences but completely missed this one. I think it does point to the problem. The new version of the underlying apyhiveapi library seems to format the device details differently, hence the change, but what is actually happening is that "power_usage" is at a lower level than "status" for Active Plugs, so the new code comes back with None. In fact, there is another "status" object embedded within the "status" being searched for "power_usage". So either this switch.py code needs to look down another level, or the underlying library needs to be changed to lift "power_usage" up to where it needs to be. I suspect the latter but, to be honest, I don't really know what I'm talking about so this could all be complete cobblers too.
me too - sorry, haven't had chance to do any investigation ;-)
Fixed in 2021.5.3
Describe the bug Since upgrading to the latest version 2021.5.1, I am no longer seeing power usage reported by my two Hive Active Plugs. It used to appear as an attribute called current_power_w, but that attribute no longer appears for the plugs. I downgraded back to an earlier version (2021.4.0) and the power usage re-appeared.
To Reproduce
Expected behaviour I would expect the power usage to be reported as an attribute called current_power_w against the switch entity for the plug, as it was in earlier versions.