File tree Expand file tree Collapse file tree
custom_components/keymaster/providers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -127,7 +127,9 @@ def _get_gateway(self) -> Any | None:
127127 return None
128128 try :
129129 return get_zha_gateway_proxy (self .hass )
130- except (KeyError , ValueError ):
130+ except KeyError :
131+ return None
132+ except ValueError :
131133 return None
132134
133135 def _get_door_lock_cluster (self ) -> DoorLock | None :
@@ -459,14 +461,20 @@ def handle_zha_event(event: Event) -> None:
459461 if operation is not None :
460462 try :
461463 op_val = DoorLock .OperationEvent (int (operation ))
462- except (TypeError , ValueError ):
464+ except TypeError :
465+ with contextlib .suppress (KeyError ):
466+ op_val = DoorLock .OperationEvent [str (operation )]
467+ except ValueError :
463468 with contextlib .suppress (KeyError ):
464469 op_val = DoorLock .OperationEvent [str (operation )]
465470
466471 if source is not None :
467472 try :
468473 src_val = DoorLock .OperationEventSource (int (source ))
469- except (TypeError , ValueError ):
474+ except TypeError :
475+ with contextlib .suppress (KeyError ):
476+ src_val = DoorLock .OperationEventSource [str (source )]
477+ except ValueError :
470478 with contextlib .suppress (KeyError ):
471479 src_val = DoorLock .OperationEventSource [str (source )]
472480
You can’t perform that action at this time.
0 commit comments