我正在用树莓做警报系统。这很简单。 当GPIO X上出现事件时,它会执行一些操作。我指定RaspberryPi,因为它会影响代码
我以一种非常简单的方式构建了代码,如果其中一个主机无法访问,那么代码就会停止。我是Python新手,我希望代码可以以任何一种方式工作,因为它是一个报警系统
首先,它可以尝试列出的每个设备,然后仅使用可用设备执行代码的其余部分
我使用了libsoundtouch模块,它非常有趣。查尔斯·布朗德的道具
HTTPConnectionPool(host='192.168.1.10',port=8090):url:/info超过最大重试次数(由NewConnectionError引起)(':无法建立新连接:[WinError 10060]
from libsoundtouch import soundtouch_device
from libsoundtouch.utils import Source, Type
import RPi.GPIO as GPIO
device1 = soundtouch_device('192.168.1.10')
device2 = soundtouch_device('192.168.1.20')
GPIO.setmode(GPIO.BOARD)
GPIO setup(19,GPIO.IN) # In for a switch
while True:
if (GPIO.input(19)):
device1.play_url('--------')
device2.play_url('--------')
IPdevice1 = 192.168.1.10
IPdevice2 = 192.168.1.20
Device1Up = true
#Ping
ping device1 if Up
device1Up= true
if device1Up = true
execute some code
*Be aware that I know this isn't real code*
目前没有回答
相关问题 更多 >
编程相关推荐