DETA Grid Connect Smart Switch and Home Assistant

I recently bought a DETA Grid Connect Smart Switch from Bunnings, with the plan being to integrate them with Home Assistant, using ESPHome, or other user-provided code. I actually didn’t use ESPHome, but rather pushed my own code/image to the device.


The device uses an ESP8266 compatible chip, with a product code of TYWE3S. I’ve included a link to the manual for the TYWE3S package.

There are two different methods that I tried for replacing the image with a custom image (as I wanted to avoid the provided cloud service and integrate directly within my home network).

Method 1 – Tuya-Convert

This method uses the tuya-convert software which is a Linux based package that you use to simulate an OTA (over-the-air) update to the device. This will replace the firmware with a Tasmota or ESPHome image (or a custom image you create). This method needs a Linux computer (I used an Ubuntu USB stick), and a WiFi adaptor. Basically the software impersonates an access point to which the DETA smart switch connects, and then sends it a new image. You can only use this method once – i.e. when the original firmware is on the smart switch. Once you push a new image to the device, you’re then reliant on your own OTA for any further changes (or use method 2).

I’ve been using this method with an image generated by the Arduino IDE, but uploaded through tuya-convert.

Method 2 – Arduino IDE

This method used an AVR programmer and a couple of hookup wires to push an image to the device directly. In my case, I used an AVR programmer from DFRobot. The device basically acts as a USB to Serial converter.

Photo 8-12-19, 6 04 15 pm

Ensure the programmer is set to 3.3V and not 5V. Using the programmer, you need to connect the following pins:

  • VCC -> VCC
  • TX -> TX
  • RX -> RX
  • GND -> GND
  • GND -> GPIO0 (during programming)
  • GND -> RST (during programming)

In order to push an image to the device, you need to first put the device into programming mode. This is done by pulling GPIO0 and RST to GND for 3 seconds. Release RST (the device boots), and once you see the code upload start, release GPIO0. If you are going to put your own firmware/image on the device, make sure to include OTA code so that you can do further updates over WiFi.

This sometimes takes a few attempts. Sometimes it works first time, sometimes I might have the timing slightly off, or I may not quite have the pins in contact. So be prepared to give it a couple of attempts.

For interest, the pinouts for manipulating the button and LEDs are as follows:

  • GPIO4 = Device status LED – pull to GND/LOW to illuminate the LED.
  • GPIO12 = Button 2 – GND/LOW represents a button press.
  • GPIO13 = Relay 1 – set to HIGH to turn on the AC relay for Light 1. This will automatically illuminate the LED on the button.
  • GPIO14 = Relay 2 – set to HIGH to turn on the AC relay for Light 2. This will automatically illuminate the LED on the button.
  • GPIO16 = Button 1 – GND/LOW represents a button press.

The pinouts are the same for the single and double gang switches. I’m pretty happy with these devices as they’re compliant with Australian regulations, and very versatile due to the ESP8266 micro-controller.

I’ve since tested this with the single and double light switches, the double power point, the extension cord, the power board and the plug top – although their GPIOs are different.

For updated information on the 3 and 4 gang switches, have a look at my latest post.

~ Mike

