# Sonoff SV Gate controller with remote wifi button

**URL:** https://discourse.nodered.org/t/sonoff-sv-gate-controller-with-remote-wifi-button/28814
**Category:** General
**Created:** [23 June 2020 13:49 UTC](https://discourse.nodered.org/t/sonoff-sv-gate-controller-with-remote-wifi-button/28814 "2020-06-23T13:49:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![anuccite](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@anuccite](https://discourse.nodered.org/u/anuccite)
#### Post date: [23 June 2020 13:49 UTC](https://discourse.nodered.org/t/sonoff-sv-gate-controller-with-remote-wifi-button/28814/1 "2020-06-23T13:49:01Z")

</div>

I have a Sliding Gate to my Rear Garage. I used the ALEKO AC1400NOR Chain Driven Sliding Gate Opener

I have sucessfully gotten it working using digiblurDIY Guide to "Smart Garage Door Solutions", I just need to work out my open / close reed setup.

The 2nd part of this is where i'm having issues, I would like to be able to place a simple doorbell button(or 2), to be able to control the gate.  
This way I could either Use the HA App on the phone, or simply push the button in the garage (or the house) and have it trigger my already working HA setup to open and or close the gate. I was hoping that i could use gpio14 on a secondary sonoff sv to register the push button, and pass that to the HA switch that controls the gate.

I entered the following Rule  
Rule1 on switch2#state=0 do publish2 stat/%topic%/status ON endon on switch2#state=1 do publish2 stat/%topic%/status OFF endon

06:46:30 MQT: stat/Opener/status = ON (retained) _ **When I push the button** _  
06:46:34 RUL: SWITCH2#STATE=1 performs "publish2 stat/Opener/status OFF"  
06:46:34 MQT: stat/Opener/status = OFF (retained) _ **When I release the button** _

My idea for the sequence would be as follows

Button pushed reads stat/Opener/status = ON(or OFF) (I see that happen real time in Node-Red)  
Which should send "ON" to cmnd/Gate/STATE

I assume I need some If / then Statement, But that's where I get lost...

Can anyone help me complete this flow?

My very simple code for that is below

```auto
[{"id":"29ead169.7df9be","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"c3ddd7b4.c344c","type":"debug","z":"29ead169.7df9be","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":550,"y":80,"wires":[]},{"id":"3f8a9b66.124bcc","type":"mqtt in","z":"29ead169.7df9be","name":"Garage Button","topic":"stat/Opener/status","qos":"0","datatype":"auto","broker":"3deb09ba.4feca6","x":100,"y":100,"wires":[["c3ddd7b4.c344c"]]},{"id":"55ccb95e.ffc8a","type":"mqtt out","z":"29ead169.7df9be","name":"Gate Control","topic":"cmnd/Gate/STATE","qos":"0","retain":"false","broker":"3deb09ba.4feca6","x":550,"y":200,"wires":[]},{"id":"3deb09ba.4feca6","type":"mqtt-broker","z":"","name":"Mosquitto","broker":"192.168.33.61","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

```

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [25 June 2020 04:57 UTC](https://discourse.nodered.org/t/sonoff-sv-gate-controller-with-remote-wifi-button/28814/2 "2020-06-25T04:57:13Z")

</div>

What you posted isn't really telling anyone anything.

How about you post the node/s with those rules you mentioned?

> [@anuccite](#):
>
> I entered the following Rule  
> Rule1 on switch2#state=0 do publish2 stat/%topic%/status ON endon on switch2#state=1 do publish2 stat/%topic%/status OFF endon
> 
> 06:46:30 MQT: stat/Opener/status = ON (retained) _ **When I push the button** _  
> 06:46:34 RUL: SWITCH2#STATE=1 performs "publish2 stat/Opener/status OFF"  
> 06:46:34 MQT: stat/Opener/status = OFF (retained) _ **When I release the button** _

You don't need to include the `MQTT`nodes. But rather a `debug` node should suffice.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [24 August 2020 04:57 UTC](https://discourse.nodered.org/t/sonoff-sv-gate-controller-with-remote-wifi-button/28814/3 "2020-08-24T04:57:17Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
