Log error when client probe takes a 185.0 reading

this indicates some power issue with the probe(s) and does not really mean
that's the temperature.  so we don't want the server to send out "high temp"
email etc. but rather just a technical error email

https://www.controlbyweb.com/support/faq/temp-sensor-reading-error.html
This commit is contained in:
Lance Edgar 2018-10-05 20:53:09 -05:00
parent 74de10e74c
commit 85e8ed9832

View file

@ -72,7 +72,13 @@ class TempmonClient(Daemon):
# main loop: take readings, pause, repeat
while True:
self.take_readings(client_uuid)
time.sleep(self.delay)
def take_readings(self, client_uuid):
"""
Take new readings for all enabled probes on this client.
"""
session = Session()
try:
@ -99,16 +105,24 @@ class TempmonClient(Daemon):
finally:
session.close()
time.sleep(self.delay)
def take_reading(self, session, probe):
"""
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)
else: # we have a good reading
reading.client = probe.client
reading.probe = probe
reading.degrees_f = self.read_temp(probe)
reading.taken = datetime.datetime.utcnow()
session.add(reading)
return reading
@ -126,7 +140,9 @@ class TempmonClient(Daemon):
equals_pos = lines[1].find('t=')
if equals_pos != -1:
temp_string = lines[1][equals_pos+2:]
# temperature data comes in as celsius
temp_c = float(temp_string) / 1000.0
# convert celsius to fahrenheit
temp_f = temp_c * 9.0 / 5.0 + 32.0
return round(temp_f,4)