1 """Bosch Smart Home Controller base entity."""
3 from __future__
import annotations
5 from boschshcpy
import SHCDevice, SHCIntrusionSystem
12 from .const
import DOMAIN
16 hass: HomeAssistant, entity: SHCBaseEntity, entry_id: str
18 """Get item that is removed from session."""
19 dev_registry = dr.async_get(hass)
20 device = dev_registry.async_get_device(identifiers={(DOMAIN, entity.device_id)})
21 if device
is not None:
22 dev_registry.async_update_device(device.id, remove_config_entry_id=entry_id)
26 """Base representation of a SHC entity."""
28 _attr_should_poll =
False
29 _attr_has_entity_name =
True
32 self, device: SHCDevice | SHCIntrusionSystem, parent_id: str, entry_id: str
34 """Initialize the generic SHC device."""
39 """Subscribe to SHC events."""
42 def on_state_changed() -> None:
48 self.
_device_device.subscribe_callback(self.
entity_identity_id, on_state_changed)
51 """Unsubscribe from SHC events."""
57 """Return the device id."""
62 """Representation of a SHC device entity."""
64 def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) ->
None:
65 """Initialize generic SHC device."""
68 identifiers={(DOMAIN, device.id)},
69 manufacturer=device.manufacturer,
70 model=device.device_model,
74 device.parent_device_id
75 if device.parent_device_id
is not None
79 super().
__init__(device=device, parent_id=parent_id, entry_id=entry_id)
82 """Subscribe to SHC events."""
85 def on_state_changed() -> None:
88 for service
in self.
_device_device.device_services:
89 service.subscribe_callback(self.
entity_identity_id, on_state_changed)
92 """Unsubscribe from SHC events."""
94 for service
in self.
_device_device.device_services:
95 service.unsubscribe_callback(self.
entity_identity_id)
99 """Return false if status is unavailable."""
100 return self.
_device_device.status ==
"AVAILABLE"
104 """Representation of a SHC domain service entity."""
107 self, domain: SHCIntrusionSystem, parent_id: str, entry_id: str
109 """Initialize the generic SHC device."""
112 identifiers={(DOMAIN, domain.id)},
113 manufacturer=domain.manufacturer,
114 model=domain.device_model,
121 super().
__init__(device=domain, parent_id=parent_id, entry_id=entry_id)
125 """Return false if status is unavailable."""
126 return self.
_device_device.system_availability
None async_added_to_hass(self)
None __init__(self, SHCDevice|SHCIntrusionSystem device, str parent_id, str entry_id)
None async_will_remove_from_hass(self)
None __init__(self, SHCIntrusionSystem domain, str parent_id, str entry_id)
None __init__(self, SHCDevice device, str parent_id, str entry_id)
None async_added_to_hass(self)
None async_will_remove_from_hass(self)
None schedule_update_ha_state(self, bool force_refresh=False)
None async_remove_devices(HomeAssistant hass, SHCBaseEntity entity, str entry_id)