Enable strict typing for deCONZ platforms binary_sensor+fan+logbook+number (#70171)
parent
03874d1b65
commit
506be5a818
|
@ -64,11 +64,15 @@ homeassistant.components.crownstone.*
|
|||
homeassistant.components.cpuspeed.*
|
||||
homeassistant.components.deconz
|
||||
homeassistant.components.deconz.alarm_control_panel
|
||||
homeassistant.components.deconz.binary_sensor
|
||||
homeassistant.components.deconz.climate
|
||||
homeassistant.components.deconz.config_flow
|
||||
homeassistant.components.deconz.diagnostics
|
||||
homeassistant.components.deconz.fan
|
||||
homeassistant.components.deconz.gateway
|
||||
homeassistant.components.deconz.light
|
||||
homeassistant.components.deconz.logbook
|
||||
homeassistant.components.deconz.number
|
||||
homeassistant.components.deconz.sensor
|
||||
homeassistant.components.deconz.services
|
||||
homeassistant.components.device_automation.*
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Support for deCONZ fans."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
from typing import Any, Literal
|
||||
|
||||
from pydeconz.light import (
|
||||
FAN_SPEED_25_PERCENT,
|
||||
|
@ -25,7 +25,7 @@ from homeassistant.util.percentage import (
|
|||
from .deconz_device import DeconzDevice
|
||||
from .gateway import DeconzGateway, get_gateway_from_config_entry
|
||||
|
||||
ORDERED_NAMED_FAN_SPEEDS = [
|
||||
ORDERED_NAMED_FAN_SPEEDS: list[Literal[0, 1, 2, 3, 4, 5, 6]] = [
|
||||
FAN_SPEED_25_PERCENT,
|
||||
FAN_SPEED_50_PERCENT,
|
||||
FAN_SPEED_75_PERCENT,
|
||||
|
@ -77,6 +77,7 @@ class DeconzFan(DeconzDevice, FanEntity):
|
|||
|
||||
TYPE = DOMAIN
|
||||
_device: Fan
|
||||
_default_on_speed: Literal[0, 1, 2, 3, 4, 5, 6]
|
||||
|
||||
_attr_supported_features = FanEntityFeature.SET_SPEED
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ from __future__ import annotations
|
|||
from collections.abc import Callable
|
||||
from dataclasses import dataclass
|
||||
|
||||
from pydeconz.sensor import PRESENCE_DELAY, Presence, SensorBase as PydeconzSensor
|
||||
from pydeconz.sensor import PRESENCE_DELAY, Presence
|
||||
|
||||
from homeassistant.components.number import (
|
||||
DOMAIN,
|
||||
|
@ -28,7 +28,7 @@ class DeconzNumberDescriptionMixin:
|
|||
|
||||
suffix: str
|
||||
update_key: str
|
||||
value_fn: Callable[[PydeconzSensor], float | None]
|
||||
value_fn: Callable[[Presence], float]
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -99,7 +99,10 @@ async def async_setup_entry(
|
|||
)
|
||||
|
||||
async_add_sensor(
|
||||
[gateway.api.sensors[key] for key in sorted(gateway.api.sensors, key=int)]
|
||||
[
|
||||
gateway.api.sensors[key]
|
||||
for key in sorted(gateway.api.sensors.presence, key=int)
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
|
@ -131,7 +134,7 @@ class DeconzNumber(DeconzDevice, NumberEntity):
|
|||
@property
|
||||
def value(self) -> float:
|
||||
"""Return the value of the sensor property."""
|
||||
return self.entity_description.value_fn(self._device) # type: ignore[no-any-return]
|
||||
return self.entity_description.value_fn(self._device)
|
||||
|
||||
async def async_set_value(self, value: float) -> None:
|
||||
"""Set sensor config."""
|
||||
|
|
56
mypy.ini
56
mypy.ini
|
@ -506,6 +506,17 @@ no_implicit_optional = true
|
|||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.deconz.binary_sensor]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
disallow_subclassing_any = true
|
||||
disallow_untyped_calls = true
|
||||
disallow_untyped_decorators = true
|
||||
disallow_untyped_defs = true
|
||||
no_implicit_optional = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.deconz.climate]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
|
@ -539,6 +550,17 @@ no_implicit_optional = true
|
|||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.deconz.fan]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
disallow_subclassing_any = true
|
||||
disallow_untyped_calls = true
|
||||
disallow_untyped_decorators = true
|
||||
disallow_untyped_defs = true
|
||||
no_implicit_optional = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.deconz.gateway]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
|
@ -561,6 +583,28 @@ no_implicit_optional = true
|
|||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.deconz.logbook]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
disallow_subclassing_any = true
|
||||
disallow_untyped_calls = true
|
||||
disallow_untyped_decorators = true
|
||||
disallow_untyped_defs = true
|
||||
no_implicit_optional = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.deconz.number]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
disallow_subclassing_any = true
|
||||
disallow_untyped_calls = true
|
||||
disallow_untyped_decorators = true
|
||||
disallow_untyped_defs = true
|
||||
no_implicit_optional = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.deconz.sensor]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
|
@ -2697,24 +2741,12 @@ ignore_errors = true
|
|||
[mypy-homeassistant.components.conversation.default_agent]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.deconz.binary_sensor]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.deconz.cover]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.deconz.fan]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.deconz.lock]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.deconz.logbook]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.deconz.number]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.deconz.siren]
|
||||
ignore_errors = true
|
||||
|
||||
|
|
|
@ -23,12 +23,8 @@ IGNORED_MODULES: Final[list[str]] = [
|
|||
"homeassistant.components.cloud.http_api",
|
||||
"homeassistant.components.conversation",
|
||||
"homeassistant.components.conversation.default_agent",
|
||||
"homeassistant.components.deconz.binary_sensor",
|
||||
"homeassistant.components.deconz.cover",
|
||||
"homeassistant.components.deconz.fan",
|
||||
"homeassistant.components.deconz.lock",
|
||||
"homeassistant.components.deconz.logbook",
|
||||
"homeassistant.components.deconz.number",
|
||||
"homeassistant.components.deconz.siren",
|
||||
"homeassistant.components.deconz.switch",
|
||||
"homeassistant.components.denonavr.config_flow",
|
||||
|
|
Loading…
Reference in New Issue