diff --git a/custom_components/e3dc_rscp/binary_sensor.py b/custom_components/e3dc_rscp/binary_sensor.py index 68b8ac9..397f45c 100644 --- a/custom_components/e3dc_rscp/binary_sensor.py +++ b/custom_components/e3dc_rscp/binary_sensor.py @@ -74,10 +74,7 @@ async def async_setup_entry( class E3DCBinarySensor(CoordinatorEntity, BinarySensorEntity): """Custom E3DC Binary Sensor implementation.""" - coordinator: E3DCCoordinator - entity_description: E3DCBinarySensorEntityDescription _attr_has_entity_name: bool = True - _custom_icons: bool = False def __init__( self, @@ -87,9 +84,10 @@ def __init__( ) -> None: """Initialize the Sensor.""" super().__init__(coordinator) - self.entity_description = description + self.coordinator: E3DCCoordinator = coordinator + self.entity_description: E3DCBinarySensorEntityDescription = description self._attr_unique_id = f"{uid}_{description.key}" - self._custom_icons = ( + self._custom_icons: bool = ( self.entity_description.on_icon is not None and self.entity_description.off_icon is not None ) diff --git a/custom_components/e3dc_rscp/diagnostics.py b/custom_components/e3dc_rscp/diagnostics.py index b17de50..bf65fb7 100644 --- a/custom_components/e3dc_rscp/diagnostics.py +++ b/custom_components/e3dc_rscp/diagnostics.py @@ -36,20 +36,14 @@ async def async_get_config_entry_diagnostics( class _DiagnosticsDumper: """Helper class to collect a diagnostic dump in a failsafe way.""" - e3dc: E3DC = None - coordinator: E3DCCoordinator = None - proxy: E3DCProxy = None - hass: HomeAssistant = None - entry: ConfigEntry = None - result: dict[str, Any] = {} - def __init__(self, _hass: HomeAssistant, _entry: ConfigEntry): """Initialize the dumper and set up a few references.""" - self.hass = _hass - self.entry = _entry - self.coordinator = self.hass.data[DOMAIN][self.entry.unique_id] - self.proxy = self.coordinator.proxy - self.e3dc = self.proxy.e3dc + self.hass: HomeAssistant = _hass + self.entry: ConfigEntry = _entry + self.coordinator: E3DCCoordinator = self.hass.data[DOMAIN][self.entry.unique_id] + self.proxy: E3DCProxy = self.coordinator.proxy + self.e3dc: E3DC = self.proxy.e3dc + self.result: dict[str, Any] = {} def create_dump(self): """Create the dump data and redact pricate data, central call-in point.""" diff --git a/custom_components/e3dc_rscp/e3dc_proxy.py b/custom_components/e3dc_rscp/e3dc_proxy.py index a97f93c..7b90ee0 100644 --- a/custom_components/e3dc_rscp/e3dc_proxy.py +++ b/custom_components/e3dc_rscp/e3dc_proxy.py @@ -57,21 +57,17 @@ def wrapper_handle_e3dc_ex(*args, **kwargs) -> Any: class E3DCProxy: """Proxies requests to pye3dc, takes care of error and async handling.""" - # TODO: move to readonly properties - e3dc: E3DC = None - e3dc_config: dict[str, Any] = None - _hass: HomeAssistant = None - _config: ConfigEntry = None - _host: str - _username: str - _password: str - _rscpkey: str - def __init__(self, _hass: HomeAssistant, _config: ConfigEntry | dict[str, str]): """Initialize E3DC Proxy and connect.""" - self._hass = _hass - self._config = _config - self.e3dc_config = {} + # TODO: move to readonly properties + self.e3dc: E3DC = None + self.e3dc_config: dict[str, Any] = {} + self._hass: HomeAssistant = _hass + self._config: ConfigEntry = _config + self._host: str + self._username: str + self._password: str + self._rscpkey: str if isinstance(_config, ConfigEntry): self._host = self._config.data.get(CONF_HOST) diff --git a/custom_components/e3dc_rscp/sensor.py b/custom_components/e3dc_rscp/sensor.py index 0cab7d7..da563ab 100644 --- a/custom_components/e3dc_rscp/sensor.py +++ b/custom_components/e3dc_rscp/sensor.py @@ -425,8 +425,6 @@ async def async_setup_entry( class E3DCSensor(CoordinatorEntity, SensorEntity): """Custom E3DC Sensor implementation.""" - coordinator: E3DCCoordinator - entity_description: SensorEntityDescription _attr_has_entity_name = True def __init__( @@ -437,7 +435,8 @@ def __init__( ) -> None: """Initialize the Sensor.""" super().__init__(coordinator) - self.entity_description = description + self.coordinator: E3DCCoordinator = coordinator + self.entity_description: SensorEntityDescription = description self._attr_unique_id = f"{uid}_{description.key}" @property diff --git a/custom_components/e3dc_rscp/switch.py b/custom_components/e3dc_rscp/switch.py index cc7e2f4..e32b18f 100644 --- a/custom_components/e3dc_rscp/switch.py +++ b/custom_components/e3dc_rscp/switch.py @@ -85,10 +85,7 @@ async def async_setup_entry( class E3DCSwitch(CoordinatorEntity, SwitchEntity): """Custom E3DC Switch Implementation.""" - coordinator: E3DCCoordinator - entity_description: E3DCSwitchEntityDescription _attr_has_entity_name = True - _has_custom_icons: bool = False def __init__( self, @@ -98,10 +95,11 @@ def __init__( ) -> None: """Initialize the Sensor.""" super().__init__(coordinator) - self.entity_description = description + self.coordinator: E3DCCoordinator = coordinator + self.entity_description: E3DCSwitchEntityDescription = description self._attr_is_on = self.coordinator.data.get(self.entity_description.key) self._attr_unique_id = f"{uid}_{description.key}" - self._has_custom_icons = ( + self._has_custom_icons: bool = ( self.entity_description.on_icon is not None and self.entity_description.off_icon is not None )