Enable strict typing for duotecno (#107261)
This commit is contained in:
parent
de72bbfaad
commit
b2a4de6eed
8 changed files with 29 additions and 15 deletions
|
@ -144,6 +144,7 @@ homeassistant.components.dormakaba_dkey.*
|
|||
homeassistant.components.downloader.*
|
||||
homeassistant.components.dsmr.*
|
||||
homeassistant.components.dunehd.*
|
||||
homeassistant.components.duotecno.*
|
||||
homeassistant.components.efergy.*
|
||||
homeassistant.components.electrasmart.*
|
||||
homeassistant.components.electric_kiwi.*
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
"""Support for Duotecno binary sensors."""
|
||||
from __future__ import annotations
|
||||
|
||||
from duotecno.controller import PyDuotecno
|
||||
from duotecno.unit import ControlUnit, VirtualUnit
|
||||
|
||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
||||
|
@ -17,7 +19,7 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up Duotecno binary sensor on config_entry."""
|
||||
cntrl = hass.data[DOMAIN][entry.entry_id]
|
||||
cntrl: PyDuotecno = hass.data[DOMAIN][entry.entry_id]
|
||||
async_add_entities(
|
||||
DuotecnoBinarySensor(channel)
|
||||
for channel in cntrl.get_units(["ControlUnit", "VirtualUnit"])
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
"""Support for Duotecno climate devices."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Final
|
||||
|
||||
from duotecno.controller import PyDuotecno
|
||||
from duotecno.unit import SensUnit
|
||||
|
||||
from homeassistant.components.climate import (
|
||||
|
@ -33,7 +36,7 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up Duotecno climate based on config_entry."""
|
||||
cntrl = hass.data[DOMAIN][entry.entry_id]
|
||||
cntrl: PyDuotecno = hass.data[DOMAIN][entry.entry_id]
|
||||
async_add_entities(
|
||||
DuotecnoClimate(channel) for channel in cntrl.get_units(["SensUnit"])
|
||||
)
|
||||
|
|
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
|
||||
from typing import Any
|
||||
|
||||
from duotecno.controller import PyDuotecno
|
||||
from duotecno.unit import DuoswitchUnit
|
||||
|
||||
from homeassistant.components.cover import CoverEntity, CoverEntityFeature
|
||||
|
@ -20,7 +21,7 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the duoswitch endities."""
|
||||
cntrl = hass.data[DOMAIN][entry.entry_id]
|
||||
cntrl: PyDuotecno = hass.data[DOMAIN][entry.entry_id]
|
||||
async_add_entities(
|
||||
DuotecnoCover(channel) for channel in cntrl.get_units("DuoswitchUnit")
|
||||
)
|
||||
|
@ -30,13 +31,9 @@ class DuotecnoCover(DuotecnoEntity, CoverEntity):
|
|||
"""Representation a Velbus cover."""
|
||||
|
||||
_unit: DuoswitchUnit
|
||||
|
||||
def __init__(self, unit: DuoswitchUnit) -> None:
|
||||
"""Initialize the cover."""
|
||||
super().__init__(unit)
|
||||
self._attr_supported_features = (
|
||||
CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE | CoverEntityFeature.STOP
|
||||
)
|
||||
_attr_supported_features = (
|
||||
CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE | CoverEntityFeature.STOP
|
||||
)
|
||||
|
||||
@property
|
||||
def is_closed(self) -> bool | None:
|
||||
|
|
|
@ -17,10 +17,9 @@ from .const import DOMAIN
|
|||
class DuotecnoEntity(Entity):
|
||||
"""Representation of a Duotecno entity."""
|
||||
|
||||
_attr_should_poll: bool = False
|
||||
_unit: BaseUnit
|
||||
_attr_should_poll = False
|
||||
|
||||
def __init__(self, unit) -> None:
|
||||
def __init__(self, unit: BaseUnit) -> None:
|
||||
"""Initialize a Duotecno entity."""
|
||||
self._unit = unit
|
||||
self._attr_name = unit.get_name()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Support for Duotecno lights."""
|
||||
from typing import Any
|
||||
|
||||
from duotecno.controller import PyDuotecno
|
||||
from duotecno.unit import DimUnit
|
||||
|
||||
from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEntity
|
||||
|
@ -18,7 +19,7 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up Duotecno light based on config_entry."""
|
||||
cntrl = hass.data[DOMAIN][entry.entry_id]
|
||||
cntrl: PyDuotecno = hass.data[DOMAIN][entry.entry_id]
|
||||
async_add_entities(DuotecnoLight(channel) for channel in cntrl.get_units("DimUnit"))
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Support for Duotecno switches."""
|
||||
from typing import Any
|
||||
|
||||
from duotecno.controller import PyDuotecno
|
||||
from duotecno.unit import SwitchUnit
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
|
@ -18,7 +19,7 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up Velbus switch based on config_entry."""
|
||||
cntrl = hass.data[DOMAIN][entry.entry_id]
|
||||
cntrl: PyDuotecno = hass.data[DOMAIN][entry.entry_id]
|
||||
async_add_entities(
|
||||
DuotecnoSwitch(channel) for channel in cntrl.get_units("SwitchUnit")
|
||||
)
|
||||
|
|
10
mypy.ini
10
mypy.ini
|
@ -1201,6 +1201,16 @@ disallow_untyped_defs = true
|
|||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.duotecno.*]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
disallow_subclassing_any = true
|
||||
disallow_untyped_calls = true
|
||||
disallow_untyped_decorators = true
|
||||
disallow_untyped_defs = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.efergy.*]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
|
|
Loading…
Add table
Reference in a new issue