Closed glcos closed 2 years ago
You may need to define _CONSTANT_ATTRIBUTES dict in your quirk for smart energy cluster with attr_id of unit of measurement attribute Id, so zha knows what uom to use
@Adminiuga thanks for your help, but I don't quite understand, this is my cluster class:
class SmartEnergyCluster(LocalDataCluster, Metering):
cluster_id = Metering.cluster_id
CURRENT_SUMM_DELIVERED_VALUE_ID = 0x0000
INSTANTANEOUS_DEMAND_VALUE_ID = 0x0400
UNIT_OF_MEASURE_VALUE_ID = 0x0300
POWER_WATT = 0x0000
ENERGY_KILO_WATT_HOUR = 0x0000
_CONSTANT_ATTRIBUTES = {0x0300: POWER_WATT}
def __init__(self, *args, **kwargs):
"""Init."""
super().__init__(*args, **kwargs)
self.endpoint.device.energy_bus.add_listener(self)
def energy_reported(self, value):
"""Energy reported."""
self._update_attribute(self.CURRENT_SUMM_DELIVERED_VALUE_ID, value)
def instantaneous_demand(self, value):
"""Instantaneous power demand reported."""
self._update_attribute(self.INSTANTANEOUS_DEMAND_VALUE_ID, value)
Setting _CONSTANT_ATTRIBUTES the way I did, doesn't seem to work.
looks good. What happens when you try to read the 0x0300 attr from zha device panel?
Don't know how to read it from zha device panel, but the uom is still missing and I get this in the logs:
WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.ptvo_info_pzem004t_92e9da14_smartenergy_metering has unknown unit None
2021-10-20 14:15:10 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.ptvo_info_pzem004t_92e9da14_smartenergy_metering_summation_delivered has unknown unit None
In addition, since the cluster has two entities defined in sensor.py (SmartEnergyMetering and SmartEnergySummation) there should be a way to set uom for each on them, because in some cases they might be different.
to read the attribute go to Configuration -> Devices -> Your device -> Manage Clusters -> Pick the Metering 0x0702 cluster -> pick 0x0300 attribute unit of measurement -> click on Get Zigbee Attribute
This is what I get
Works as expected. If you restart HA, does it still shows the UOM as None Can you post the state changes for this entity during the restart?
If still doesn't work, could you remove the device from ZHA and re-pair it? -- this is to clear the cached values, like unsupported attributes which still might be lingering on if the device was added before there was any quirk present.
Just restarting HA one more time did the trick! Thanks again @Adminiuga
Now it is also appearing in the energy dashboard
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Is your feature request related to a problem? Please describe. I'm building a quirk for a PZEM004T based device which is actually working fine, but the entities related to the Metering SmartEnergy cluster are missing the unit of measurement. Instantaneous demand should be in Watt of Kilowatt while Energy should be in W/h or Kw/h. Tests done on a system running Home Assistant 2021.11.0.dev0
Describe the solution you'd like Show the unit of measurement or better choose it from the quirk
Device signature - this can be acquired by removing the device from ZHA and pairing it again from the add devices screen. Be sure to add the entire content of the log panel after pairing the device to a code block below this line. Not needed here
Additional context
Quirk is here https://github.com/glcos/PTVOquirk/blob/main/pzem004t.py