diff --git a/homeassistant/components/xs1/entity.py b/homeassistant/components/xs1/entity.py index c1ec43ec33c..61601066636 100644 --- a/homeassistant/components/xs1/entity.py +++ b/homeassistant/components/xs1/entity.py @@ -2,6 +2,8 @@ import asyncio +from xs1_api_client.device import XS1Device + from homeassistant.helpers.entity import Entity # Lock used to limit the amount of concurrent update requests @@ -13,7 +15,7 @@ UPDATE_LOCK = asyncio.Lock() class XS1DeviceEntity(Entity): """Representation of a base XS1 device.""" - def __init__(self, device): + def __init__(self, device: XS1Device) -> None: """Initialize the XS1 device.""" self.device = device diff --git a/homeassistant/components/xs1/sensor.py b/homeassistant/components/xs1/sensor.py index 26c009b15ee..d1411fe540b 100644 --- a/homeassistant/components/xs1/sensor.py +++ b/homeassistant/components/xs1/sensor.py @@ -3,6 +3,8 @@ from __future__ import annotations from xs1_api_client.api_constants import ActuatorType +from xs1_api_client.device.actuator import XS1Actuator +from xs1_api_client.device.sensor import XS1Sensor from homeassistant.components.sensor import SensorEntity from homeassistant.core import HomeAssistant @@ -20,8 +22,8 @@ def setup_platform( discovery_info: DiscoveryInfoType | None = None, ) -> None: """Set up the XS1 sensor platform.""" - sensors = hass.data[DOMAIN][SENSORS] - actuators = hass.data[DOMAIN][ACTUATORS] + sensors: list[XS1Sensor] = hass.data[DOMAIN][SENSORS] + actuators: list[XS1Actuator] = hass.data[DOMAIN][ACTUATORS] sensor_entities = [] for sensor in sensors: @@ -35,16 +37,16 @@ def setup_platform( break if not belongs_to_climate_actuator: - sensor_entities.append(XS1Sensor(sensor)) + sensor_entities.append(XS1SensorEntity(sensor)) add_entities(sensor_entities) -class XS1Sensor(XS1DeviceEntity, SensorEntity): +class XS1SensorEntity(XS1DeviceEntity, SensorEntity): """Representation of a Sensor.""" @property - def name(self): + def name(self) -> str: """Return the name of the sensor.""" return self.device.name() @@ -54,6 +56,6 @@ class XS1Sensor(XS1DeviceEntity, SensorEntity): return self.device.value() @property - def native_unit_of_measurement(self): + def native_unit_of_measurement(self) -> str: """Return the unit of measurement.""" return self.device.unit() diff --git a/homeassistant/components/xs1/switch.py b/homeassistant/components/xs1/switch.py index 5e107099515..232bd590c61 100644 --- a/homeassistant/components/xs1/switch.py +++ b/homeassistant/components/xs1/switch.py @@ -5,6 +5,7 @@ from __future__ import annotations from typing import Any from xs1_api_client.api_constants import ActuatorType +from xs1_api_client.device.actuator import XS1Actuator from homeassistant.components.switch import SwitchEntity from homeassistant.core import HomeAssistant @@ -22,7 +23,7 @@ def setup_platform( discovery_info: DiscoveryInfoType | None = None, ) -> None: """Set up the XS1 switch platform.""" - actuators = hass.data[DOMAIN][ACTUATORS] + actuators: list[XS1Actuator] = hass.data[DOMAIN][ACTUATORS] add_entities( XS1SwitchEntity(actuator) @@ -36,12 +37,12 @@ class XS1SwitchEntity(XS1DeviceEntity, SwitchEntity): """Representation of a XS1 switch actuator.""" @property - def name(self): + def name(self) -> str: """Return the name of the device if any.""" return self.device.name() @property - def is_on(self): + def is_on(self) -> bool: """Return true if switch is on.""" return self.device.value() == 100