1 """Support for Ecowitt Weather Stations."""
4 from typing
import Final
6 from aioecowitt
import EcoWittSensor, EcoWittSensorTypes
9 BinarySensorDeviceClass,
11 BinarySensorEntityDescription,
17 from .
import EcowittConfigEntry
18 from .entity
import EcowittEntity
20 ECOWITT_BINARYSENSORS_MAPPING: Final = {
22 key=
"LEAK", device_class=BinarySensorDeviceClass.MOISTURE
26 device_class=BinarySensorDeviceClass.BATTERY,
27 entity_category=EntityCategory.DIAGNOSTIC,
34 entry: EcowittConfigEntry,
35 async_add_entities: AddEntitiesCallback,
37 """Add sensors if new."""
38 ecowitt = entry.runtime_data
42 if sensor.stype
not in ECOWITT_BINARYSENSORS_MAPPING:
44 mapping = ECOWITT_BINARYSENSORS_MAPPING[sensor.stype]
47 description = dataclasses.replace(
55 ecowitt.new_sensor_cb.append(_new_sensor)
56 entry.async_on_unload(
lambda: ecowitt.new_sensor_cb.remove(_new_sensor))
59 for sensor
in ecowitt.sensors.values():
64 """Representation of a Ecowitt BinarySensor."""
67 self, sensor: EcoWittSensor, description: BinarySensorEntityDescription
69 """Initialize the sensor."""
75 """Return true if the binary sensor is on."""
76 return bool(self.ecowitt.value)
None __init__(self, EcoWittSensor sensor, BinarySensorEntityDescription description)
None async_setup_entry(HomeAssistant hass, EcowittConfigEntry entry, AddEntitiesCallback async_add_entities)
None _new_sensor(EcoWittSensor sensor)