1 """Sensor support for Skybell Doorbells."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
7 from datetime
import datetime
9 from aioskybell
import SkybellDevice
10 from aioskybell.helpers
import const
as CONST
15 SensorEntityDescription,
23 from .entity
import DOMAIN, SkybellEntity
26 @dataclass(frozen=True, kw_only=True)
28 """Class to describe a Skybell sensor."""
30 value_fn: Callable[[SkybellDevice], StateType | datetime]
33 SENSOR_TYPES: tuple[SkybellSensorEntityDescription, ...] = (
36 translation_key=
"chime_level",
37 value_fn=
lambda device: device.outdoor_chime_level,
40 key=
"last_button_event",
41 translation_key=
"last_button_event",
42 device_class=SensorDeviceClass.TIMESTAMP,
43 value_fn=
lambda device: device.latest(
"button").
get(CONST.CREATED_AT),
46 key=
"last_motion_event",
47 translation_key=
"last_motion_event",
48 device_class=SensorDeviceClass.TIMESTAMP,
49 value_fn=
lambda device: device.latest(
"motion").
get(CONST.CREATED_AT),
52 key=CONST.ATTR_LAST_CHECK_IN,
53 translation_key=
"last_check_in",
54 entity_registry_enabled_default=
False,
55 device_class=SensorDeviceClass.TIMESTAMP,
56 entity_category=EntityCategory.DIAGNOSTIC,
57 value_fn=
lambda device: device.last_check_in,
60 key=
"motion_threshold",
61 translation_key=
"motion_threshold",
62 entity_registry_enabled_default=
False,
63 entity_category=EntityCategory.DIAGNOSTIC,
64 value_fn=
lambda device: device.motion_threshold,
68 translation_key=
"video_profile",
69 entity_registry_enabled_default=
False,
70 entity_category=EntityCategory.DIAGNOSTIC,
71 value_fn=
lambda device: device.video_profile,
74 key=CONST.ATTR_WIFI_SSID,
75 translation_key=
"wifi_ssid",
76 entity_registry_enabled_default=
False,
77 entity_category=EntityCategory.DIAGNOSTIC,
78 value_fn=
lambda device: device.wifi_ssid,
81 key=CONST.ATTR_WIFI_STATUS,
82 translation_key=
"wifi_status",
83 entity_registry_enabled_default=
False,
84 entity_category=EntityCategory.DIAGNOSTIC,
85 value_fn=
lambda device: device.wifi_status,
91 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
93 """Set up Skybell sensor."""
96 for coordinator
in hass.data[DOMAIN][entry.entry_id]
97 for description
in SENSOR_TYPES
98 if coordinator.device.owner
or description.key
not in CONST.ATTR_OWNER_STATS
103 """A sensor implementation for Skybell devices."""
105 entity_description: SkybellSensorEntityDescription
109 """Return the state of the sensor."""
SkybellDevice _device(self)
StateType|datetime native_value(self)
web.Response get(self, web.Request request, str config_key)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)