Hi everybody, I would need to create a device that can “activate” remotely and, once activated, turn on and then off (continuously) a pump every 10 minutes, until I “deactivate” it again remotely.
In this case I need it to operate a bilge pump that circulates the water in a tank with fish to keep them alive.
However, this tank will not always have fish in it and for this reason I need to activate and deactivate it remotely (fish in tank bilge on, fish not in tank bilge off).
Where the tank is, there is a wifi internet connection which I could access
I think it should be done with esphome’s time automation but I don’t know how I should do it.
Thanks for the help and ciao
Be a lot easier just to do it with a homeassistant automation.
You can use the gui to make an automation to:
turn on a switch, delay 10 minutes, turn off, delay 10 minutes , repeat a million times
then just add the automation as a switch in your gui.
Probably a way to do it directly on th ESPhome, which will be more stable incase WIFI goes out, but never done it. Look at this documentation: Automations and Templates — ESPHome
Looks like the “interval” component does exactly what you want.
@Pietrogramma by some small chance, last night in bed i was brushing up on my ESPHome automations and I think you need this
wait_until Action
This action allows your automations to wait until a condition evaluates to true. (So this is just a shorthand way of writing a while action with an empty then block.)
In a trigger:
on_…:
- logger.log: “Waiting for binary sensor”
- wait_until:
binary_sensor.is_on: some_binary_sensor - logger.log: “Binary sensor is ready”
If you want to use a timeout, the term “condition” is required:
In a trigger:
on_…:
- logger.log: “Waiting for binary sensor”
- wait_until:
condition:
binary_sensor.is_on: some_binary_sensor
timeout: 8s - logger.log: “Binary sensor might be ready”
the esphome page is here
Thanks Jaaem, I used the “interval” automations and all work fine, thanks again. Thanks also at Julian for the help.
Now there is another problem; in this moment the Automation work always, but I must active it when the fish are in the tank, how I can control the automation?
I need to recycle the water in a tank every 10 minutes, to keep the fish alive.
These fish are not always present in the tank and when the tank is empty, the pump must be turned off.
However, when fish are put in the tank, the pump should cycle on and off every 10 minutes.
Using the “interval” function of Esphome the pump is always on and off.
I would like to be able to start or stop the automation remotely and to start the cicle of turno On and turno Off of the pump only when I start the automation.
For now I have a wemos D1 mini pro programmed in esphome with an “interval” automatism that turns the pump on and off every 10 minutes.
When I power up the wemos, the automation starts immediately, Instead, I would like to give a remote command to the wemos, to which I tell it to start the automation or to stop the automation
@pietrogramma … well i control my home switches / buttons from my iPhone or sometimes voice control through Google Nest Hub. So same question, what do you want?
If the ESP node is close by then I would probably have a manual button in the ESP node case. I did that for a water pump; just set up a GPIO output component. Then your system is secure against loosing wifi; it is a stand alone system and you can run temperature sensors into it to give alerts or control other devices. I think this is an aquarium question
in my case the esp node is far from where I am.
The tank I’m talking about is located on my boat and is remotely controlled by me via a webcam, when there is fish the cam sends me SMS messages and, in this case, I should activate the on/off automation every 10 minutes.
The code I’m using for the wemos is as follows:
captive_portal:
switch:
- platform: gpio
pin: 5
name: "Vasca del vivo"
id: pesce
interval:
- interval: 1min
then:
- switch.toggle: pesce
@Pietrogramma interesting. So does the code work. Is there something more that you need to do? Do you want the cam to control the automation or are you happy pressing the button?
The code works perfectly but I need that the automation activate only when I need it. If you try to put the code in a wemos and power ON the wemos, the automation starts immediately and instead I would like the wemos on, but the automation starts only when I decide it.
I could do this by putting a wifi relay that turns on the wemos when I decide, but I would like to avoid putting too many devices (wemos relay, pump relay, wemos etc.).
For this reason I was asking if there is a command that activates and deactivates the automations of ESP (in this case “interval”)
@Pietrogramma thank you for explaining. I think you just need to put interval automaton after this. The switch will show up in HA and you can then just turn it on and off. Good luck
I Hi Julian, I have read the page that you kindly indicated to me but I have not found anything that allows me to activate or deactivate the automations. As I wrote above, my need is to always keep the wemos on and to activate the automation only when I need it. By inserting the automation after the switch command, every 10 minutes the switch turns on and then turns off by itself. I thought the automation would only activate if I turned on the switch, but instead it always activates and changes the state of the switch from on to off every 10 minutes. I think the only way to do what I’m looking for is to use a wifi relay that turns the wemos on and off.
Thanks for your help
Pietrogramma
I wanted something similar to you for my mozzie zappers connected to a sonoff s26 smart switch. The smart switch is always connected with power. I then made an input boolean switch that is located on my HA dashboard. I have 4 seperate rooms with mozzie zappers - this 4 separate input booleans.
When i have guets staying in certain rooms I just activate the boolean. This trigger is then used by the sonoffs26 to activate the run program which turns the zappers on at sunset and off at sunrise.
You already have your time code - you just need to trigger this with a boolean switch which you toggle when required.
Pat
Hi Patraff, I’m newbie of the Esphome world; For the automation I used this code:
captive_portal:
switch:
- platform: gpio
pin: 5
name: "Vasca del vivo"
id: pesce
interval:
- interval: 10min
then:
- switch.toggle: pesce
Can you complete for me the code, with the boolean switch? If it’s complicated, can you indicate me a tutorial to make boolean switch?
Thanks and ciao
Pietro
I too am no programmer. I ask lots of questions in these forums and people are kind enough to point me in the right direction. With a bit of reading I manage to clunk my way through.
I built my automation for the mozzie zappers using the automation GUI - with a little look at the yaml code after advice. Here is my automation. You need to build the input boolean first. Pretty simple in the GUI.
description: ""
trigger:
- platform: sun
event: sunrise
offset: 0
- platform: sun
event: sunset
offset: 0
condition:
- condition: state
entity_id: input_boolean.elke_s_room_mozzies
state: "on"
action:
- if:
- condition: template
value_template: "{{ trigger.event == \"sunrise\" }}"
then:
- service: switch.turn_off
data: {}
target:
device_id: 4f7f95e830171160e8023de4414a22ea
else:
- service: switch.turn_on
data: {}
target:
device_id: 4f7f95e830171160e8023de4414a22ea
mode: single
Obviously this only has one turn on and off in the daily cycle. As to your requirements for every 15 minutes I can’t provide too much help.
Pat
Thanks very much Pat…I will study and I hope that I will create the right project.
Thanks at all and goodnight