mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
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:
parent
ac85a3ce64
commit
b9b6ed33ee
@ -472,25 +472,8 @@ class SmartEnergyMetering(Sensor):
|
|||||||
|
|
||||||
@MULTI_MATCH(
|
@MULTI_MATCH(
|
||||||
channel_names=CHANNEL_SMARTENERGY_METERING,
|
channel_names=CHANNEL_SMARTENERGY_METERING,
|
||||||
models={"TS011F"},
|
|
||||||
stop_on_match_group=CHANNEL_SMARTENERGY_METERING,
|
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"):
|
class SmartEnergySummation(SmartEnergyMetering, id_suffix="summation_delivered"):
|
||||||
"""Smart Energy Metering summation sensor."""
|
"""Smart Energy Metering summation sensor."""
|
||||||
|
|
||||||
@ -523,6 +506,26 @@ class SmartEnergySummation(SmartEnergyMetering, id_suffix="summation_delivered")
|
|||||||
return round(cooked, 3)
|
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)
|
@MULTI_MATCH(channel_names=CHANNEL_PRESSURE)
|
||||||
class Pressure(Sensor):
|
class Pressure(Sensor):
|
||||||
"""Pressure sensor."""
|
"""Pressure sensor."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user