From 38a2f196b8f28d7c9e9921b74f47c223d34d2bca Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 2 Mar 2021 01:32:24 -0600 Subject: [PATCH] Fix typing on fan percentage (#47259) --- homeassistant/components/comfoconnect/fan.py | 3 ++- homeassistant/components/demo/fan.py | 4 ++-- homeassistant/components/esphome/fan.py | 2 +- homeassistant/components/insteon/fan.py | 2 +- homeassistant/components/isy994/fan.py | 6 +++--- homeassistant/components/lutron_caseta/fan.py | 3 ++- homeassistant/components/smartthings/fan.py | 2 +- homeassistant/components/wemo/fan.py | 2 +- homeassistant/components/wilight/fan.py | 4 +++- 9 files changed, 16 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/comfoconnect/fan.py b/homeassistant/components/comfoconnect/fan.py index 26abd85522a..d248bf74ac4 100644 --- a/homeassistant/components/comfoconnect/fan.py +++ b/homeassistant/components/comfoconnect/fan.py @@ -1,6 +1,7 @@ """Platform to control a Zehnder ComfoAir Q350/450/600 ventilation unit.""" import logging import math +from typing import Optional from pycomfoconnect import ( CMD_FAN_MODE_AWAY, @@ -95,7 +96,7 @@ class ComfoConnectFan(FanEntity): return SUPPORT_SET_SPEED @property - def percentage(self) -> str: + def percentage(self) -> Optional[int]: """Return the current speed percentage.""" speed = self._ccb.data.get(SENSOR_FAN_SPEED_MODE) if speed is None: diff --git a/homeassistant/components/demo/fan.py b/homeassistant/components/demo/fan.py index c79b53c0918..77d6f39a794 100644 --- a/homeassistant/components/demo/fan.py +++ b/homeassistant/components/demo/fan.py @@ -211,7 +211,7 @@ class DemoPercentageFan(BaseDemoFan, FanEntity): """A demonstration fan component that uses percentages.""" @property - def percentage(self) -> str: + def percentage(self) -> Optional[int]: """Return the current speed.""" return self._percentage @@ -271,7 +271,7 @@ class AsyncDemoPercentageFan(BaseDemoFan, FanEntity): """An async demonstration fan component that uses percentages.""" @property - def percentage(self) -> str: + def percentage(self) -> Optional[int]: """Return the current speed.""" return self._percentage diff --git a/homeassistant/components/esphome/fan.py b/homeassistant/components/esphome/fan.py index df23f37cb63..8cf28d6b2aa 100644 --- a/homeassistant/components/esphome/fan.py +++ b/homeassistant/components/esphome/fan.py @@ -111,7 +111,7 @@ class EsphomeFan(EsphomeEntity, FanEntity): return self._state.state @esphome_state_property - def percentage(self) -> Optional[str]: + def percentage(self) -> Optional[int]: """Return the current speed percentage.""" if not self._static_info.supports_speed: return None diff --git a/homeassistant/components/insteon/fan.py b/homeassistant/components/insteon/fan.py index a641d353450..cef19f57a9f 100644 --- a/homeassistant/components/insteon/fan.py +++ b/homeassistant/components/insteon/fan.py @@ -41,7 +41,7 @@ class InsteonFanEntity(InsteonEntity, FanEntity): """An INSTEON fan entity.""" @property - def percentage(self) -> str: + def percentage(self) -> int: """Return the current speed percentage.""" if self._insteon_device_group.value is None: return None diff --git a/homeassistant/components/isy994/fan.py b/homeassistant/components/isy994/fan.py index f565383f007..43323cc5546 100644 --- a/homeassistant/components/isy994/fan.py +++ b/homeassistant/components/isy994/fan.py @@ -1,6 +1,6 @@ """Support for ISY994 fans.""" import math -from typing import Callable +from typing import Callable, Optional from pyisy.constants import ISY_VALUE_UNKNOWN, PROTO_INSTEON @@ -43,7 +43,7 @@ class ISYFanEntity(ISYNodeEntity, FanEntity): """Representation of an ISY994 fan device.""" @property - def percentage(self) -> str: + def percentage(self) -> Optional[int]: """Return the current speed percentage.""" if self._node.status == ISY_VALUE_UNKNOWN: return None @@ -97,7 +97,7 @@ class ISYFanProgramEntity(ISYProgramEntity, FanEntity): """Representation of an ISY994 fan program.""" @property - def percentage(self) -> str: + def percentage(self) -> Optional[int]: """Return the current speed percentage.""" if self._node.status == ISY_VALUE_UNKNOWN: return None diff --git a/homeassistant/components/lutron_caseta/fan.py b/homeassistant/components/lutron_caseta/fan.py index edda379aedc..55799315ba0 100644 --- a/homeassistant/components/lutron_caseta/fan.py +++ b/homeassistant/components/lutron_caseta/fan.py @@ -1,5 +1,6 @@ """Support for Lutron Caseta fans.""" import logging +from typing import Optional from pylutron_caseta import FAN_HIGH, FAN_LOW, FAN_MEDIUM, FAN_MEDIUM_HIGH, FAN_OFF @@ -42,7 +43,7 @@ class LutronCasetaFan(LutronCasetaDevice, FanEntity): """Representation of a Lutron Caseta fan. Including Fan Speed.""" @property - def percentage(self) -> str: + def percentage(self) -> Optional[int]: """Return the current speed percentage.""" if self._device["fan_speed"] is None: return None diff --git a/homeassistant/components/smartthings/fan.py b/homeassistant/components/smartthings/fan.py index 4cd451e2416..ec133a1f6aa 100644 --- a/homeassistant/components/smartthings/fan.py +++ b/homeassistant/components/smartthings/fan.py @@ -76,7 +76,7 @@ class SmartThingsFan(SmartThingsEntity, FanEntity): return self._device.status.switch @property - def percentage(self) -> str: + def percentage(self) -> int: """Return the current speed percentage.""" return ranged_value_to_percentage(SPEED_RANGE, self._device.status.fan_speed) diff --git a/homeassistant/components/wemo/fan.py b/homeassistant/components/wemo/fan.py index 1f45194659d..d8f54057557 100644 --- a/homeassistant/components/wemo/fan.py +++ b/homeassistant/components/wemo/fan.py @@ -127,7 +127,7 @@ class WemoHumidifier(WemoSubscriptionEntity, FanEntity): } @property - def percentage(self) -> str: + def percentage(self) -> int: """Return the current speed percentage.""" return ranged_value_to_percentage(SPEED_RANGE, self._fan_mode) diff --git a/homeassistant/components/wilight/fan.py b/homeassistant/components/wilight/fan.py index d663dc39ded..35727b19927 100644 --- a/homeassistant/components/wilight/fan.py +++ b/homeassistant/components/wilight/fan.py @@ -1,5 +1,7 @@ """Support for WiLight Fan.""" +from typing import Optional + from pywilight.const import ( FAN_V1, ITEM_FAN, @@ -77,7 +79,7 @@ class WiLightFan(WiLightDevice, FanEntity): return self._status.get("direction", WL_DIRECTION_OFF) != WL_DIRECTION_OFF @property - def percentage(self) -> str: + def percentage(self) -> Optional[int]: """Return the current speed percentage.""" if "direction" in self._status: if self._status["direction"] == WL_DIRECTION_OFF: