Skip to content

Commit

Permalink
Fix KeyError for gpiozero digital_outputs flyte#414
Browse files Browse the repository at this point in the history
  • Loading branch information
arturalbov committed Oct 20, 2024
1 parent 678276f commit f6838ff
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mqtt_io/modules/gpio/gpiozero.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ def set_pin(self, pin: PinType, value: bool) -> None:
self._out_pins[pin].on()
else:
self._out_pins[pin].off()

def get_pin(self, pin: PinType) -> bool:
return cast(bool, self._in_pins[pin].is_active)
if pin in self._in_pins:
return cast(bool, self._in_pins[pin].is_active)
elif pin in self._out_pins:
return bool(self._out_pins[pin].value)
else:
raise ValueError(f"Pin {pin} not found")

def setup_interrupt_callback(
self,
Expand Down

0 comments on commit f6838ff

Please sign in to comment.