Skip to content

Instantly share code, notes, and snippets.

@anthonyeden
Created January 28, 2020 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonyeden/b040e4f8037fa1169dcc10667aac91e6 to your computer and use it in GitHub Desktop.
Save anthonyeden/b040e4f8037fa1169dcc10667aac91e6 to your computer and use it in GitHub Desktop.
LWRP Example: Silence Detection & GPIO
# Requires https://github.com/anthonyeden/Livewire-Routing-Protocol-Client
import time
from LWRPClient import LWRPClient
# Connect to audio node
LWRP_Audio = LWRPClient("192.168.1.5", 93)
LWRP_Audio.login()
# Connect to GPIO node
LWRP_Logic = LWRPClient("192.168.1.5", 93)
LWRP_Logic.login()
def silence(data):
# TODO: Add some logic here to work out which channel is silent
print(data)
# Set the new GPO state
# 1 = Channel
# 2 = Pin
# 3 = State
LWRP_Logic.setGPO("1", "2", "low")
if __name__ == "__main__":
# Create a subscription for silence events
LWRP_Audio.levelAlertSub(silence)
# Loop forever while the callbacks execute in another thread
while True:
time.sleep(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment