diff --git a/homeassistant/components/ads/binary_sensor.py b/homeassistant/components/ads/binary_sensor.py index 4704026e454..72a12506dc1 100644 --- a/homeassistant/components/ads/binary_sensor.py +++ b/homeassistant/components/ads/binary_sensor.py @@ -19,6 +19,7 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from .const import CONF_ADS_VAR, DATA_ADS, STATE_KEY_STATE from .entity import AdsEntity +from .hub import AdsHub DEFAULT_NAME = "ADS binary sensor" PLATFORM_SCHEMA = BINARY_SENSOR_PLATFORM_SCHEMA.extend( @@ -50,7 +51,13 @@ def setup_platform( class AdsBinarySensor(AdsEntity, BinarySensorEntity): """Representation of ADS binary sensors.""" - def __init__(self, ads_hub, name, ads_var, device_class): + def __init__( + self, + ads_hub: AdsHub, + name: str, + ads_var: str, + device_class: BinarySensorDeviceClass | None, + ) -> None: """Initialize ADS binary sensor.""" super().__init__(ads_hub, name, ads_var) self._attr_device_class = device_class or BinarySensorDeviceClass.MOVING diff --git a/homeassistant/components/ads/cover.py b/homeassistant/components/ads/cover.py index 31c1eac5d18..541f8bfc82c 100644 --- a/homeassistant/components/ads/cover.py +++ b/homeassistant/components/ads/cover.py @@ -23,6 +23,7 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from .const import CONF_ADS_VAR, DATA_ADS, STATE_KEY_STATE from .entity import AdsEntity +from .hub import AdsHub DEFAULT_NAME = "ADS Cover" @@ -57,7 +58,7 @@ def setup_platform( """Set up the cover platform for ADS.""" ads_hub = hass.data[DATA_ADS] - ads_var_is_closed: str | None = config.get(CONF_ADS_VAR) + ads_var_is_closed: str = config[CONF_ADS_VAR] ads_var_position: str | None = config.get(CONF_ADS_VAR_POSITION) ads_var_pos_set: str | None = config.get(CONF_ADS_VAR_SET_POS) ads_var_open: str | None = config.get(CONF_ADS_VAR_OPEN) @@ -88,16 +89,16 @@ class AdsCover(AdsEntity, CoverEntity): def __init__( self, - ads_hub, - ads_var_is_closed, - ads_var_position, - ads_var_pos_set, - ads_var_open, - ads_var_close, - ads_var_stop, - name, - device_class, - ): + ads_hub: AdsHub, + ads_var_is_closed: str, + ads_var_position: str | None, + ads_var_pos_set: str | None, + ads_var_open: str | None, + ads_var_close: str | None, + ads_var_stop: str | None, + name: str, + device_class: CoverDeviceClass | None, + ) -> None: """Initialize AdsCover entity.""" super().__init__(ads_hub, name, ads_var_is_closed) if self._attr_unique_id is None: diff --git a/homeassistant/components/ads/entity.py b/homeassistant/components/ads/entity.py index 3973d279a22..f51ede2bbc8 100644 --- a/homeassistant/components/ads/entity.py +++ b/homeassistant/components/ads/entity.py @@ -3,10 +3,12 @@ import asyncio from asyncio import timeout import logging +from typing import Any from homeassistant.helpers.entity import Entity from .const import STATE_KEY_STATE +from .hub import AdsHub _LOGGER = logging.getLogger(__name__) @@ -16,19 +18,23 @@ class AdsEntity(Entity): _attr_should_poll = False - def __init__(self, ads_hub, name, ads_var): + def __init__(self, ads_hub: AdsHub, name: str, ads_var: str) -> None: """Initialize ADS binary sensor.""" - self._state_dict = {} + self._state_dict: dict[str, Any] = {} self._state_dict[STATE_KEY_STATE] = None self._ads_hub = ads_hub self._ads_var = ads_var - self._event = None + self._event: asyncio.Event | None = None self._attr_unique_id = ads_var self._attr_name = name async def async_initialize_device( - self, ads_var, plctype, state_key=STATE_KEY_STATE, factor=None - ): + self, + ads_var: str, + plctype: type, + state_key: str = STATE_KEY_STATE, + factor: int | None = None, + ) -> None: """Register device notification.""" def update(name, value): diff --git a/homeassistant/components/ads/light.py b/homeassistant/components/ads/light.py index 17e94923b01..5ea4868bf11 100644 --- a/homeassistant/components/ads/light.py +++ b/homeassistant/components/ads/light.py @@ -21,6 +21,7 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from .const import CONF_ADS_VAR, DATA_ADS, STATE_KEY_STATE from .entity import AdsEntity +from .hub import AdsHub CONF_ADS_VAR_BRIGHTNESS = "adsvar_brightness" STATE_KEY_BRIGHTNESS = "brightness" @@ -54,7 +55,13 @@ def setup_platform( class AdsLight(AdsEntity, LightEntity): """Representation of ADS light.""" - def __init__(self, ads_hub, ads_var_enable, ads_var_brightness, name): + def __init__( + self, + ads_hub: AdsHub, + ads_var_enable: str, + ads_var_brightness: str | None, + name: str, + ) -> None: """Initialize AdsLight entity.""" super().__init__(ads_hub, name, ads_var_enable) self._state_dict[STATE_KEY_BRIGHTNESS] = None diff --git a/homeassistant/components/ads/valve.py b/homeassistant/components/ads/valve.py index f20e21477db..b94215ec9ea 100644 --- a/homeassistant/components/ads/valve.py +++ b/homeassistant/components/ads/valve.py @@ -45,11 +45,8 @@ def setup_platform( ads_var: str = config[CONF_ADS_VAR] name: str = config[CONF_NAME] device_class: ValveDeviceClass | None = config.get(CONF_DEVICE_CLASS) - supported_features: ValveEntityFeature = ( - ValveEntityFeature.OPEN | ValveEntityFeature.CLOSE - ) - entity = AdsValve(ads_hub, ads_var, name, device_class, supported_features) + entity = AdsValve(ads_hub, ads_var, name, device_class) add_entities([entity]) @@ -57,18 +54,18 @@ def setup_platform( class AdsValve(AdsEntity, ValveEntity): """Representation of an ADS valve entity.""" + _attr_supported_features = ValveEntityFeature.OPEN | ValveEntityFeature.CLOSE + def __init__( self, ads_hub: AdsHub, ads_var: str, name: str, device_class: ValveDeviceClass | None, - supported_features: ValveEntityFeature, ) -> None: """Initialize AdsValve entity.""" super().__init__(ads_hub, name, ads_var) self._attr_device_class = device_class - self._attr_supported_features = supported_features self._attr_reports_position = False self._attr_is_closed = True