From 0773a1c90d1df0b7e8bc2ff147ee085b9b90bd23 Mon Sep 17 00:00:00 2001 From: Bretton Wade Date: Tue, 13 Sep 2022 15:55:22 -0400 Subject: [PATCH] 1.09-x - fix error handling --- custom_components/apex/apex.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/custom_components/apex/apex.py b/custom_components/apex/apex.py index b01c2e1..7e1fe6e 100644 --- a/custom_components/apex/apex.py +++ b/custom_components/apex/apex.py @@ -210,13 +210,11 @@ def set_dos_rate(self, did, profile_id, rate): # _LOGGER.debug(r.text) # turn the pump on - self.set_variable(did, f"Set {profile['name']}") - - # return no error - return {"error": ""} - - # XXX TODO handle rates less than 0.1ml/min by dosing over multiple minutes? Is this necessary? - return {"error": f"Requested rate ({rate} mL / min) is out of the supported range [0.1 .. {int(pump_speeds[0] / 3)}]."} + return self.set_variable(did, f"Set {profile['name']}") + else: + return {"error": f"Requested rate ({rate} mL / min) exceeds the supported range (limit {int(pump_speeds[0] / safety_margin)} mL / min)."} else: + # XXX TODO handle 0 < rate < 0.1ml/min by dosing over multiple minutes? Is this necessary? + # turn the pump off - self.set_variable(did, f"Set OFF") + return self.set_variable(did, f"Set OFF")