Open fbalesse opened 5 months ago
Same issue here : with this device, the current, voltage and energy meter are ok, but the power values are way too small (apparent power seems to be incorrectly divided by 1000). I also tried to write a quirk file, but without success.
Problem description
Device is correctly added to Home Assistant and sensors appears after a reboot. The issue is Power value (in W) on Home Assistant is divised by 1000 with 1 digit precision. Regarding the cluster, the value is ok, but a dividor is set to 1000 when multiplicator is set to 1.
Solution description
I tried to write my first Quirks, by if i don't use LocalDataCluster, the sensors don't change, and if i use it, the sensors keep the 0 value. I don't understand why.
Screenshots/Video
No response
Device signature
Device signature
signature = { # "node_descriptor": "NodeDescriptor(logical_type=Diagnostic information
No response
Logs
No response
Custom quirk
Custom quirk
```python """Bituo Din Power Meter.""" from zigpy.profiles import zha from zigpy.quirks import CustomDevice import zigpy.types as t from zigpy.zcl.clusters.general import Basic, Ota, Scenes, Identify from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement, Diagnostic from zigpy.zcl.clusters.smartenergy import Metering from zhaquirks import Bus, LocalDataCluster from zhaquirks.const import ( DEVICE_TYPE, ENDPOINTS, INPUT_CLUSTERS, MODELS_INFO, OUTPUT_CLUSTERS, PROFILE_ID, ) class PowerMeasurement(LocalDataCluster, ElectricalMeasurement): """Custom class for power, voltage and current measurement.""" cluster_id = ElectricalMeasurement.cluster_id POWER_ID = 0x050B VOLTAGE_ID = 0x0505 CURRENT_ID = 0x0508 REACTIVE_POWER_ID = 0x050E AC_FREQUENCY_ID = 0x0300 TOTAL_REACTIVE_POWER_ID = 0x0305 TOTAL_POWER_ID = 0x0304 POWER_FACTOR_ID = 0x0510 AC_CURRENT_MULTIPLIER = 0x0602 AC_CURRENT_DIVISOR = 0x0603 AC_FREQUENCY_MULTIPLIER = 0x0400 AC_FREQUENCY_DIVISOR = 0x0401 AC_POWER_MULTIPLIER = 0x0604 AC_POWER_DIVISOR = 0x0605 _CONSTANT_ATTRIBUTES = { AC_POWER_MULTIPLIER: 1000, AC_POWER_DIVISOR: 1000, } def voltage_reported(self, value): """Voltage reported.""" self._update_attribute(self.VOLTAGE_ID, value) def power_reported(self, value): """Power reported.""" self._update_attribute(self.POWER_ID, value * self.AC_POWER_MULTIPLIER) def power_factor_reported(self, value): """Power Factor reported.""" self._update_attribute(self.POWER_FACTOR_ID, value) def reactive_power_reported(self, value): """Reactive Power reported.""" self._update_attribute(self.REACTIVE_POWER_ID, value * self.AC_POWER_MULTIPLIER) def current_reported(self, value): """Ampers reported.""" self._update_attribute(self.CURRENT_ID, value) def frequency_reported(self, value): """AC Frequency reported.""" self._update_attribute(self.AC_FREQUENCY_ID, value) def reactive_energy_reported(self, value): """Summation Reactive Energy reported.""" self._update_attribute(self.TOTAL_REACTIVE_POWER_ID, value) class BituoPowerMeter(CustomDevice): signature = { # "node_descriptor": "NodeDescriptor(logical_type=Additional information
No response