hi guys im new in smart home i have a project and i hope you can help me
i have a 4 chanel rely i want control it with home assistance and toggle swich i program esp and know i can control rely with esp but i dont know how program esp to control rely with toggle swich
my plan is to connect toggle swich with a pin and when i change toggle swich pin change to low or high and bace on the rely pin change
i need help with
1-how connect toggle with esp pin i conect gnd pin to swich and then to d7 pin i dont know i to it right
2-with coding its do like that(when pin d7(is toggle swich pin)change from low to hight if pin D1(rely 1 pin) is high do nothing else change pin 1 to hight /when pin d7 change form hight to low if pin 1 is low do nothing else change pin 1 to low
and i want to its thing in esp not home assistance because if my server go offline i still can control my rely
sorry my English is not good
thank
Does it have to be a toggle switch?
A push button is more consistent intuitively, a switch can be perceived as on in a certain state.
If you want a toggle then you need to add automations to the GPIO pin like:
on_turn_on:
- switch.toggle: relay
on_turn_off:
- switch.toggle: relay
The above is perhaps not correct syntax, I just wrote it from what I remember.
Using a button you use on_press → switch.toggle.
No big deal whichever you use.
But you are correct in your thinking about having the switch on a separate pin, just remember to add pull-up or pull-down.
hi thanks
its must be toggle switch a dont want to change original wall toggle
i use pin d7 for toggle swich (connect gnd pin to toggle and to pin d7)
i define d7 as a swich but when i turn on toggle swich on pin d7 status dont change
What yaml do you have for d7 pin?
its like that
switch:
- platform: gpio
pin:
number: 13
name: “toggle 1”
it says 13 here…
Remember to paste code inside a code block (preformatted text </>
)or it’s much harder to find errors
pin D7 number is 13
Ok… got it.
try and make the pin pull-up:
GPIO Binary Sensor — ESPHome
This should make the pin on
until the switch grounds it.