SGC01 smart wifi garage opener

Hi.

I bought a swing gate opener which included a SGC01 wifi smart control. I opened it up and it’s controlled by an ESP12 I believe. I managed to flash it with EspHome, but I am struggeling on controlling the relay.

I tried to do a continuity check between COM port on relay and the different pins on the ESP without luck.

Tried a couple of “random” pin configurations in EspHome, but if I choose the wrong one I have to solder back and re-flash. Any tips on how to find the correct pin for controlling the relay?

Figured it out. For future refernce if it can help others, this is the pins for momentary switch and door sensor for this board

esp8266:
  board: esp12e

switch:
  - platform: gpio
    pin: 15
    id: relay
    name: "Swing gate"
    icon: "mdi:gate"
    on_turn_on:
    - delay: 500ms
    - switch.turn_off: relay
    
binary_sensor:
  - platform: gpio
    device_class: opening
  # filters: 
  #   - invert:  depending on if reed switch is normally open or normally closed
    name: "Swing gate status"
    pin:
      number: 16
      mode: INPUT
1 Like

Do you know what the header pinouts are on the board to be able to flash it?

Thanks

Never mind, I’ve worked it out
SGC01-Flash Pins

Hi, i’m using the exact the same device(sgc01 smart wifi) on my sliding gate. It controlled by a xhouse app. xhouse app has no direct integration to HA. Can someone help me if there is a way to integrate this device into HA? Or can someone share how to flash this device to esphome? I would like to expose this into HA and have control locally.

Hi all, do you know if this works with Tuya / Smart Home app? Or do I have to sign up to ANOTHER app?

If you have a USB to serial adapter you can connect to the ESP chip on the SGC01 board as per @cygnus-x1 post above.

R to the serial adapters TX pin,
T to the serial adapters RX pin,
Power to power, and ground to ground.

More info on USB to serial adapters here: Getting Started - Tasmota Under Serial Programmers.

More info on connecting to the ESP board here : Physically Connecting to your Device — ESPHome Including some important notes about how to put the board in flashing/programming mode. You might have to install drivers, bridge GPIO0 and GND, and/or have to power cycle after erase and before uploading etc.

This is the code I used in ESPHome:

esp8266:
  board: esp12e

switch:
  - platform: gpio
    pin: 15
    id: relay
    name: "Swing gate"
    icon: "mdi:gate"
    on_turn_on:
    - delay: 500ms
    - switch.turn_off: relay
    
binary_sensor:
  - platform: gpio
    device_class: opening
    name: "Swing gate status"
    pin:
      number: 16
      mode: INPUT

I got this device working in Home Assistant using XHouse IOT API calls. Unfortunately there is no local API. It all goes via http://47.52.111.184:9010/xhouseAppEncapsulation
so no SSL encryption either. However they do use timestamps and tokens in their HTTP Headers so it is somewhat secure.

I would recommend if you can flash it with ESPHome or swap it out with, dare I say, a Tuya alternative as at least they have a local API. This would likely be a drop-in replacement: Wofea WiFi Smart Garage Door Opener Controller DC12 DC24V - AliExpress
or a Konnected door opener which comes with ESPHome pre-installed: Smart Garage Door Opener White (v2) – Konnected

Anyway for anyone that would prefer to leave their XHouse IOT device as is you can use this AppDaemon code: XHouse IOT AppDaemon for Home Assistant · GitHub

I tried really hard to instead use Node-Red or n8n but I couldn’t get it to work. However using AppDaemon is super easy.

Written guide below or follow along with the video guide. https://youtu.be/U8Lxwaw6P1E

Using XHouse IOT Device with Home Assistant via AppDaemon

Step 1: Install the AppDaemon Addon in Home Assistant

If you haven’t already, install AppDaemon through Home Assistant’s Add-on Store or as a Docker container.

Step 2: Add AppDaemon .py file

Download the xhouse.py file and put it in your AppDaemon apps directory e.g.

\addon_configs\a0d7b954_appdaemon\apps

Step 3: Update apps.yaml file

Paste in the apps.yaml configuration into your apps.yaml file. Change the email and password fields to your XHouse IOT account details.

Step 4: Restart AppDaemon

After saving both files, restart AppDaemon to load the app.

How It Works

  1. AppDaemon logs in to your XHouse IOT account when it starts
  2. It hopefully discovers all your devices and creates cover or switch entities in Home Assistant (it has only been tested with the SGC01 so it might not work with other devices)
  3. It refreshes the devices state every 5 minutes (configurable)
  4. You can control your device through Home Assistant’s UI

The entities will appear as a cover or switch with entity IDs such as cover.xhouse_800421019117424640.

Please note that using this will cause your app on your phone to log out. Ideally create a second XHouse IOT account and share the device with it. That way you can use the app and Home Assistant simultaneously.

I’ve a sliding gates and the installer is offering me to configure a SGC01 smart Wifi to control it… I don’t want to go on the trouble of going through the API on the Xhouse cloud (for security reason I’m filtering traffic) and I’m not keen to re flash the ESP module (sounds fun but don’t have time and all the equipment to do it).
Would it be easier to install a Shelly module (Shelly 1 Gen3) to control the gate ?

Actually yes the Shelly would be a great alternative to the SGC01. You would likely need to do a little bit of configuring on the Shelly to get it to work how you want it but there’s heaps of videos out there explaining wiring it up, how to use it with a dry contact sensor etc.

Just wanted to drop a thank you. I was relying on google to allow me to open/close my gate using home assistant but it frequently stopped working with google saying it was offline. I had no luck flashing my particular XH-SCG01 as mine has an ESP32c2-12 and I just couldn’t get anywhere with it. This is a great alternative solution.

1 Like

