Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- import os
- import glob
- import requests
- from w1thermsensor import W1ThermSensor
- for sensor in W1ThermSensor.get_available_sensors():
- print("Sensor %s has temperature %.2f" % (sensor.id, sensor.get_temperature()))
- temp_round = round(sensor.get_temperature(),1)
- if sensor.id == '00000938007e': #Hot
- url = 'http://192.168.1.43:8080/json.htm?type=command¶m=udevice&idx=10&nvalue=0&svalue=' + str(temp_round)
- if sensor.id == '041754509cff': #2
- url = 'http://192.168.1.43:8080/json.htm?type=command¶m=udevice&idx=165&nvalue=0&svalue=' + str(temp_round)
- if sensor.id == '00000a049960': #3
- url = 'http://192.168.1.43:8080/json.htm?type=command¶m=udevice&idx=166&nvalue=0&svalue=' + str(temp_round)
- if sensor.id == '00000a03a9e7': #4
- url = 'http://192.168.1.43:8080/json.htm?type=command¶m=udevice&idx=167&nvalue=0&svalue=' + str(temp_round)
- try:
- print (url)
- r = requests.get(url)
- page = r.content
- print (page)
- except requests.exceptions.HTTPError as errh:
- print ("Http Error:",errh)
- except requests.exceptions.ConnectionError as errc:
- print ("Error Connecting:",errc)
- except requests.exceptions.Timeout as errt:
- print ("Timeout Error:",errt)
- except requests.exceptions.RequestException as err:
- print ("OOps: Something Else",err)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement