Skip to content

Commit

Permalink
Update gpio_any_wan_connected.py
Browse files Browse the repository at this point in the history
added state tracking and logging
  • Loading branch information
phate999 authored Dec 18, 2024
1 parent a64953f commit 21003d1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gpio_any_wan_connected/gpio_any_wan_connected.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import time
cp = EventingCSClient('gpio_any_wan_connected')
cp.log('Starting...')
previous_state = None
while True:
state = int(cp.get('status/wan/connection_state') == 'connected')
cp.put('control/gpio/CONNECTOR_GPIO_1', state)
if state != previous_state:
cp.put('control/gpio/ACCESSORY_GPIO_1', state)
cp.log(f'Set control/gpio/ACCESSORY_GPIO_1 to {state}')
previous_state = state
time.sleep(1)

0 comments on commit 21003d1

Please sign in to comment.