Skip to content

Commit f6838ff

Browse files
committed
Fix KeyError for gpiozero digital_outputs flyte#414
1 parent 678276f commit f6838ff

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: mqtt_io/modules/gpio/gpiozero.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,14 @@ def set_pin(self, pin: PinType, value: bool) -> None:
8080
self._out_pins[pin].on()
8181
else:
8282
self._out_pins[pin].off()
83-
83+
8484
def get_pin(self, pin: PinType) -> bool:
85-
return cast(bool, self._in_pins[pin].is_active)
85+
if pin in self._in_pins:
86+
return cast(bool, self._in_pins[pin].is_active)
87+
elif pin in self._out_pins:
88+
return bool(self._out_pins[pin].value)
89+
else:
90+
raise ValueError(f"Pin {pin} not found")
8691

8792
def setup_interrupt_callback(
8893
self,

0 commit comments

Comments
 (0)