Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 33 additions & 27 deletions examples/luftdaten.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,33 +118,39 @@ def send_to_luftdaten(values, id):
pm_values_json = [{"value_type": key, "value": val} for key, val in pm_values.items()]
temp_values_json = [{"value_type": key, "value": val} for key, val in temp_values.items()]

resp_1 = requests.post(
"https://api.luftdaten.info/v1/push-sensor-data/",
json={
"software_version": "enviro-plus 0.0.1",
"sensordatavalues": pm_values_json
},
headers={
"X-PIN": "1",
"X-Sensor": id,
"Content-Type": "application/json",
"cache-control": "no-cache"
}
)

resp_2 = requests.post(
"https://api.luftdaten.info/v1/push-sensor-data/",
json={
"software_version": "enviro-plus 0.0.1",
"sensordatavalues": temp_values_json
},
headers={
"X-PIN": "11",
"X-Sensor": id,
"Content-Type": "application/json",
"cache-control": "no-cache"
}
)
try:
resp_1 = requests.post(
"https://api.luftdaten.info/v1/push-sensor-data/",
json={
"software_version": "enviro-plus 0.0.1",
"sensordatavalues": pm_values_json
},
headers={
"X-PIN": "1",
"X-Sensor": id,
"Content-Type": "application/json",
"cache-control": "no-cache"
}
)
except:
pass

try:
resp_2 = requests.post(
"https://api.luftdaten.info/v1/push-sensor-data/",
json={
"software_version": "enviro-plus 0.0.1",
"sensordatavalues": temp_values_json
},
headers={
"X-PIN": "11",
"X-Sensor": id,
"Content-Type": "application/json",
"cache-control": "no-cache"
}
)
except:
pass

if resp_1.ok and resp_2.ok:
return True
Expand Down