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:
parent
74de10e74c
commit
85e8ed9832
|
@ -72,7 +72,13 @@ class TempmonClient(Daemon):
|
||||||
|
|
||||||
# main loop: take readings, pause, repeat
|
# main loop: take readings, pause, repeat
|
||||||
while True:
|
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()
|
session = Session()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -99,16 +105,24 @@ class TempmonClient(Daemon):
|
||||||
finally:
|
finally:
|
||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
time.sleep(self.delay)
|
|
||||||
|
|
||||||
def take_reading(self, session, probe):
|
def take_reading(self, session, probe):
|
||||||
"""
|
"""
|
||||||
Take a single reading and add to Rattail database.
|
Take a single reading and add to Rattail database.
|
||||||
"""
|
"""
|
||||||
reading = tempmon.Reading()
|
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.client = probe.client
|
||||||
reading.probe = probe
|
reading.probe = probe
|
||||||
reading.degrees_f = self.read_temp(probe)
|
|
||||||
reading.taken = datetime.datetime.utcnow()
|
reading.taken = datetime.datetime.utcnow()
|
||||||
session.add(reading)
|
session.add(reading)
|
||||||
return reading
|
return reading
|
||||||
|
@ -126,7 +140,9 @@ class TempmonClient(Daemon):
|
||||||
equals_pos = lines[1].find('t=')
|
equals_pos = lines[1].find('t=')
|
||||||
if equals_pos != -1:
|
if equals_pos != -1:
|
||||||
temp_string = lines[1][equals_pos+2:]
|
temp_string = lines[1][equals_pos+2:]
|
||||||
|
# temperature data comes in as celsius
|
||||||
temp_c = float(temp_string) / 1000.0
|
temp_c = float(temp_string) / 1000.0
|
||||||
|
# convert celsius to fahrenheit
|
||||||
temp_f = temp_c * 9.0 / 5.0 + 32.0
|
temp_f = temp_c * 9.0 / 5.0 + 32.0
|
||||||
return round(temp_f,4)
|
return round(temp_f,4)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue