Remove xiaomi_aqara from mypy ignore list (#73526)

pull/71867/head
epenet 2022-06-15 10:45:47 +02:00 committed by GitHub
parent 17eb8c95dd
commit 94a8fe0052
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 24 deletions

View File

@ -82,7 +82,7 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
def play_ringtone_service(call: ServiceCall) -> None:
"""Service to play ringtone through Gateway."""
ring_id = call.data.get(ATTR_RINGTONE_ID)
gateway = call.data.get(ATTR_GW_MAC)
gateway: XiaomiGateway = call.data[ATTR_GW_MAC]
kwargs = {"mid": ring_id}
@ -93,12 +93,12 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
def stop_ringtone_service(call: ServiceCall) -> None:
"""Service to stop playing ringtone on Gateway."""
gateway = call.data.get(ATTR_GW_MAC)
gateway: XiaomiGateway = call.data[ATTR_GW_MAC]
gateway.write_to_hub(gateway.sid, mid=10000)
def add_device_service(call: ServiceCall) -> None:
"""Service to add a new sub-device within the next 30 seconds."""
gateway = call.data.get(ATTR_GW_MAC)
gateway: XiaomiGateway = call.data[ATTR_GW_MAC]
gateway.write_to_hub(gateway.sid, join_permission="yes")
persistent_notification.async_create(
hass,
@ -110,7 +110,7 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
def remove_device_service(call: ServiceCall) -> None:
"""Service to remove a sub-device from the gateway."""
device_id = call.data.get(ATTR_DEVICE_ID)
gateway = call.data.get(ATTR_GW_MAC)
gateway: XiaomiGateway = call.data[ATTR_GW_MAC]
gateway.write_to_hub(gateway.sid, remove_device=device_id)
gateway_only_schema = _add_gateway_to_schema(hass, vol.Schema({}))
@ -181,6 +181,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
entry.data[CONF_HOST],
)
assert entry.unique_id
device_registry = dr.async_get(hass)
device_registry.async_get_or_create(
config_entry_id=entry.entry_id,

View File

@ -34,7 +34,7 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Perform the setup for Xiaomi devices."""
entities = []
entities: list[XiaomiBinarySensor] = []
gateway = hass.data[DOMAIN][GATEWAYS_KEY][config_entry.entry_id]
for entity in gateway.devices["binary_sensor"]:
model = entity["model"]

View File

@ -1,4 +1,6 @@
"""Support for Xiaomi Aqara locks."""
from __future__ import annotations
from homeassistant.components.lock import LockEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED
@ -44,13 +46,14 @@ class XiaomiAqaraLock(LockEntity, XiaomiDevice):
super().__init__(device, name, xiaomi_hub, config_entry)
@property
def is_locked(self) -> bool:
def is_locked(self) -> bool | None:
"""Return true if lock is locked."""
if self._state is not None:
return self._state == STATE_LOCKED
return None
@property
def changed_by(self) -> int:
def changed_by(self) -> str:
"""Last change triggered by."""
return self._changed_by

View File

@ -88,7 +88,7 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Perform the setup for Xiaomi devices."""
entities = []
entities: list[XiaomiSensor | XiaomiBatterySensor] = []
gateway = hass.data[DOMAIN][GATEWAYS_KEY][config_entry.entry_id]
for device in gateway.devices["sensor"]:
if device["model"] == "sensor_ht":

View File

@ -2976,18 +2976,6 @@ ignore_errors = true
[mypy-homeassistant.components.xbox.sensor]
ignore_errors = true
[mypy-homeassistant.components.xiaomi_aqara]
ignore_errors = true
[mypy-homeassistant.components.xiaomi_aqara.binary_sensor]
ignore_errors = true
[mypy-homeassistant.components.xiaomi_aqara.lock]
ignore_errors = true
[mypy-homeassistant.components.xiaomi_aqara.sensor]
ignore_errors = true
[mypy-homeassistant.components.xiaomi_miio]
ignore_errors = true

View File

@ -141,10 +141,6 @@ IGNORED_MODULES: Final[list[str]] = [
"homeassistant.components.xbox.browse_media",
"homeassistant.components.xbox.media_source",
"homeassistant.components.xbox.sensor",
"homeassistant.components.xiaomi_aqara",
"homeassistant.components.xiaomi_aqara.binary_sensor",
"homeassistant.components.xiaomi_aqara.lock",
"homeassistant.components.xiaomi_aqara.sensor",
"homeassistant.components.xiaomi_miio",
"homeassistant.components.xiaomi_miio.air_quality",
"homeassistant.components.xiaomi_miio.binary_sensor",