Explorar el Código

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 hace 1 día
padre
commit
1c00a9f692
Se han modificado 1 ficheros con 8 adiciones y 0 borrados
  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,