Unsure what function I'm missing

Hi Everybody, I’m not seeing an answer for my seemingly easy problem in any previous posts so ill go ahead and ask…

I’m looking to turn on pumps when my water float sensor is reading the bool state 0, and turn off the pumps when water float sensor is reading bool state 1.

Seemingly a really easy problem but I cannot find a Function that allows for this. Feeling like the answer is right in front of me, but I’m too close to see it. I would really appreciate help.

If you simply turn on flow when a float measurement is low, in order to accurately determine precisely when the float measures high (and synchronize that with the period of the function checking that measurement), will require having both the float input and function set at very low periods, something that is wasteful of storage (for measuring the float sensor this often is unnecessary) and resources (for running the function this often is unnecessary).

A better approach would be to progressively add water in specific amounts/durations, with a wait period in between to allow new float sensor measurements to be acquired. An input that measures the float sensor every 60 seconds and a function that runs every 130 seconds to check the value, and if low, instructs an output (water valve) to turn on for 60 seconds.

1 Like

Thanks for the response, that sounds like a better solution for sure. Is there currently a supported function where an inputs value is checked, and an output triggers on/off accordingly?

  1. Create a Conditional Controller Function, set Period of 130 seconds and save.
  2. Add a Measurement (Single, Last) Condition, select the float input, save.
  3. Add an Output (On/Off/Duration), select the output for the valve, set State to ON, and set duration to an appropriate duration (~less than half of the Function Period), save.
  4. Delete all the example code, put the following code in the Run Python Code box, replacing the condition ID and action ID with the ones specified in your Function, then save:
measurement = self.condition("asdf1234")
self.logger.info(f"Measurement value is {measurement}")

if measurement is not None:
    if measurement == 0:
  1. Activate the Function. If there’s a measurement within the set Max Age of the Condition and it’s equal to 0, it will execute the action.

Note: Period for the Input should be roughly the same amount of time you set the output to run for. The initial example of Function Period 130 seconds, Input Period 60 seconds, and Output duration 60 seconds is a good ratio, so scale up or down all values proportionally, if needed. If you have too long Input Period, you need to increase the Max Age of the Function Condition, otherwise it will not be able to acquire a measurement if the Max Age is less than the Input period.

1 Like

Thanks Kyle, I’ve been wanting a reason to dive into the conditional controllers, looks like this should be a good introduction for me.

I also was able to rig up what I was wanting with a Bang-Bang Hysteric Function. Pump is on until the set point of 0 bool is achieved.

Thanks Again!

1 Like