1 """Base class for Acmeda Roller Blinds."""
3 from __future__
import annotations
11 from .const
import ACMEDA_ENTITY_REMOVE, DOMAIN, LOGGER
15 """Base representation of an Acmeda roller."""
17 _attr_should_poll =
False
18 _attr_has_entity_name =
True
20 def __init__(self, roller: aiopulse.Roller) ->
None:
21 """Initialize the roller."""
25 """Unregister from registries and call entity remove function."""
26 LOGGER.error(
"Removing %s %s", self.__class__.__name__, self.
unique_idunique_id)
28 ent_registry = er.async_get(self.hass)
29 if self.entity_id
in ent_registry.entities:
30 ent_registry.async_remove(self.entity_id)
32 dev_registry = dr.async_get(self.hass)
33 device = dev_registry.async_get_device(identifiers={(DOMAIN, self.
unique_idunique_id)})
36 and self.registry_entry
is not None
37 and self.registry_entry.config_entry_id
is not None
39 dev_registry.async_update_device(
40 device.id, remove_config_entry_id=self.registry_entry.config_entry_id
43 await self.async_remove(force_remove=
True)
46 """Entity has been added to hass."""
52 ACMEDA_ENTITY_REMOVE.format(self.
rollerroller.id),
58 """Entity being removed from hass."""
63 """Write updated device state information."""
64 LOGGER.debug(
"Device update notification received: %s", self.name)
65 self.async_write_ha_state()
69 """Return the unique ID of this roller."""
74 """Return the ID of this roller."""
75 return self.
rollerroller.id
79 """Return the device info."""
81 identifiers={(DOMAIN, self.
unique_idunique_id)},
82 manufacturer=
"Rollease Acmeda",
83 name=self.
rollerroller.name,
84 via_device=(DOMAIN, self.
rollerroller.hub.id),
None __init__(self, aiopulse.Roller roller)
None async_added_to_hass(self)
None async_remove_and_unregister(self)
None async_will_remove_from_hass(self)
dr.DeviceInfo device_info(self)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)