try to survive downtimes of target

prod_changes
agp8x 2020-05-20 13:15:24 +02:00
parent ffc7ac2794
commit 0eb7a30e4a
1 changed files with 6 additions and 2 deletions

View File

@ -1,4 +1,4 @@
HOST = "192.168.2.110"
HOST = "192.168.2.160"
PORT = 4223
UID = "DYC"
URL = "http://192.168.2.30:8086/write?db=mydb"
@ -15,7 +15,11 @@ def asdf(type, identifier, **kwargs):
time_ns = time.time_ns()
for key in kwargs:
data = "{unit},type={type},identifier={id} value={value} {time_ns}".format(unit=key, type=type, id=identifier, value=kwargs[key], time_ns=time_ns)
r = requests.post(URL, data=data)
try:
r = requests.post(URL, data=data)
print(r, r.status_code)
except Exception as e:
print(e)
def cb_station(identifier, temperature, humidity, wind_speed, gust_speed, rain, wind_direction, battery_low):
asdf(type="station", identifier=identifier, temperature=temperature, humidity=humidity, wind_speed=wind_speed, gust_speed=gust_speed, rain=rain, wind_direction=wind_direction, battery_low=battery_low)