瀏覽代碼

fix(event): ignore unknown event types

HA throws an exception if we try to trigger an event that was not declared up front.
Ignore unknown values that we receive instead of blinding triggering them.

Should avoid the underlying issue that is fixed for one specific device in PR #5091
Jason Rumney 1 天之前
父節點
當前提交
1c00a9f692
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      custom_components/tuya_local/event.py

+ 8 - 0
custom_components/tuya_local/event.py

@@ -77,6 +77,14 @@ class TuyaLocalEvent(TuyaLocalEntity, EventEntity):
                     value,
                     value,
                 )
                 )
                 self._last_value = value
                 self._last_value = value
+                if value not in self._attr_event_types:
+                    _LOGGER.warning(
+                        "%s/%s received value %s not in event types, ignoring",
+                        self._config._device.config,
+                        self.name or "event",
+                        value,
+                    )
+                    return
                 self._trigger_event(
                 self._trigger_event(
                     value,
                     value,
                     self.extra_state_attributes,
                     self.extra_state_attributes,