Hi all,
I have a smart switch (with power metering) that turns on the irrigation pump on my balcony.
I set-up a nice scheduler on ha to water my plants regularly, but as of now I have no way of knowing if the tank is empty with the risk of not only having my plants dry, but also damaging the pump (it is not supposed to run dry). To prevent this risk, I normally check the power consumption of the pump to understand whether the tank is full or empty (if the tank is empty, the pump consumes way less, obviously, as it does less work).
I would like to have a “fake” sensor tell me if the power consumption of the pump was above or below a certain threshold (20 watts) the last time it ran. I was thinking to do this by setting-up an automation that would activate when the pump is running (first condition) and would set the state of a boolean sensor to “empty” in case the power consumption is below the threshold (second condition).
Can someone advise me on how to move from concept to code, please?
Thank you!
so it’s not a constant? where do you get it from?
anyway, one option is to use template binary sensor.
I’m not sure if it is a constant, but it changes state every time the pump is running (i.e., every time the dedicated switch is turned on). Then it retains that value until the net time the pump is turned on.
Well, I’m afraid I don’t know how to help you if you don’t know the conditions…
I’m sorry, I’m not sure what you mean by constant in this case
Create an input boolean and use your power sensor when pump running > (say) 2 seconds to turn it on if it goes below 20W
The pump switch off should also have this boolean as a trigger (when - > on) and the pump on automation have the boolean being off as a condition to start
It worked! It was an extremely simple solution, thank you very much
You are most welcome.
Please post your code so that the next person searching this topic has a running start to solve their problem.
Happy automating
Absolutely! I am planning to make a post with my whole configuration of the irrigation automations and scheduling, but in the meantime here it is.
First of all I created an input_boolean that tells if the water tank is full (on) or not (off)
input_boolean:
irrigation_tank_full:
When I fill the tank, I turn on that switch manually.
Then I added tmultiple automations:
the first one sets the input_boolean to “off” if the power consumption of the pump (when it is running) is <30w (I measured this empirically as a good threshold):
atuomation:
- alias: Irrigation tank empty
description: ''
trigger:
- above: '1'
below: '30'
entity_id: sensor.balcony_irrigation_consumption
platform: numeric_state
condition: []
action:
- entity_id: input_boolean.irrigation_tank_full
service: input_boolean.turn_off
The second automation turns of the irrigation in case the tank runs out of water while running:
automation:
- alias: Turn off irrigation on empty tank
description: ''
trigger:
- entity_id: input_boolean.irrigation_tank_full
from: 'on'
platform: state
to: 'off'
condition: []
action:
- entity_id: switch.balcony_irrigation
service: switch.turn_off
The third automation is to make sure the pump can run if I manually turn it on, but I forgot to change the input_boolean of the full tank to “on” (i.e., I filled the tank manually but then I forgot to change the state of the tank to full by manually change the input_boolean). The automation changes the state of the input_boolean to “on” if the pump is running and the consumption is >30W:
automation:
- alias: Irrigation tank full
description: ''
trigger:
- above: '30'
entity_id: sensor.balcony_irrigation_consumption
platform: numeric_state
condition:
- condition: state
entity_id: input_boolean.irrigation_tank_full
state: 'off'
action:
- entity_id: input_boolean.irrigation_tank_full
service: input_boolean.turn_on
The last automation turns off the pump if the tank is emptied while the pump is running:
automation:
- alias: Turn off irrigation on empty tank
description: ''
trigger:
- entity_id: input_boolean.irrigation_tank_full
from: 'on'
platform: state
to: 'off'
condition: []
action:
- entity_id: switch.balcony_irrigation
service: switch.turn_off
On top of all of that I have a weekly timer that runs only if the input_boolean is on that is, if the tank is full.
The next step will be to implement a notification when the tank is empty, but for now I’m not able to do that so I’ll have to study the documentation frst. I’ll update this post!