1 """The Ecowitt Weather Station Entity."""
3 from __future__
import annotations
7 from aioecowitt
import EcoWittSensor
12 from .const
import DOMAIN
16 """Base class for Ecowitt Weather Station."""
18 _attr_has_entity_name =
True
19 _attr_should_poll =
False
21 def __init__(self, sensor: EcoWittSensor) ->
None:
22 """Construct the entity."""
23 self.ecowitt: EcoWittSensor = sensor
28 (DOMAIN, sensor.station.key),
30 name=sensor.station.model,
31 model=sensor.station.model,
32 sw_version=sensor.station.version,
36 """Install listener for updates later."""
38 def _update_state() -> None:
39 """Update the state on callback."""
42 self.ecowitt.update_cb.append(_update_state)
43 self.
async_on_removeasync_on_remove(
lambda: self.ecowitt.update_cb.remove(_update_state))
47 """Return whether the state is based on actual reading from device."""
48 return (self.ecowitt.last_update_m + 5 * 60) > time.monotonic()
None async_added_to_hass(self)
None __init__(self, EcoWittSensor sensor)
None async_write_ha_state(self)
None async_on_remove(self, CALLBACK_TYPE func)