Add try/catch for client's "read temp" logic
this can isolate an error for a certain probe, so that other probes can go ahead and take their readings during each client run. that way only the bad one is marked as "error" status by the server
This commit is contained in:
parent
b644818eef
commit
8220082359
|
@ -137,22 +137,28 @@ class TempmonClient(Daemon):
|
|||
Take a single reading and add to Rattail database.
|
||||
"""
|
||||
reading = tempmon.Reading()
|
||||
reading.degrees_f = self.read_temp(probe)
|
||||
|
||||
# a reading of 185.0 °F indicates some sort of power issue. when this
|
||||
# happens we log an error (which sends basic email) but do not record
|
||||
# the temperature. that way the server doesn't see the 185.0 reading
|
||||
# and send out a "false alarm" about the temperature being too high.
|
||||
# https://www.controlbyweb.com/support/faq/temp-sensor-reading-error.html
|
||||
if reading.degrees_f == 185.0:
|
||||
log.error("got reading of 185.0 from probe: %s", probe.description)
|
||||
try:
|
||||
reading.degrees_f = self.read_temp(probe)
|
||||
|
||||
else: # we have a good reading
|
||||
reading.client = probe.client
|
||||
reading.probe = probe
|
||||
reading.taken = datetime.datetime.utcnow()
|
||||
session.add(reading)
|
||||
return reading
|
||||
except:
|
||||
log.exception("Failed to read temperature (but will keep trying) for probe: %s", probe)
|
||||
|
||||
else:
|
||||
# a reading of 185.0 °F indicates some sort of power issue. when this
|
||||
# happens we log an error (which sends basic email) but do not record
|
||||
# the temperature. that way the server doesn't see the 185.0 reading
|
||||
# and send out a "false alarm" about the temperature being too high.
|
||||
# https://www.controlbyweb.com/support/faq/temp-sensor-reading-error.html
|
||||
if reading.degrees_f == 185.0:
|
||||
log.error("got reading of 185.0 from probe: %s", probe.description)
|
||||
|
||||
else: # we have a good reading
|
||||
reading.client = probe.client
|
||||
reading.probe = probe
|
||||
reading.taken = datetime.datetime.utcnow()
|
||||
session.add(reading)
|
||||
return reading
|
||||
|
||||
def read_temp(self, probe):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue