Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import requests
- import sys
- host = '192.168.178.53'
- port = '80'
- username = 'nico'
- password = '2578'
- deviceid = 'mysensor'
- def getDHT(deviceid):
- r = requests.get('http://%s:%s@%s:%s/api/devices/%s' % (username, password, host, port, deviceid))
- data = r.json()
- temp = str(data['device']['attributes'][0]['value']) + data['device']['attributes'][0]['unit']
- humi = str(data['device']['attributes'][1]['value']) + data['device']['attributes'][1]['unit']
- value = temp +' '+ humi
- return value
- print getDHT(deviceid)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement