Skip to content

Commit

Permalink
1.09-x - fix error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
brettonw committed Sep 13, 2022
1 parent f4e5b5d commit 0773a1c
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions custom_components/apex/apex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 0773a1c

Please sign in to comment.