Fix typing on fan percentage (#47259)

This commit is contained in:
J. Nick Koston 2021-03-02 01:32:24 -06:00 committed by GitHub
parent 7e71050669
commit 38a2f196b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 16 additions and 12 deletions

View file

@ -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:

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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: