From b16d158dc2a6ba3559a35fe08a2d104296e09996 Mon Sep 17 00:00:00 2001 From: topsworld Date: Fri, 17 Jan 2025 12:00:15 +0800 Subject: [PATCH] fix: fix __init__ type error --- custom_components/xiaomi_home/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/custom_components/xiaomi_home/__init__.py b/custom_components/xiaomi_home/__init__.py index fcf114b..fb1b5c7 100644 --- a/custom_components/xiaomi_home/__init__.py +++ b/custom_components/xiaomi_home/__init__.py @@ -93,7 +93,7 @@ async def async_setup_entry( """Send messages in Notifications dialog box.""" if title: persistent_notification.async_create( - hass=hass, message=message, + hass=hass, message=message or '', title=title, notification_id=notify_id) else: persistent_notification.async_dismiss( @@ -126,9 +126,8 @@ async def async_setup_entry( miot_devices: list[MIoTDevice] = [] er = entity_registry.async_get(hass=hass) for did, info in miot_client.device_list.items(): - spec_instance: MIoTSpecInstance = await spec_parser.parse( - urn=info['urn']) - if spec_instance is None: + spec_instance = await spec_parser.parse(urn=info['urn']) + if not isinstance(spec_instance, MIoTSpecInstance): _LOGGER.error('spec content is None, %s, %s', did, info) continue device: MIoTDevice = MIoTDevice( @@ -156,7 +155,8 @@ async def async_setup_entry( for entity in filter_entities: device.entity_list[platform].remove(entity) entity_id = device.gen_service_entity_id( - ha_domain=platform, siid=entity.spec.iid) + ha_domain=platform, + siid=entity.spec.iid) # type: ignore if er.async_get(entity_id_or_uuid=entity_id): er.async_remove(entity_id=entity_id) if platform in device.prop_list: