Update doorbell.py
This commit is contained in:
@@ -17,5 +17,11 @@ while True:
|
|||||||
if data:
|
if data:
|
||||||
data = data.decode('utf8')
|
data = data.decode('utf8')
|
||||||
if (data == 'RING'):
|
if (data == 'RING'):
|
||||||
logging.info(data)
|
try:
|
||||||
urllib.request.urlopen('http://192.168.178.51/bell/on')
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user