46 thoughts on “DETA Grid Connect Smart Switch and Home Assistant

  1. Nice article Mike.
    I just spent hours trying to find the device ID (using a Man in the middle proxy) with no success. I think I’ll go down the same path as you have and do away with the cloud service. I want to run them from a local Raspberry Pi server anyway, so no need for the Grid Connect capability. Thanks for posting the info.

  2. Thanks for posting this and laying out the pins so clearly!

    I’ve got a 2 gang switch working in ESPhome, only thing I can’t get to work is the touch LED’s being on whilst the lights are off (they only turn on when the lights are turned on)… I assume them being on when the lights are off is the intended behaviour so the switch can be located in the dark. Here is my ESPhome yaml for reference for others looking to get these into HA.

    Anyone got any ideas on powering the LEDs when switches are off?


    name: switchname
    platform: ESP8266
    board: esp01_1m

    ssid: “”
    password: “”

    # Enable fallback hotspot (captive portal) in case wifi connection fails
    ssid: “”
    password: “”


    # Enable logging

    # Enable Home Assistant API


    – platform: gpio
    name: button1
    number: GPIO16
    mode: INPUT_PULLUP
    inverted: True
    – light.toggle: light_1

    – platform: gpio
    name: button2
    number: GPIO12
    mode: INPUT_PULLUP
    inverted: True
    – light.toggle: light_2

    – platform: status
    name: “Status”

    – platform: gpio
    pin: GPIO13
    id: relay_1

    – platform: gpio
    pin: GPIO14
    id: relay_2

    – platform: binary
    name: “”
    id: light_1
    output: relay_1

    – platform: binary
    name: “”
    id: light_2
    output: relay_2

    number: GPIO4
    inverted: yes


    1. Howdy – that’s the way the hardware is designed – when you activate the relay, it’s accompanying LED is lit up at the same time. They’re not independently controllable with the circuit board as designed.

      1. Yeah fair enough, I guess that design makes sense for a GPO so you have an indicator of when the switch is on or off, but definitely feel like it should have been inverted for light switches!

        Anyway, thanks for your help 🙂

      2. Hey Mike, and Josh.

        If you place a 15K-20K resistor (0805) on R20 (1+ gang), R33 (2+ gang) and R15 (3 gang) then the LEDs will be illuminated always as you desire.

        The higher the resistance, the dimmer the LED (15k might be too bright in a dark room).

        It will then switch to the standard brightness once the relay is activated.


  3. You press AND HOLD the switch button for around 5 seconds (until you hear the relay activate). Then the status LED should blink rapidly to indicate it is in pairing mode

  4. Can this Deta smart switch programming into dimmer switch ? Assume two gang switch into two dimmer switch ?

  5. No luck with the triple gang switch:

    ID: 0242416f68626d643661473931494652319ac3d59b1aa47083d6bad90fc0f89b4edd42de897e10a5b48a2eba38d708a403
    PSK: 6e9b0fada77b1646ade482f17bc0c88397f1c9b682750a49dcb9fc5c138ba4ce
    could not establish sslpsk socket: [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:1056)

    any ideas?

    1. Yup, apparently the 3 and 4 gang have had a firmware upgrade which has changed the key. The tuya-convert should have a new version soon that sorts it out. Alternatively you could solder leads onto the chip to push the code to it manually and then use over-the-air updates.

  6. Can anyone who has a deta smart plug (the type you wire to an appliance) confirm if they blue LED on the power button should light up when it’s on? Mine only flashes on startup and I would have thought it stayed on when the device is on like the wall plugs.

    1. I have one of those Deta smart plugs. It is flashed with Tasmota so it’s behaviour may not be the same as under other firmwares.

      At power on, the LED in the on/off button flashes 4 times. From then on the LED lights when the switch is on (relay is closed). This is the same whether the switch is pushed manually or activated via http or mqtt.

      Hope that helps.

    2. The LED on those is controlled by the board – they are not hardwired to indicate the relay position. This means the LED can independently controlled, but it also means you have to find which output is the one you have to control.

  7. Hi, great post. I brought 2x these plugs on the weekend. There appears to have been a firmware update to the switch so now tuya-convert doesn’t work. I’ve plugged the board into a USB to Serial converter, and I’m still not having any luck.
    Confirming that the TX & RX not crossed?
    Also what software are you using to load the firmware .bin onto the board?

    1. got it working.
      crossed TX & RX.
      used tasmotizer-1.1a for windows, on Win10. running As Administrator
      used bin tasmota-basic7.1.bin

      If the install fails, then disconnect the usb to serial dongle. refresh the com ports in tasmotizer. then while the device is connected and running, connect an ground lead to GPIO0, then to RST, hold for 3 sec. then release RST, wait 3 sec, then release GPIO0. Then click Tasmotize! button

  8. Hi Mike,
    Thanks for your work on this. I’m trying to use the manual method on a few 1 gang and 2 gang switches but am having trouble getting it into programming mode. It reboots when I pull GPIO0 and rst to ground but no lights turn on again. Should they? Tasmotizer also times out while connecting.

  9. Mike; few bits of feedback, both on the 1/2 gang models and the 3/4 gang models.

    For everyone – I had to connect the Tx on the board to Rx on my usb adaptor. Rx->Tx. In order to get it to work, I took Reset to ground at the same time as I held GPI0 to ground. I then *kept* holding GPI0 at ground during the flashing process – worked every time if I did that – no timing issues.

  10. Mike, thanks for posting this information. It has been really useful. I have managed to convert one to Homekit from Raven Systems, for a friend. Personally I’m 100% in the Android camp.
    Has anybody successfully, backed up and restored the original firmware to these? if so could you please provide some guidance? I have tried OTA on Linux and made a backup, I was merely trying to just back it up, however, unfortunately, cancel at that point is the wrong choice as it erases the firmware (I guess I should have chosen restore the original firmware).
    I have another (still Working) one which I have tried backing up using esptool, however when I restore either the backup I made using esptool, or the OTA backup, the device doesn’t appear to boot. I have tried QIO, DIO and DOUT for the SPI mode to no avail. I have successfully flashed it with alternate firmware, but want the option to be able to roll back to factory firmware. Any assistance would be appreciated.

    1. I haven’t verified it to work, but you might try this as a starting point:

      I’m not really sure why you would want to, though. The biggest reason for replacing the original firmware on these is because the original firmware is allowing a Chinese company with dubious security protocols to have access to devices inside your network. Were it not for Tasmota, I would not be using any of these devices – not even the first one I was given as a gift.

      Best Regards,

  11. Any reason why you didn’t go down the ESPHome path? I am about to embark on this journey as was curious why Tasmota over ESPHome, especially if integrating into HA. I guess they are both similar…

    1. Yeah both of those are good options and relatively straight forward, with pros and cons for each. I do a lot of this for the learning as much as the outcome though. If haven’t spent enough time comparing though to give a recommendation between them. I’d definitely recommend though using one of those before writing your own firmware for the chips!

  12. Thanks for this article Mike. I successfully upgraded mine using the high tech blu-tac approach to hold jumpers to the required pins and just linked straight to VCC and ground on the ESP from my FTDI cable. Worked a treat.

  13. Hi Guys

    recently purchased a few DETA switchs to have a play. Straight forward replacement if switching from 1 location is there a way to get it working on a 2 way switch situation?

    1. I wrote a rule in Openhab to achieve this. When Switch A is changed, update Switch B to match and vice versa. Only wire one switch to the actual light.

  14. Hi Mike, love your work but struggling to get this going.

    wondering if you could check my breadboard setup and see if I’m doing anything wrong?


    When I pull GRND and RST together, testing 2, 3 & 5sec holding intervals, I do not get pushed into the transfer process and just end with either;
    (1) “Failed to connect to ESP8266: Timed out waiting for packet header” in Tasmotizer, or
    (2) “Unexpected error: ESP Chip Auto-Detection failed: Failed to connect to Espressif device: Timed out waiting for packet header” in ESPTool.

    I have tested multiple Atmega8U2, and they are all detected without issue so its clearly me just not doing something right. Also, no difference whether on macOS or Windows.

    It’s doing my head in, haha.

    Cheers buddy.


    1. whelp as if on queue last night after posting this it just worked…. for others who may be struggling, I got it working by touching the GPIO (I called in GRND above, it was wrong – tired) & RST briefly…. so I took both to ground together, released RST, then released GPIO… this action is all done within 0.5-1.5 seconds.

      worked every time like a charm after that.

  15. ok i messed with this for a bit and the randomness of getting it in programing mode. Seems if i had it in
    pairing mode, hold a button till the status light starts flashing
    then grounded gpi0
    then grounded rst
    Then release rst and straight after within half a second released gpi0

    It would always go to programming mode without fail.

  16. thanks heaps man for this article and for the one with 3-4 gang swiitches as well!!!
    I am testing Deta switches which i am planning to use in the new house. Used Broadlink TC2 before (the one that does not need neutral wire) but those are 433mhz and not electrically certified. After some tinkering i was able to flash tasmota to a 2-gang 6912HA via serial using raspberry pi3 which worked perfectly (i soldered pins to the switches board which probably was excessive). OTA didn’t work for me, tried ubuntu VM with a usb wifi adapter (proxim orinoco) which seemed to work (it created a hotspot but wiithout psk which was weird) but the scriipt never saw the switch, and also tried OTA via rasberry pi where the script just couldn’t create a hotspot. I could be the wifi adapter or possibly i have a switch with new fiirmware (bought in July 2021) that doesn’t work with OTA so i just bit the bullet and pulled the soldering iron 🙂 after having done one, the others should be triiiviial. just integrated it with Home Assistant and it works perfectly! finally there is a viable option in Oz, just I wish there was a certified switch that doesn’t need neutral wire (probaly not happening)

  17. Quick note, Deta are starting to replace 8266 with wa2 type chip. These are NOT convertable even using hard wired serial converter. Best get in quick. Most single switches at bunnings are running with new chips. 3 / 4 button switchs are still available. Best way I found was to check serial No’s – last 6 numbers starting with 094 are still good to flash.

    1. Just a quick update regarding the serial numbers. I bought 2 yesterday with last 6 numbers starting with 094. Discovered after struggling for 10 hours not getting it working, that it had the new chip. The best way to be sure seems to look on the packaging for a “Series 2” model number, eg “6911HA – Series 2”. Both mine had that. 😦

      1. Thanks Aldo, that’s really helpful. Good to know they’ve marked the change on the box. I bought a cache of these when I first realised I could flash them. Such a shame they make these harder for modding.

  18. hi! Has anyone tried flashing the “Deta Grid Connect Smart Outdoor Double Powerpoint”? Mine has a smart energy meter that i’d really like to enable post flashing etc

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s