1 """Support for Blink system camera sensors."""
3 from __future__
import annotations
10 SensorEntityDescription,
14 SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
23 from .const
import DEFAULT_BRAND, DOMAIN, TYPE_TEMPERATURE, TYPE_WIFI_STRENGTH
24 from .coordinator
import BlinkConfigEntry, BlinkUpdateCoordinator
26 _LOGGER = logging.getLogger(__name__)
28 SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
31 native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
32 device_class=SensorDeviceClass.TEMPERATURE,
33 entity_category=EntityCategory.DIAGNOSTIC,
34 state_class=SensorStateClass.MEASUREMENT,
37 key=TYPE_WIFI_STRENGTH,
38 translation_key=
"wifi_strength",
39 native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
40 device_class=SensorDeviceClass.SIGNAL_STRENGTH,
41 entity_category=EntityCategory.DIAGNOSTIC,
42 state_class=SensorStateClass.MEASUREMENT,
49 config_entry: BlinkConfigEntry,
50 async_add_entities: AddEntitiesCallback,
52 """Initialize a Blink sensor."""
54 coordinator = config_entry.runtime_data
57 for camera
in coordinator.api.cameras
58 for description
in SENSOR_TYPES
65 """A Blink camera sensor."""
67 _attr_has_entity_name =
True
71 coordinator: BlinkUpdateCoordinator,
73 description: SensorEntityDescription,
75 """Initialize sensors from Blink camera."""
79 self.
_camera_camera = coordinator.api.cameras[camera]
80 serial = self.
_camera_camera.serial
83 "temperature_calibrated"
84 if description.key ==
"temperature"
88 identifiers={(DOMAIN, serial)},
90 name=f
"{DOMAIN} {camera}",
91 manufacturer=DEFAULT_BRAND,
92 model=self.
_camera_camera.camera_type,
98 """Handle coordinator update."""
104 """Update attributes for sensor."""
109 self.
_camera_camera.attributes[
"name"],
116 "%s not a valid camera attribute. Did the API change?", self.
_sensor_key_sensor_key
None __init__(self, BlinkUpdateCoordinator coordinator, camera, SensorEntityDescription description)
None _handle_coordinator_update(self)
None async_setup_entry(HomeAssistant hass, BlinkConfigEntry config_entry, AddEntitiesCallback async_add_entities)