fix: ignore undefined piid and keep processing following arguments (#377)

This commit is contained in:
RangerCD 2024-12-24 21:03:11 +08:00 committed by GitHub
parent 0f5da18108
commit 7654e5e518
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1198,8 +1198,8 @@ class MIoTEventEntity(Entity):
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 @@ class MIoTEventEntity(Entity):
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()