1 """sensor integration microBees."""
3 from microBeesPy
import Sensor
8 SensorEntityDescription,
13 CONCENTRATION_PARTS_PER_MILLION,
22 from .const
import DOMAIN
23 from .coordinator
import MicroBeesUpdateCoordinator
24 from .entity
import MicroBeesEntity
28 device_class=SensorDeviceClass.POWER,
29 state_class=SensorStateClass.MEASUREMENT,
30 native_unit_of_measurement=UnitOfPower.WATT,
32 suggested_display_precision=2,
35 device_class=SensorDeviceClass.TEMPERATURE,
36 state_class=SensorStateClass.MEASUREMENT,
37 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
39 suggested_display_precision=1,
42 device_class=SensorDeviceClass.CO2,
43 state_class=SensorStateClass.MEASUREMENT,
44 native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
46 suggested_display_precision=1,
49 device_class=SensorDeviceClass.HUMIDITY,
50 state_class=SensorStateClass.MEASUREMENT,
51 native_unit_of_measurement=PERCENTAGE,
53 suggested_display_precision=1,
56 device_class=SensorDeviceClass.ILLUMINANCE,
57 state_class=SensorStateClass.MEASUREMENT,
58 native_unit_of_measurement=LIGHT_LUX,
60 suggested_display_precision=1,
66 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
69 coordinator = hass.data[DOMAIN][entry.entry_id].coordinator
72 MBSensor(coordinator, desc, bee_id, sensor.id)
73 for bee_id, bee
in coordinator.data.bees.items()
74 for sensor
in bee.sensors
75 if (desc := SENSOR_TYPES.get(sensor.device_type))
is not None
80 """Representation of a microBees sensor."""
84 coordinator: MicroBeesUpdateCoordinator,
85 entity_description: SensorEntityDescription,
89 """Initialize the microBees sensor."""
90 super().
__init__(coordinator, bee_id)
97 """Name of the sensor."""
98 return self.
sensorsensor.name
102 """Return the state of the sensor."""
103 return self.
sensorsensor.value
107 """Return the sensor."""
108 return self.coordinator.data.sensors[self.
sensor_idsensor_id]
float|None native_value(self)
None __init__(self, MicroBeesUpdateCoordinator coordinator, SensorEntityDescription entity_description, int bee_id, int sensor_id)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)