Thank you !
I got some improvement on the integration of my swing gate controller from the same supplier … ,However I am wrestling with a problem : “This entity (“switch.xhouse_978742808435232768”) does not have a unique identifier, therefore its settings cannot be managed from the user interface. See the documentation for details.”


What settings are you wanting to change? Unfortunately Appdaemon doesn’t allows for unique ID entities via the method I used. It could be expanded to use MQTT which would allow for unique ID’s. But perhaps the easiest method would be to edit configuration.yaml and add a template switch or cover.

template:
  # For a switch (replace DEVICE_ID with your actual device ID)
  - switch:
      - name: "XHouse Switch Name"
        unique_id: xhouse_switch_DEVICE_ID
        state: "{{ states('switch.xhouse_DEVICE_ID') }}"
        turn_on:
          service: switch.turn_on
          target:
            entity_id: switch.xhouse_DEVICE_ID
        turn_off:
          service: switch.turn_off
          target:
            entity_id: switch.xhouse_DEVICE_ID
        availability: "{{ states('switch.xhouse_DEVICE_ID') != 'unavailable' }}"
        icon: mdi:power-socket

  # For a cover/gate (replace DEVICE_ID with your actual device ID)
  - cover:
      - name: "Gate Opener"
        unique_id: xhouse_gate_DEVICE_ID
        state: "{{ states('cover.xhouse_DEVICE_ID') }}"
        device_class: gate
        open_cover:
          service: cover.open_cover
          target:
            entity_id: cover.xhouse_DEVICE_ID
        close_cover:
          service: cover.close_cover
          target:
            entity_id: cover.xhouse_DEVICE_ID
        availability: "{{ states('cover.xhouse_DEVICE_ID') != 'unavailable' }}"

Ideally this would be made into a HACS integration, but I figured Appdaemon would involve less maintenance and breaking changes from HA updates.

Thank you !

I have to dig a little bit further as my twin gate controller has three/four functions:
small pedestrian gate to open
twin gate to open
gate or gates closure
emergency stop

Thank you

Regards

Do all those functions work correctly for you in Home Assistant? This was only tested on a device that just has a simple open/close, but I did try to make it support multiple entities if applicable.

Hi @BenAndo, thank you for developing this solution. I’m using an EGA-18 WiFi+BLE Swing Gate opener, and your script successfully discovers and registers the device. However, I’m unable to control it and the state remains “open” even when the gate is physically closed.

Here are the device details from the attributes pane:

  • Detected model: EGA1800
  • Device type: WIFIANDBLE_EGA

When I attempt to control the device, I receive the following error:

INFO xhouse: DEBUG: Control response: 200 - {"code": "809000000002", "msg": "\u8bbe\u5907\u8d85\u65f6", "errorMap": null, "result": null}

Would it be possible to add support for this device model? I’m also open to provide any additional information needed. This device is the same with @Euge56’s and has the mentioned functions (e.g., pedestrian gate, main gate open/close, emergency stop). I may be able to help gather information for mapping the API behavior, though I’m not sure exactly how to proceed.

Hi @shrimpshark thanks for the detailed information. Yes I’d be happy to add support for that device. I’ve gone ahead and refactored the code a little bit and made it hopefully have better generic support other devices such as yours.

First override your xhouse.py code with the new version that I’ve just published and let me know if it’s any better. I’ve also added in better debugging where if debugging is enabled it’ll output the API response which will help me add official support for your device. If you paste it in I’ll take a look. It should look something like:

2026-03-09 09:11:18.998951 INFO xhouse: DEBUG: { "code": "0", "msg": "success!", "errorMap": null, "result": { "background": null, "groupName": null, "deviceInfos": [ { "id": 800421019117424640, "deviceId": "800421019117424640", "alias": "Garage Door", "deviceAlias": "Garage Door", "deviceType": "WIFI_CONTROL", "model": "XH-SGC01", "firmwareVersion": "3.0.3", "deviceName": "B0004365", "deviceNo": "B0004365", "hostNo": null, "isAdd": 0, "action": null, "hostId": null, "status": 1, "properties": [ { "key": "Switch_1", "type": "INT", "value": "1", "name": "\u5f00\u5173", "icon": "WIFI_CONTROL_8", "mode": null, "relayTime": null }, { "key": "VoiceControl", "type": "INT", "value": "1", "name": "VoiceControl", "icon": null, "mode": null, "relayTime": null }, { "key": "bleCode", "type": null, "value": "75903487", "name": null, "icon": null, "mode": null, "relayTime": null }, { "key": "wifiName", "type": null, "value": "", "name": null, "icon": null, "mode": null, "relayTime": null } ], "primaryUser": 0, "validStartTime": 978278400000, "validEndTime": 4102243200000, "subDeviceInfos": null } ], "icon": null } }

If the update did in fact add working support for your device then please also toggle all the entities and paste in the logs e.g.

2026-03-09 09:19:45.084626 INFO xhouse: Successfully sent close command to device 800421019117424640
2026-03-09 09:19:45.083737 INFO xhouse: DEBUG: { "code": "0", "msg": "success!", "errorMap": null, "result": " " }
2026-03-09 09:19:45.081254 INFO xhouse: DEBUG: === CONTROL RESPONSE (device 800421019117424640) ===
2026-03-09 09:19:44.727092 INFO xhouse: DEBUG: Control request body: {"deviceId": 800421019117424640, "userId": 965821322024194048, "propertyValue": {"Switch_1": 0}, "action": "Off"}
2026-03-09 09:19:44.725894 INFO xhouse: Sending 'Close' command to device 800421019117424640 (Gate Opener)
2026-03-09 09:19:44.723026 INFO xhouse: DEBUG: Cover event: close_cover for cover.xhouse_800421019117424640