Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. import requests
  4. import sys
  5.  
  6. host = '192.168.178.53'
  7. port = '80'
  8. username = 'nico'
  9. password = '2578'
  10. deviceid = 'mysensor'
  11.  
  12.  
  13.  
  14. def getDHT(deviceid):
  15. r = requests.get('http://%s:%s@%s:%s/api/devices/%s' % (username, password, host, port, deviceid))
  16. data = r.json()
  17. temp = str(data['device']['attributes'][0]['value']) + data['device']['attributes'][0]['unit']
  18. humi = str(data['device']['attributes'][1]['value']) + data['device']['attributes'][1]['unit']
  19. value = temp +' '+ humi
  20. return value
  21.  
  22. print getDHT(deviceid)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement