Solenoid valve doesn't work as it should

Hello, I have a little problem with my solenoid valve. Before connecting the solenoid valve to the relay, I checked that it works properly and it worked as it is supposed to work. After connecting it to the relay and ESP32, in Home Assistant it works in reverse i.e. when there is a signal “turn on the solenoid valve” the solenoid valve turns off and vice versa.
Code in ESP:

switch:
  - platform: gpio
    pin: 26
    id: relay
    restore_mode: ALWAYS_ON
    name: "Electrovalve"

I’m using ALWAYS_ON because when I’m starting the valve it turns off. My connections:

This should fix your issue (change to always_off to get the same results as before) :

In the future, post ESPHome questions in the ESPHome category: you’ll get better responses.

1 Like