From 152022aef3abe37021899344a873a9533fa58b04 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 31 Aug 2022 22:16:21 +0200 Subject: [PATCH] Improve type hints in home_connect (#77587) --- homeassistant/components/home_connect/binary_sensor.py | 2 +- homeassistant/components/home_connect/light.py | 8 +++++--- homeassistant/components/home_connect/sensor.py | 4 ++-- homeassistant/components/home_connect/switch.py | 5 ----- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/home_connect/binary_sensor.py b/homeassistant/components/home_connect/binary_sensor.py index c00e8303b66..93b90cbfbd3 100644 --- a/homeassistant/components/home_connect/binary_sensor.py +++ b/homeassistant/components/home_connect/binary_sensor.py @@ -68,7 +68,7 @@ class HomeConnectBinarySensor(HomeConnectEntity, BinarySensorEntity): return bool(self._state) @property - def available(self): + def available(self) -> bool: """Return true if the binary sensor is available.""" return self._state is not None diff --git a/homeassistant/components/home_connect/light.py b/homeassistant/components/home_connect/light.py index c7418060eaf..17dc842358f 100644 --- a/homeassistant/components/home_connect/light.py +++ b/homeassistant/components/home_connect/light.py @@ -93,7 +93,7 @@ class HomeConnectLight(HomeConnectEntity, LightEntity): """Return the color property.""" return self._hs_color - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Switch the light on, change brightness, change color.""" if self._ambient: _LOGGER.debug("Switching ambient light on for: %s", self.name) @@ -121,7 +121,9 @@ class HomeConnectLight(HomeConnectEntity, LightEntity): hs_color = kwargs.get(ATTR_HS_COLOR, self._hs_color) if hs_color is not None: - rgb = color_util.color_hsv_to_RGB(*hs_color, brightness) + rgb = color_util.color_hsv_to_RGB( + hs_color[0], hs_color[1], brightness + ) hex_val = color_util.color_rgb_to_hex(rgb[0], rgb[1], rgb[2]) try: await self.hass.async_add_executor_job( @@ -165,7 +167,7 @@ class HomeConnectLight(HomeConnectEntity, LightEntity): _LOGGER.error("Error while trying to turn off light: %s", err) self.async_entity_update() - async def async_update(self): + async def async_update(self) -> None: """Update the light's status.""" if self.device.appliance.status.get(self._key, {}).get(ATTR_VALUE) is True: self._state = True diff --git a/homeassistant/components/home_connect/sensor.py b/homeassistant/components/home_connect/sensor.py index de409484f1e..38a45ccf709 100644 --- a/homeassistant/components/home_connect/sensor.py +++ b/homeassistant/components/home_connect/sensor.py @@ -49,11 +49,11 @@ class HomeConnectSensor(HomeConnectEntity, SensorEntity): @property def native_value(self): - """Return true if the binary sensor is on.""" + """Return sensor value.""" return self._state @property - def available(self): + def available(self) -> bool: """Return true if the sensor is available.""" return self._state is not None diff --git a/homeassistant/components/home_connect/switch.py b/homeassistant/components/home_connect/switch.py index 2278c2b1f2d..89b1f23589f 100644 --- a/homeassistant/components/home_connect/switch.py +++ b/homeassistant/components/home_connect/switch.py @@ -60,11 +60,6 @@ class HomeConnectProgramSwitch(HomeConnectEntity, SwitchEntity): """Return true if the switch is on.""" return bool(self._state) - @property - def available(self): - """Return true if the entity is available.""" - return True - async def async_turn_on(self, **kwargs: Any) -> None: """Start the program.""" _LOGGER.debug("Tried to turn on program %s", self.program_name)