Skip to content

Commit 51ea01f

Browse files
authored
Added Timestamp to output
1 parent 6d24a1d commit 51ea01f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

devices.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/usr/bin/env python
2-
import urllib2, subprocess, requests
2+
import urllib2, subprocess, requests, time
3+
timestamp = time.strftime("Time: %H:%M, Date: %Y%m%d, ")
4+
print timestamp
35
for device in requests.get('http://localhost/api/devices').json():
46
if device['offUrl'].find('heyu') != -1:
57
url = "http://localhost/api/c/lights/%s/bridgeupdatestate" % device['id']
6-
heyu = device['offUrl'].replace("foff", "dimlevel").replace("off","dimlevel")
7-
if heyu.find('dimlevel') != -1:
8-
proc = subprocess.Popen([heyu], stdout=subprocess.PIPE, shell=True)
8+
chtxt = device['offUrl'].replace("foff", "dimlevel").replace("off","dimlevel")
9+
if chtxt.find('dimlevel') != -1:
10+
proc = subprocess.Popen([chtxt], stdout=subprocess.PIPE, shell=True)
911
(dimlevel, err) = proc.communicate()
1012
dimlevel = int(dimlevel)
1113
if dimlevel > 0:

0 commit comments

Comments
 (0)