1 """Pushbullet platform for sensor component."""
3 from __future__
import annotations
13 from .api
import PushBulletNotificationProvider
14 from .const
import DATA_UPDATED, DOMAIN
16 SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
18 key=
"application_name",
19 translation_key=
"application_name",
20 entity_registry_enabled_default=
False,
24 translation_key=
"body",
27 key=
"notification_id",
28 translation_key=
"notification_id",
29 entity_registry_enabled_default=
False,
32 key=
"notification_tag",
33 translation_key=
"notification_tag",
34 entity_registry_enabled_default=
False,
38 translation_key=
"package_name",
39 entity_registry_enabled_default=
False,
43 translation_key=
"receiver_email",
44 entity_registry_enabled_default=
False,
48 translation_key=
"sender_email",
49 entity_registry_enabled_default=
False,
52 key=
"source_device_iden",
53 translation_key=
"source_device_identifier",
54 entity_registry_enabled_default=
False,
58 translation_key=
"title",
62 translation_key=
"type",
63 entity_registry_enabled_default=
False,
67 SENSOR_KEYS: list[str] = [desc.key
for desc
in SENSOR_TYPES]
71 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
73 """Set up the Pushbullet sensors from config entry."""
75 pb_provider: PushBulletNotificationProvider = hass.data[DOMAIN][entry.entry_id]
79 for description
in SENSOR_TYPES
86 """Representation of a Pushbullet Sensor."""
88 _attr_should_poll =
False
89 _attr_has_entity_name =
True
94 pb_provider: PushBulletNotificationProvider,
95 description: SensorEntityDescription,
97 """Initialize the Pushbullet sensor."""
101 f
"{pb_provider.pushbullet.user_info['iden']}-{description.key}"
104 identifiers={(DOMAIN, pb_provider.pushbullet.user_info[
"iden"])},
106 entry_type=DeviceEntryType.SERVICE,
111 """Fetch the latest data from the sensor.
113 This will fetch the 'sensor reading' into self._state but also all
114 attributes into self._state_attributes.
119 except (KeyError, TypeError):
124 """Register callbacks."""
_attr_extra_state_attributes
None async_update_callback(self)
None async_added_to_hass(self)
None __init__(self, str name, PushBulletNotificationProvider pb_provider, SensorEntityDescription description)
None async_write_ha_state(self)
None async_on_remove(self, CALLBACK_TYPE func)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)