Procházet zdrojové kódy

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 před 1 dnem
rodič
revize
1c00a9f692
1 změnil soubory, kde provedl 8 přidání a 0 odebrání
  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,
                 )
                 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(
                     value,
                     self.extra_state_attributes,