I was using a Sonoff 4 Channel Pro relay in my “Smart Garage Door” project however it was big time overkill. I only need one relay to pull this off. In addition to this I was using a NodeMCU ESP8266 to act separately as the garage door sensor. So in essence I had:
- Spare Remote Control (for Security 2.0 garage door opener)
- Sonoff 4 Channel Pro Relay
- NodeMCU ESP8266 Chip for Door sensor
Now I have
- Spare Remote Control
- Sonoff SV
Much, much more compact. In addition to using the Sonoff SV to open and close the door I used the GPIO 14 pin on the board to add the door sensor to the Sonoff SV.
First and foremost I have flashed the Sonoff SV with Tasmota and configured it as follows:
- Set Module Type to Sonoff SV (03)
- Set GPIO 14 to Switch2 (10)
Now after the SV reboots go to the Console and type the following 5 commands
SwitchTopic 1 SwitchMode1 0 SwitchMode2 2 PulseTime1 10 PowerRetain 1
Now set it aside and unplug the board and lets get the hardware ready.
- Remove the two resistors to the right of the INPUT. There is one on each side of the 2 pin connector. Just take a small screwdriver and pry on them. They’ll pop off pretty easily. What this does is it isolates the relay from the wifi.
- Now solder a jumper across the input + and –
- Take a USB connector and leave the A side on and connect it to the + and – terminals labelled in the picture below. I spliced female breadboard wires onto them.
- Hook reed switch to GPIO and a Ground Terminal
- Solder the wires that go to the spare remote button to the output end.
Here is a depiction of all your relevant hook ups:
That’s it. Now lets configure HomeAssistant. This is the switch for the door.
NOTE: I renamed my sonoff MQTT name to “sonoffgarage”. If you don’t change this yours will just be “sonoff” in the MQTT commands below.
switch 15: - platform: mqtt name: "Garage Door" state_topic: "stat/sonoffgarage/POWER" command_topic: "cmnd/sonoffgarage/POWER" payload_on: "ON" payload_off: "OFF" optimistic: false qos: 0 retain: false
Now here is the garage door binary sensor for the reed switch.
NOTE: The door sensor (reed switch) is now “POWER2”. Also note that again yours could be named “sonoff” and mine is named “sonoffgarage”. If you have Eagle Eyes you might note that my payload_on is off. The door would show open when it was closed, and vice versa. You can issue a command in the Sonoff SV Console to change this however this was just the simplest way as far as I was concerned. No right or wrong way IF IT WORKS.
- platform: mqtt name: Garage Door state_topic: cmnd/sonoffgarage/POWER2 payload_on: 'OFF' payload_off: 'ON' sensor_class: 'opening' optimistic: false qos: 0 retain: true
I made an automation to send me a notification to my phone when the door is opened.
automation 24: alias: Notify when garage door opens trigger: - platform: state entity_id: binary_sensor.garage_door to: 'on' action: - service: notify.mypushbullet data_template: title: "Garage Door Open" message: >- Doors Open Dude
Now for safety’s sake I set an automation to automatically close the door if it is open for 20 minutes. At least if it accidentally goes up, it will come back down.
automation 25: alias: Close Garage After 20 Minutes trigger: - platform: state entity_id: binary_sensor.garage_door to: 'on' for: minutes: 20 action: - service: switch.turn_on entity_id: switch.garage_door
Lastly I set a customization for the garage door. This makes it change color and stuff.
binary_sensor.garage_door: friendly_name: Garage Door device_class: garage_door switch.garage_door: friendly_name: Garage Door icon: mdi:garage
Bad Assed. The only way to describe it. I printed a 3D case for the SV from here. Here’s what it looks like installed.
Hello, why use an extra binary sensor for the reed switch.
https://www.youtube.com/watch?v=QMepwpyjMCY
cover:
– platform: mqtt
name: “Garasje”
state_topic: “stat/garasjeport/POWER2”
command_topic: “cmnd/garasjeport/power”
payload_open: “ON”
payload_close: “ON”
payload_stop: “ON”
state_open: “ON”
state_closed: “OFF”
optimistic: false
On Firmware 6.5.0 I had to set GPIO4 to Relay2 in order for the magswitch on GPIO 14 to control the 2nd POWER value (POWER2) and not the only POWER value POWER. After setting GPIO4 to Relay2, there are 2 POWER values (POWER1 and POWER2.
Also, the main interface now contains two Toggle buttons, Toggle 1 and Toggle 2, more in line with the expectation.
I have a question: I followed all instructions but my sonoff sv only turns on when i press the toggle once then turns off when i press it again. Isn’t it supposed to be ‘inching’, like turning itself off after .5 seconds? I have to press twice, otherwise it remains on. What am I missing?
Chris
Have a look at the PulseTime command. Enter PulseTime 10 in the console and the relay stays on for 1 second only.
I have a different issue. The Sensor which is supposed to tell us if the door is open or closed:
sendor:
– platform: mqtt
name: Garage Door
state_topic: cmnd/sonoffgarage/POWER2
payload_on: ‘OFF’
payload_off: ‘ON’
sensor_class: ‘opening’
optimistic: false
qos: 0
retain: true
seems to cause errors and has to be modified thus:
– platform: mqtt
name: Front Gate
state_topic: cmnd/sonoffsv1/POWER2
# payload_on: ‘OFF’
# payload_off: ‘ON’
# sensor_class: ‘opening’
# optimistic: false
qos: 0
# retain: true
Hello John,
I’m glad I found your post because I was struggling with DrZzs’ YouTube video (https://youtu.be/AU1KD_aJSMY) until I discovered my Craftsman garage door opener has security 2.0.
I was hoping you could help me because I’m stuck at wiring the SV to the remote control. The remote control button I’m using can be triggered by shorting the top 2 or bottom 2 pads (guess it depends on how you view the remote, but I think you get the idea that there are two points to trigger the button). I soldered two 28 awg wires to the bottom pads on the underside of the remote control. One of these wires is connected to Out+ and the other wire to Out- on the SV. I also soldered a single 28 awg wire between In+ and In- on the SV. I reassemble my remote and physically pressing the button still opens/closes the garage. But pressing the button in HA does not work. When I press the HA button, the SV red LED lights up and I hear a click for the initial press and then a second click when the HA button turns off automatically.
This is my first time soldering so it’s possible I did not make a strong connection so I’ve re-soldered twice and still cannot get the HA side to work. I would appreciate any help you could offer.
Hardware:
Sonoff SV with ESPHome (using YAML file from DrZzs: https://gist.github.com/Snipercaine/f3908a051fd79e6d7d7b765152666c2a except I removed the ultrasonic sensor code)
Home Assistant (latest version)
Got any pictures? Email me if you want.
That would be great. I just emailed you.
Just wanted to come back and say thanks John. Your advice helped me get everything set up. Next step is making Tasker work with Home Assistant.
Thanks again.
Hi, just a question: why do you remove the two resistors?
I have used a sharp knife to remove the resistors on my boards
His question was “why” and not “how”…
Hi there,
Nice setup!
Any considerations if I do this using a 4 Channel Pro Sonoff controller?? I need to control three different doors, so it made sense.
I am not completely sure about the MQTT options I need to give the 4Ch on the console though. And I need to be 110% sure it won’t open any of the doors… of course…
Your help and input would be greatly appreciated!
Regards from Chile!
MO
Hello John just a newbie in all this thing called “Home Assistant ” . Just one question maybe stupid 😛 but I will ask . I use same board for my garage door with EspHome following DrZzzz video, and same like him I attached a proximity sensor to GpiO05 and 04 . My question is if there is other pins available for a second proximity sensor since I have 2 cars in garage. I tried something stupid and connected the 2nd sensor to same pins and obviously shows same info doesn’t matter if one parking place is empty, I guess is normal 🤦.
GPIO’s 4, 5 and 14 are exposed
My switch is doing the weirdest thing, driving me nuts! It’s sending the state, and the sending the inverted state immediately after. Any clues on how to stop this:
So
OFF
ON
OFF
then 7 seconds later
ON
OFF
ON
12:50:31.160 MQT: cmnd/tasmota_D86D23/POWER2 = OFF
12:50:31.164 MQT: stat/garage_door/SWITCH2 = {“STATE”:”OFF”}
12:50:32.663 MQT: cmnd/tasmota_D86D23/POWER2 = ON
12:50:32.667 MQT: stat/garage_door/SWITCH2 = {“STATE”:”ON”}
12:50:33.114 MQT: cmnd/tasmota_D86D23/POWER2 = OFF
12:50:33.118 MQT: stat/garage_door/SWITCH2 = {“STATE”:”OFF”}
12:50:39.518 MQT: cmnd/tasmota_D86D23/POWER2 = ON
12:50:39.524 MQT: stat/garage_door/SWITCH2 = {“STATE”:”ON”}
12:50:39.668 MQT: cmnd/tasmota_D86D23/POWER2 = OFF
12:50:39.672 MQT: stat/garage_door/SWITCH2 = {“STATE”:”OFF”}
12:50:40.118 MQT: cmnd/tasmota_D86D23/POWER2 = ON
12:50:40.122 MQT: stat/garage_door/SWITCH2 = {“STATE”:”ON”}
Hi
Would you still use the same pins out for the remote if you can wire it directly into the board of the garage motor? My Garage motor main board has pins that can be setup with a key switch so can tap into that?