Kaynağa Gözat

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 gün önce
ebeveyn
işleme
1c00a9f692
1 değiştirilmiş dosya ile 8 ekleme ve 0 silme
  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,