Update doorbell.py

This commit is contained in:
2020-09-02 07:28:27 +00:00
parent 847917f056
commit 568a9a2528
+7 -1
View File
@@ -17,5 +17,11 @@ while True:
if data:
data = data.decode('utf8')
if (data == 'RING'):
try:
response = urllib.request.urlopen('http://192.168.178.51/bell/on', timeout=5).read().decode('utf-8')
except (HTTPError, URLError, OSError) as error:
logging.error('Data of %s not retrieved because %s\nURL: %s', name, error, url)
except timeout:
logging.error('socket timed out - URL %s', url)
else:
logging.info(data)
urllib.request.urlopen('http://192.168.178.51/bell/on')