Fix type hints in zha remaining channels (#73778)

* Fix hvac channel type hints

* Fix security channel type hints

* Fix homeautomation channel type hints

* Fix type hints in zha base channel

* Adjust select entity

* Remove unused arg
This commit is contained in:
epenet 2022-06-24 16:35:38 +02:00 committed by GitHub
parent f29cc33fa0
commit b880a05e45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 17 additions and 35 deletions

View file

@ -370,7 +370,7 @@ class ChannelPool:
return [self.all_channels[chan_id] for chan_id in (available - claimed)]
@callback
def zha_send_event(self, event_data: dict[str, str | int]) -> None:
def zha_send_event(self, event_data: dict[str, Any]) -> None:
"""Relay events to hass."""
self._channels.zha_send_event(
{

View file

@ -137,7 +137,7 @@ class ZigbeeChannel(LogMixin):
self.value_attribute = attr
self._status = ChannelStatus.CREATED
self._cluster.add_listener(self)
self.data_cache = {}
self.data_cache: dict[str, Enum] = {}
@property
def id(self) -> str:
@ -278,7 +278,7 @@ class ZigbeeChannel(LogMixin):
)
def _configure_reporting_status(
self, attrs: dict[int | str, tuple], res: list | tuple
self, attrs: dict[int | str, tuple[int, int, float | int]], res: list | tuple
) -> None:
"""Parse configure reporting result."""
if isinstance(res, (Exception, ConfigureReportingResponseRecord)):
@ -304,10 +304,10 @@ class ZigbeeChannel(LogMixin):
for r in res
if r.status != Status.SUCCESS
]
attrs = {self.cluster.attributes.get(r, [r])[0] for r in attrs}
attributes = {self.cluster.attributes.get(r, [r])[0] for r in attrs}
self.debug(
"Successfully configured reporting for '%s' on '%s' cluster",
attrs - set(failed),
attributes - set(failed),
self.name,
)
self.debug(
@ -393,6 +393,7 @@ class ZigbeeChannel(LogMixin):
def zha_send_event(self, command: str, arg: list | dict | CommandSchema) -> None:
"""Relay events to hass."""
args: list | dict
if isinstance(arg, CommandSchema):
args = [a for a in arg if a is not None]
params = arg.as_dict()

View file

@ -158,7 +158,11 @@ class ElectricalMeasurementChannel(ZigbeeChannel):
return None
meas_type = self.MeasurementType(meas_type)
return ", ".join(m.name for m in self.MeasurementType if m in meas_type)
return ", ".join(
m.name
for m in self.MeasurementType
if m in meas_type and m.name is not None
)
@registries.ZIGBEE_CHANNEL_REGISTRY.register(

View file

@ -293,6 +293,7 @@ class ThermostatChannel(ZigbeeChannel):
return bool(self.occupancy)
except ZigbeeException as ex:
self.debug("Couldn't read 'occupancy' attribute: %s", ex)
return None
async def write_attributes(self, data, **kwargs):
"""Write attributes helper."""

View file

@ -199,26 +199,17 @@ class IasAce(ZigbeeChannel):
def _emergency(self) -> None:
"""Handle the IAS ACE emergency command."""
self._set_alarm(
AceCluster.AlarmStatus.Emergency,
IAS_ACE_EMERGENCY,
)
self._set_alarm(AceCluster.AlarmStatus.Emergency)
def _fire(self) -> None:
"""Handle the IAS ACE fire command."""
self._set_alarm(
AceCluster.AlarmStatus.Fire,
IAS_ACE_FIRE,
)
self._set_alarm(AceCluster.AlarmStatus.Fire)
def _panic(self) -> None:
"""Handle the IAS ACE panic command."""
self._set_alarm(
AceCluster.AlarmStatus.Emergency_Panic,
IAS_ACE_PANIC,
)
self._set_alarm(AceCluster.AlarmStatus.Emergency_Panic)
def _set_alarm(self, status: AceCluster.PanelStatus, event: str) -> None:
def _set_alarm(self, status: AceCluster.AlarmStatus) -> None:
"""Set the specified alarm status."""
self.alarm_status = status
self.armed_state = AceCluster.PanelStatus.In_Alarm

View file

@ -64,6 +64,7 @@ class ZHAEnumSelectEntity(ZhaEntity, SelectEntity):
"""Representation of a ZHA select entity."""
_attr_entity_category = EntityCategory.CONFIG
_attr_name: str
_enum: type[Enum]
def __init__(

View file

@ -2996,18 +2996,6 @@ ignore_errors = true
[mypy-homeassistant.components.xiaomi_miio.switch]
ignore_errors = true
[mypy-homeassistant.components.zha.core.channels.base]
ignore_errors = true
[mypy-homeassistant.components.zha.core.channels.homeautomation]
ignore_errors = true
[mypy-homeassistant.components.zha.core.channels.hvac]
ignore_errors = true
[mypy-homeassistant.components.zha.core.channels.security]
ignore_errors = true
[mypy-homeassistant.components.zha.core.device]
ignore_errors = true

View file

@ -144,10 +144,6 @@ IGNORED_MODULES: Final[list[str]] = [
"homeassistant.components.xiaomi_miio.light",
"homeassistant.components.xiaomi_miio.sensor",
"homeassistant.components.xiaomi_miio.switch",
"homeassistant.components.zha.core.channels.base",
"homeassistant.components.zha.core.channels.homeautomation",
"homeassistant.components.zha.core.channels.hvac",
"homeassistant.components.zha.core.channels.security",
"homeassistant.components.zha.core.device",
"homeassistant.components.zha.core.discovery",
"homeassistant.components.zha.core.gateway",