It is read by the app from the device. Easy enough to test. Turn it on and off with the physical button on the device and note that the app sees the changes.
As far as I know there is no other input enabled on the basic. It might be possible to interface something external like a micro switch or magnetic reed switch that would provide a pulse when the gate passes by it. One problem with that is that you would not know for sure which way the gate was since it could get out of sync. You could go with one of the better Sonoff's with a current sensor and connect say a switch that closes when the gate is open with a high value resistor (light bulb maybe) in series with it. Then you would know the status of the gate by checking to see if it was drawing current.
Huh? I don't follow any of that. The app reads the state of the basic (on or off) and reports it. The state of the basic (on or off) is an active, not simulated output from the basic and an input to the app. The only physical input to the basic is the button on it.
You lost me. If you want to read the state of the device at the device just connect to the relay! Nothing is "simulated". The app reads the state of the device on your phone, the relay contacts are open or closed at the device. The state can be changed either by sending a signal from the app or pressing the button on the device.
There is no input on the basic that you can manipulate other than the pushbutton switch. GPIO14 is available on the header but not implemented in the standard firmware or app. As I said earlier go with something like the POW and connect a reed switch in series with a fixed resistor to. If you already have a high/low output from the gate control you can use a simple transistor switch and a resistor to produce two different "current" readings.
There is no input you can manipulate on the basic other than the push button with the current firmware and app.
I wanted to get the same result (i.e. using a sonoff switch as a relay status monitor) without reflashing the sonoff and used an Arduino board. On both the external relay (in my case it was a thermostat relay) and the Sonoff relay I connected the COM input to GND and the NC (or NO) pins to a couple of digital inputs of the Arduino. I connected a digital output to the input of a photomos AQY212EH (with a series resistor of course and the other input connected to GND) and the output of the photomos in parallel to the sonoff pushbutton (soldering two wires). The program on Arduino continuously monitor the status of the relays and, if different, send a 100ms ON pulse to the photomos (and goes high for 1 second afer that), that closes the sonoff pushbutton. The sonoff toggles on the pushbutton opening.
The status of the sonoff switch can be read with eWeLink and a scene can be created to control a second sonoff (sonoff#1 ON -> sonoff#2 ON; sonoff#1 OFF -> sonoff#2 OFF).
I used this method to create a remote thermostat.