Hello all,
I’m trying to use an ESP-32 to remotely control my pool pump via a series of relays. I’ve managed to use ESPHome to upload yaml files into the ESP32 so that i can view 4 switches in my home assistant GUI. Now i want to create schedules to control the pump throughout the day but want to off load that work to the ESP32 rather than use HA.
I can muddle my way through VB and C (Arduino IDE) but i just can’t figure out how to do this in YAML.
I would like to set relays in a certain on/off position and then based on a time passed or clock to change the relay positions to their next position sequence.
Can someone point me in the right direction?
I’m looking to cycle through my pump timers via relay inputs based on time of day. Also being able to activate a certain relay sequence as needed via HA automation. (turn on water jets then kick pump to full power and vice versa)
This part sounds like a script that is activated by a user defined service on the esp unit that can be called from home assistant. See Native API Component — ESPHome . But it can be implemented in many ways depending on what you find most useful for your use case.
@ashscott That is great. Go figure the add-on has great documentation. Here i just went straight to the web to learn yaml.
@MatthewFlamm I’m thinking just an automation in HA for the deckjets relay and calling a script for the high flow sequence on the pump. thanks for the idea!
I suggest you put your automations on the device if possible and leave HA automations to situations where you need the state of multiple devices. What happens if your HA instance is down because of an upgrade snafu?
I took your advice and created a switch in HA to turn on deck jets that opens an automated valve (via relay) and changes the pump speed. then does the opposite when turned off. Just need to figure out how to stop the system from running on_time triggers when deck jet switch is on and also when turned off how to return the pump to the correct timer cycle… I’ll think on that a bit.
Do all your automations using scripts. There is a condition to check if a script is already running and you can handle all the possibilities that way. For example, it script is running, turn off script, turn off all relays, execute new script. This way there are go clashes between automations.
Scripts are very useful but are buried in the documentation. See here.
You are already using scripts I see sorry. Just use the is_running condition to make sure only one script is running at a time if needed.
im not familiar with using the time from HA to set time automations. Will this fail to work when the connection happens to drop momentarily at the wrong time on your device? My esp devices do drop out of connection briefly several times a day. If you can get the timer on the esp device itself, it would be preferred, but again, I don’t have any direct experience there.
Hi All,
I managed to figure out a method to have the deck jets on and turn the pump up to full power then on switch.off the cycle resumes at the correct time spot. I’ve used variables to get the timer_# being used then when exiting the deck_jet mode it should fire the proper sequence. See code below. I’m having issues with getting the variable to work on exiting the deck_jet. Any thoughts on what i’m doing wrong?
Note: I did not worry about stopping a script as they are run fairly instantaneous. they execute then the ESP keeps looping until the next trigger occurs.
- platform: gpio
name: "Deck Jets"
pin: GPIO13
inverted: yes
id: deck_jets
on_turn_on:
- switch.turn_on: deck_jets
- delay: 10s
- script.execute: timer_1 #turn on relay sequence with high flow rate for pump
on_turn_off:
- switch.turn_off: deck_jets
- delay: 10s
- script.execute: id(cycle_on) # This is the problematic line. resume schedule in the correct pump rate based on variable being written at each sequence change
time:
- platform: homeassistant
id: homeassistant_time #rPoint to HA to provide a time update to ESP32
on_time:
- seconds: 0
minutes: 0
hours: 3
then: #turn pump off
- if:
condition:
switch.is_off: deck_jets
then:
- globals.set:
id: cycle_on
value: 'pump_off'
- script.execute: pump_off
else:
- globals.set:
id: cycle_on
value: 'pump_off'
- seconds: 0
minutes: 0
hours: 7
then: #turn on timer 4
- if:
condition:
switch.is_off: deck_jets
then:
- globals.set:
id: cycle_on
value: 'timer_4'
- script.execute: timer_4
else:
- globals.set:
id: cycle_on
value: 'timer_4'