From 7654e5e5184360a0a347e6be08d6f6a79c70246f Mon Sep 17 00:00:00 2001 From: RangerCD Date: Tue, 24 Dec 2024 21:03:11 +0800 Subject: [PATCH] fix: ignore undefined piid and keep processing following arguments (#377) --- custom_components/xiaomi_home/miot/miot_device.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/custom_components/xiaomi_home/miot/miot_device.py b/custom_components/xiaomi_home/miot/miot_device.py index 103a7c3..47e2bc1 100644 --- a/custom_components/xiaomi_home/miot/miot_device.py +++ b/custom_components/xiaomi_home/miot/miot_device.py @@ -1198,8 +1198,8 @@ def on_event_occurred( def __on_event_occurred(self, params: dict, ctx: Any) -> None: _LOGGER.debug('event occurred, %s', params) trans_arg = {} - try: - for item in params['arguments']: + for item in params['arguments']: + try: if 'value' not in item: continue if 'piid' in item: @@ -1215,10 +1215,10 @@ def __on_event_occurred(self, params: dict, ctx: Any) -> None: for index, prop in enumerate(self.spec.argument) } break - except KeyError as error: - _LOGGER.error( - 'on event msg, invalid args, %s, %s, %s', - self.entity_id, params, error) + except KeyError as error: + _LOGGER.debug( + 'on event msg, invalid args, %s, %s, %s', + self.entity_id, params, error) self.on_event_occurred( name=self.spec.description_trans, arguments=trans_arg) self.async_write_ha_state()