1 """Platform for beewi_smartclim integration."""
3 from __future__
import annotations
5 from beewi_smartclim
import BeewiSmartClimPoller
6 import voluptuous
as vol
9 PLATFORM_SCHEMA
as SENSOR_PLATFORM_SCHEMA,
20 DEFAULT_NAME =
"BeeWi SmartClim"
24 [SensorDeviceClass.TEMPERATURE,
"Temperature", UnitOfTemperature.CELSIUS],
25 [SensorDeviceClass.HUMIDITY,
"Humidity", PERCENTAGE],
26 [SensorDeviceClass.BATTERY,
"Battery", PERCENTAGE],
29 PLATFORM_SCHEMA = SENSOR_PLATFORM_SCHEMA.extend(
31 vol.Required(CONF_MAC): cv.string,
32 vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
40 add_entities: AddEntitiesCallback,
41 discovery_info: DiscoveryInfoType |
None =
None,
43 """Set up the beewi_smartclim platform."""
45 mac = config[CONF_MAC]
46 prefix = config[CONF_NAME]
47 poller = BeewiSmartClimPoller(mac)
51 for sensor_type
in SENSOR_TYPES:
52 device = sensor_type[0]
58 name = f
"{prefix} {name}"
66 """Representation of a Sensor."""
68 def __init__(self, poller, name, mac, device, unit):
69 """Initialize the sensor."""
78 """Fetch new state data from the poller."""
79 self.
_poller_poller.update_sensor()
81 if self.
_device_device == SensorDeviceClass.TEMPERATURE:
83 if self.
_device_device == SensorDeviceClass.HUMIDITY:
85 if self.
_device_device == SensorDeviceClass.BATTERY:
def __init__(self, poller, name, mac, device, unit)
_attr_native_unit_of_measurement
None setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback add_entities, DiscoveryInfoType|None discovery_info=None)
def add_entities(account, async_add_entities, tracked)
float|None get_temperature(MadVRCoordinator coordinator, str key)