Skip to content

Commit

Permalink
Fix pH Input error when calibration temperature is None
Browse files Browse the repository at this point in the history
  • Loading branch information
kizniche committed Oct 10, 2024
1 parent ffb9448 commit 49c4961
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
17 changes: 7 additions & 10 deletions mycodo/inputs/atlas_ec.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# coding=utf-8
import copy
import logging
import time

from flask_babel import lazy_gettext
Expand Down Expand Up @@ -271,20 +272,16 @@ def get_measurement(self):
else:
out_value = last_measurement[1]

self.logger.debug(
"Latest temperature used to calibrate: {temp}".format(
temp=out_value))
self.logger.debug(f"Latest temperature used to calibrate: {out_value}")

ret_value, ret_msg = self.atlas_command.calibrate(
'temperature', set_amount=out_value)
ret_value, ret_msg = self.atlas_command.calibrate('temperature', set_amount=out_value)
time.sleep(0.5)

self.logger.debug("Calibration returned: {val}, {msg}".format(
val=ret_value, msg=ret_msg))
self.logger.debug(f"Calibration returned: '{ret_value}', '{ret_msg}'")
if logging.getLevelName(self.logger.level) == "DEBUG":
self.logger.debug(f"Stored temperature value: {self.atlas_device.query('T,?')}")
else:
self.logger.error(
"Calibration measurement not found within the past "
"{} seconds".format(self.max_age))
self.logger.error(f"Calibration measurement not found within the past {self.max_age} seconds")

# Read device
atlas_status, atlas_return = self.atlas_device.query('R')
Expand Down
31 changes: 15 additions & 16 deletions mycodo/inputs/atlas_ph.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,27 +264,26 @@ def get_measurement(self):
_, unit, _ = return_measurement_info(
device_measurement, conversion)

if unit != "C":
out_value = convert_from_x_to_y_unit(
unit, "C", last_measurement[1])
if last_measurement[1] is None:
self.logger.error("Cannot use calibration temperature because it returned None. "
"Fix your temperature measurement and try again.")
else:
out_value = last_measurement[1]
if unit != "C":
out_value = convert_from_x_to_y_unit(
unit, "C", last_measurement[1])
else:
out_value = last_measurement[1]

self.logger.debug(
f"Latest temperature used to calibrate: {out_value}")
self.logger.debug(f"Latest temperature used to calibrate: {out_value}")

ret_value, ret_msg = self.atlas_command.calibrate(
'temperature', set_amount=out_value)
time.sleep(0.5)
ret_value, ret_msg = self.atlas_command.calibrate('temperature', set_amount=out_value)
time.sleep(0.5)

self.logger.debug(
f"Calibration returned: '{ret_value}', '{ret_msg}'")
if logging.getLevelName(self.logger.level) == "DEBUG":
self.logger.debug(
f"Stored temperature value: {self.atlas_device.query('T,?')}")
self.logger.debug(f"Calibration returned: '{ret_value}', '{ret_msg}'")
if logging.getLevelName(self.logger.level) == "DEBUG":
self.logger.debug(f"Stored temperature value: {self.atlas_device.query('T,?')}")
else:
self.logger.error(
f"Calibration measurement not found within the past {self.max_age} seconds")
self.logger.error(f"Calibration measurement not found within the past {self.max_age} seconds")

# Read device
atlas_status, atlas_return = self.atlas_device.query('R')
Expand Down

1 comment on commit 49c4961

@kizniche
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Radical DIY Forum. There might be relevant details there:

https://forum.radicaldiy.com/t/atlas-ec-disappears-after-8-16-0-upgrade/1976/23

Please sign in to comment.