ZHA ElectricalMeasurement cluster add Frequency and Power Factor (#59417)
* Add files via upload * Add Frequency and PF * Add Frequency and PF Add Frequency and PF * Add Frequency and PF Add Frequency and PF * Add Frequency and PF Add Frequency and PF * Add Frequency and PF Add Frequency and PF * Update homeassistant/const.py Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> * Update homeassistant/components/zha/sensor.py Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> * Update homeassistant/const.py Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> * Fix rebase * rebase cleanup * fix stale doc string * missed this again * isort * update tests * update discovery test data Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> Co-authored-by: David Mulcahey <david.mulcahey@me.com>
This commit is contained in:
parent
e4a613a4b3
commit
8a73381b56
4 changed files with 189 additions and 2 deletions
|
@ -25,6 +25,7 @@ from homeassistant.const import (
|
|||
ELECTRIC_CURRENT_AMPERE,
|
||||
ELECTRIC_POTENTIAL_VOLT,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
FREQUENCY_HERTZ,
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
POWER_VOLT_AMPERE,
|
||||
|
@ -346,6 +347,35 @@ class ElectricalMeasurementRMSVoltage(ElectricalMeasurement, id_suffix="rms_volt
|
|||
return False
|
||||
|
||||
|
||||
@MULTI_MATCH(channel_names=CHANNEL_ELECTRICAL_MEASUREMENT)
|
||||
class ElectricalMeasurementFrequency(ElectricalMeasurement, id_suffix="ac_frequency"):
|
||||
"""Frequency measurement."""
|
||||
|
||||
SENSOR_ATTR = "ac_frequency"
|
||||
_device_class: SensorDeviceClass = SensorDeviceClass.FREQUENCY
|
||||
_unit = FREQUENCY_HERTZ
|
||||
_div_mul_prefix = "ac_frequency"
|
||||
|
||||
@property
|
||||
def should_poll(self) -> bool:
|
||||
"""Poll indirectly by ElectricalMeasurementSensor."""
|
||||
return False
|
||||
|
||||
|
||||
@MULTI_MATCH(channel_names=CHANNEL_ELECTRICAL_MEASUREMENT)
|
||||
class ElectricalMeasurementPowerFactor(ElectricalMeasurement, id_suffix="power_factor"):
|
||||
"""Frequency measurement."""
|
||||
|
||||
SENSOR_ATTR = "power_factor"
|
||||
_device_class: SensorDeviceClass = SensorDeviceClass.POWER_FACTOR
|
||||
_unit = PERCENTAGE
|
||||
|
||||
@property
|
||||
def should_poll(self) -> bool:
|
||||
"""Poll indirectly by ElectricalMeasurementSensor."""
|
||||
return False
|
||||
|
||||
|
||||
@MULTI_MATCH(
|
||||
generic_ids=CHANNEL_ST_HUMIDITY_CLUSTER, stop_on_match_group=CHANNEL_HUMIDITY
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue