device_listener = DeviceNodeOutput() push_listener = PushNodeOutput(atv) atv.power.listener = power_listener atv.listener = device_listener atv.push_updater.listener = push_listener atv.push_updater.start() await atv.power.turn_off() #Turn off Apple TV after reconnect hg.nodeOutput(0, {"payload": True}) while hg.connected(): await asyncio.sleep(1) finally: atv.close() return 0 # hg waits until the connection is established (but for a maximum of 2 seonds). # The socket path is passed in sys.argv[1], the node's ID in sys.argv[2] hg = Homegear(sys.argv[1], eventHandler, sys.argv[2], nodeInput); # Wait for the flows to start. startUpComplete.acquire() while hg.connected(): if startUpComplete.wait(1) == True: break startUpComplete.release() # The node is now fully started. Start event loop. loop.run_until_complete(appstart(loop, hg))
# needed when you access non local variables. print("Event handler called with arguments: peerId: " + str(peerId) + "; channel: " + str(channel) + "; variable name: " + variableName + "; value: " + str(value)) hg = Homegear("/var/run/homegear/homegearIPC.sock", eventHandler) # hg waits until the connection is established (but for a maximum of 2 seonds). hg.setSystemVariable("TEST", 6) print("getSystemVariable(\"TEST\") after setting \"TEST\" to 6: ", hg.getSystemVariable("TEST")) hg.setSystemVariable("TEST", ["One", 2, 3.3]) print("getSystemVariable(\"TEST\") after setting \"TEST\" to an array: ", hg.getSystemVariable("TEST")) hg.setSystemVariable("TEST", { "One": 1, 2: "Two", 3: [3, 3, 3] }) print("getSystemVariable(\"TEST\") after setting \"TEST\" to a struct: ", hg.getSystemVariable("TEST")) counter = 0 while (hg.connected()): time.sleep(1) counter += 1 hg.setSystemVariable("TEST", counter)