Fix smart energy polling for Tuya plugs (#74640)

* Add PolledSmartEnergySummation to poll summation_delivered for some ZHA plugs

* Remove PolledSmartEnergyMetering, add stop_on_match_group to summation sensors
This commit is contained in:
TheJulianJES 2022-07-07 20:27:48 +02:00 committed by GitHub
parent ac85a3ce64
commit b9b6ed33ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -472,25 +472,8 @@ class SmartEnergyMetering(Sensor):
@MULTI_MATCH(
channel_names=CHANNEL_SMARTENERGY_METERING,
models={"TS011F"},
stop_on_match_group=CHANNEL_SMARTENERGY_METERING,
)
class PolledSmartEnergyMetering(SmartEnergyMetering):
"""Polled metering sensor."""
@property
def should_poll(self) -> bool:
"""Poll the entity for current state."""
return True
async def async_update(self) -> None:
"""Retrieve latest state."""
if not self.available:
return
await self._channel.async_force_update()
@MULTI_MATCH(channel_names=CHANNEL_SMARTENERGY_METERING)
class SmartEnergySummation(SmartEnergyMetering, id_suffix="summation_delivered"):
"""Smart Energy Metering summation sensor."""
@ -523,6 +506,26 @@ class SmartEnergySummation(SmartEnergyMetering, id_suffix="summation_delivered")
return round(cooked, 3)
@MULTI_MATCH(
channel_names=CHANNEL_SMARTENERGY_METERING,
models={"TS011F"},
stop_on_match_group=CHANNEL_SMARTENERGY_METERING,
)
class PolledSmartEnergySummation(SmartEnergySummation):
"""Polled Smart Energy Metering summation sensor."""
@property
def should_poll(self) -> bool:
"""Poll the entity for current state."""
return True
async def async_update(self) -> None:
"""Retrieve latest state."""
if not self.available:
return
await self._channel.async_force_update()
@MULTI_MATCH(channel_names=CHANNEL_PRESSURE)
class Pressure(Sensor):
"""Pressure sensor."""