added checking for phone
This commit is contained in:
parent
deb35fe160
commit
0c5729d7c5
23
alarm.py
23
alarm.py
@ -3,10 +3,27 @@ import spotframework.net.network as networkclass
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
def checkPhone():
|
||||||
|
|
||||||
|
response = os.system("ping -c 1 -w5 " + os.environ['PHONEIP'] + " > /dev/null 2>&1")
|
||||||
|
print('checking for phone')
|
||||||
|
if response == 0:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
network = networkclass.network(userclass.User())
|
network = networkclass.network(userclass.User())
|
||||||
|
|
||||||
network.play(os.environ['SPOTALARMURI'], network.getDeviceID(os.environ['SPOTALARMDEVICENAME']))
|
found = False
|
||||||
|
|
||||||
network.setShuffle(True)
|
for i in range(0, 36):
|
||||||
network.next()
|
if checkPhone():
|
||||||
|
found = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if found:
|
||||||
|
network.play(os.environ['SPOTALARMURI'], network.getDeviceID(os.environ['SPOTALARMDEVICENAME']))
|
||||||
|
|
||||||
|
network.setShuffle(True)
|
||||||
|
network.next()
|
||||||
|
Loading…
Reference in New Issue
Block a user