Hi guys,
I hope you guys are well
Apologies for the long post
I was hoping that someone a lot smarter than me can assist with my next upcoming project. Essentially, when we have planned power outages here in South Africa, we need to manually turn 2 valves to go from our tank water to municipal supply and then when the planned power outage ends, we need to manually turn these same 2 valves to go back to the tank water supply. This is a pain when you’re in the shower and the water disappears and you then need to run outside to close/open these valves:
I’ve ordered 2 of the following solenoid valves (1 to replace each of the valves above):
DF Robot DN20 Solenoid Valve - these each come with a 5V relay.
They can either be wired in to be “always open” or “always closed” as per the diagram below. When power is lost, they remain in their current state but I’m planning on putting this whole project on our battery inverter so this is not a prob.
Other components I’ll be using is an ESP32-S Nodemcu-32 V1.3 which has a 5V pin which I’m planning to use to power the 2 x relays below.
Regarding HA - I’ve somehow managed to create a working sensor called: power_state. This uses the pool pump timer which is not on the battery inverter to determine if we’re having a power outage or not and hopefully this will help with an automation. I’ve used the following code for this:
YAML:
If pool voltage is 0 then there is no power at home
else power is normal
{% if states("sensor.pool_pump_voltage") == 0 %}
No power
{% else %}
Power normal
{% endif %}
I’ve attempted to create code to operate the 2 solenoid valves but I’ve never put more than 1 sensor on an ESP32:
YAML:
esphome:
name: Jojo-Tank-Control
esp32:
board: nodemcu-32s
framework:
type: arduino
switch:
- platform: gpio
name: "Normally Closed Solenoid Controller"
pin: GPIO22
switch:
- platform: gpio
name: "Normally Open Solenoid Controller"
pin: GPIO23
I would really appreciate it if you guys could guide me on the above config/codes and if possible, assist with an automation to make this all happen in the background plus have an override setting, just in case.
Thanks in advance!