Compare commits
3
Commits
d636bf3124
...
bff2b727cc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bff2b727cc | ||
|
|
086e632b75 | ||
|
|
3bc09edfe4 |
@@ -149,11 +149,16 @@ class Sensor():
|
|||||||
'fields': data,
|
'fields': data,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for attempt in range(3):
|
||||||
try:
|
try:
|
||||||
sensors_client.write_points([point])
|
sensors_client.write_points([point])
|
||||||
except requests.exceptions.ConnectionError:
|
break
|
||||||
logging.exception('Error connecting to InfluxDB!')
|
except Exception as e:
|
||||||
|
logging.exception('Error writing to InfluxDB (attempt %s/3): %s', attempt + 1, e)
|
||||||
|
if attempt == 2:
|
||||||
|
controller_message('Failed to write to InfluxDB after 3 attempts: ' + str(e))
|
||||||
return
|
return
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
logging.info('Wrote %s data to InfluxDB: %s', self, data)
|
logging.info('Wrote %s data to InfluxDB: %s', self, data)
|
||||||
|
|
||||||
@@ -525,10 +530,13 @@ async def history(request):
|
|||||||
q = 'select max("pm10") as max_p10, max("pm25") as max_p25, max("co2") as max_co2, max("voc_idx") as max_voc from air where "name" = \'{}\' and time >= {}s and time < {}s group by time({}) fill(linear)'.format(name, start, end, window)
|
q = 'select max("pm10") as max_p10, max("pm25") as max_p25, max("co2") as max_co2, max("voc_idx") as max_voc from air where "name" = \'{}\' and time >= {}s and time < {}s group by time({}) fill(linear)'.format(name, start, end, window)
|
||||||
elif measurement == 'soil':
|
elif measurement == 'soil':
|
||||||
client = sensors_client
|
client = sensors_client
|
||||||
q = 'select mean("soil") as soil from soil where "name" = \'{}\' and time >= {}s and time < {}s group by time({}) fill(linear)'.format(name, start, end, window)
|
q = 'select mean("soil") as soil, mean("moisture") as moisture from soil where "name" = \'{}\' and time >= {}s and time < {}s group by time({}) fill(linear)'.format(name, start, end, window)
|
||||||
elif measurement == 'lux':
|
elif measurement == 'lux':
|
||||||
client = sensors_client
|
client = sensors_client
|
||||||
q = 'select mean("lux") as lux from air where "name" = \'{}\' and time >= {}s and time < {}s group by time({}) fill(linear)'.format(name, start, end, window)
|
q = 'select mean("lux") as lux from air where "name" = \'{}\' and time >= {}s and time < {}s group by time({}) fill(linear)'.format(name, start, end, window)
|
||||||
|
elif measurement == 'hpa':
|
||||||
|
client = sensors_client
|
||||||
|
q = 'select mean("hpa") as hpa from air where "name" = \'{}\' and time >= {}s and time < {}s group by time({}) fill(linear)'.format(name, start, end, window)
|
||||||
elif measurement == 'sleep':
|
elif measurement == 'sleep':
|
||||||
client = sensors_client
|
client = sensors_client
|
||||||
q = 'select max("max_mag") as max_mag from sleep where "name" = \'{}\' and time >= {}s and time < {}s group by time({}) fill(linear)'.format(name, start, end, window)
|
q = 'select max("max_mag") as max_mag from sleep where "name" = \'{}\' and time >= {}s and time < {}s group by time({}) fill(linear)'.format(name, start, end, window)
|
||||||
|
|||||||
Reference in New Issue
Block a user