Преглед изворни кода

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 пре 4 дана
родитељ
комит
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,
                 )
                 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,