DETA Grid Connect 3 and 4 Gang Light Switches and Home Assistant

I’ve been using the Deta Grid Connect 1 and 2 gang light switches with Home Assistant for about 6 months now – as mentioned in this post. The 3 and 4 gang switches have finally arrived, and having picked one up from Bunnings, I was keen to get it setup and the firmware replaced with my own.

As mentioned in that previous post, replacing the firmware with ESPHome, your own firmware, or Tasmota has two methods. The first method is to use tuya-convert over WiFi, and the second method is to use the headers on the circuit board to plug your own leads in and upload firmware through a serial connection. Unfortunately, the good people at Deta have removed the headers on the circuit board, and changed the key used by the firmware rendering tuya-convert unusable.

It is only a matter of time though before tuya-convert is updated which will enable a wireless push of new firmware to the device. Luckily though, even without the headers, you can still use a serial connection to the board. The difficulty though, is you either need to solder your own leads on or be a little dexterous. As I mentioned on the earlier post, you need to provide power and ground to the board; you need to connect your serial programmer’s TX and RX; and you need to pull RST and GPIO0 to ground, release RST to boot the device and then release GPIO0 for programming mode.

In order to avoid soldering, or needing 4 hands, you can connect power and ground to the bottom pins on the board. You need to supply 5V though, as the pin doesn’t connect directly to VCC on the chip, rather it connects to the input side of the voltage regulator. So providing 5V on the pin gets you 3.3V on the chip. I used a bread board power supply to get the 5V, and I shared the ground on the bread board power supply to my programmer.

I then used a couple of ground connected leads to hold against RST and GPIO0 to reboot the device. Releasing RST boots the device, and then releasing GPIO0 a few seconds later enables programming mode.

Once in programming mode, I used a little header block with 2 pins bent away, and connected them to TX and RX on my programmer. I then simply held it against the TX and RX pins on the chip while pushing firmware through the programmer.

Once the firmware had uploaded, I released the TX and RX pins, and then pulled RST to ground momentarily to boot the device.

The firmware I pushed to the device supports OTA (over the air) updates, so hopefully that was only a one off activity! The good news is though, you only ever have to hold 2 pins against the chip at any one time in your hand – so its not too difficult even without the header area on the board.

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.

~ Mike

27 thoughts on “DETA Grid Connect 3 and 4 Gang Light Switches and Home Assistant

  1. Hi Mike,

    I’ve just purchased one of these and while the above makes some sense, I don’t understand all of it… any chance you could explain and/or film a little? Just mostly need some advice with regards to boot/program mode and process…

  2. Just confirming I finally worked it out and have successfully flashed a 4 gang switch.

    Appreciate this guide, was great the 4 gang is slightly different although the above pictures are still relevant.

    Cheers

    1. What did you do differently with the 4 gang one – you noted it was slightly different – I couldn’t get it to flash for some reason.

      1. Hi Steve,

        I’ve done it a couple of times now, it’s exactly the same as the 3 gang describe only the board looks different.

        Can you get it to see the ESP? Or are you having a trouble getting it connected?

      2. I’ve not yet flashed my 4-Gang, I’ll be doing that tonight, but I’ve successfully flashed half a dozen different tuya’s over the last 2 days via OTA, I have three of these and several older sonoffs that need to be done serially.

    2. Hi – my usb to serial adapter has a 3.3v pin and 5v. I connected the 5v to my breadboard then connected a jumper lead to the 5v pin on the board per Mike’s picture. Then connected ground of usb to breadboard and jumper wire from breadboard to ground per Mike’s piacture. This gave the board power as the Led lights came on. Then I connected a jumper from ground (negative on breadboard) to rst pin and the lights in the board went out. Then I connected a jumper from ground to the goio00 pin and the led on the board came on steady. I released the rst and then released the gpio00 3-8 seconds Later (tried different times) but as soon as I pulled the lead of gpio00, the led light on the board went out. Then I connected the rx in usb to Tx on board and Tx on usb to rx on board. (Actually tried vice Versa as well and that didn’t work either) While holding the ex/Tx pins in place, I clicked Tasmotise on tasmotiser after having selected the right com port (com3) and the top Tasmota bin release plus the tick box of backup and flash. The backup part my have worked as it put a file on my pc but the download firmware part says failed to connect to esp times out waiting for packet header and sometime I got invalid head of packet ox4f. Either way, nothing downloaded as nothing moved off the zero % in the download bar. Not sure what I’m doing wrong . Strangely, I was able to push the WiFi SSID and password to the device as it said 110kb pushed.

      1. I’ve tried for about 12 hours to get this to work – all my it’s capable devices work but not this one. I’ve tried everything – is there someone I can mail my device to with paid return mail to see if they can make it work. It’s not going into flash mode.

  3. Hi Mike. Wondering if the individual switches be used to control other devices? For example. I’d like to replace a single light switch with a 3-gang. First button will control the existing light via the current wire and give the switch its power, the other two buttons programmed (in home assistant) to run another device elsewhere in the house (maybe trigger a HA automation). Would this type of config be possible with ESPHome or can they only control wired lights?

    Cheers.

    1. Hi Andrew – you could leave one of the output light connections not connected to anything – the software running on the controller doesn’t actually know if there’s something there. You can do a lot of cool stuff with them just as a switch.

      I’ve actually got one connected to a LIFX wifi light. However, its programmed so that when I press the wall switch, it doesn’t actually power off the light, but rather tells HA to inform the wifi bulb to turn off (but it stays powered). If I then hold the light switch down for 3 seconds, it actually powers the circuit off. I’ve got a friend with one where if you hold the button down, it tells HA to turn off all lights.

      1. Hi Mike, first off thank you for your posts. I’ve just flashed some switches with ‘spare’ gangs just like above.

        First time tasmota user and hoping you might tell me more about how to make smart buttons out of the spare gangs? Should I remove the corresponding relay from the template and just leave the button?

        I’ve seen talk around Switch mode but unsure how to apply it to a specific gang and utilise button hold modes.

        Otherwise everything is happy in home assistant 😀

        Cheers,

        Linton

  4. Just wanted to call out and say that your advise was golden – I bought these from my local bunnings – First one went fine with OTA – second one had the new firmware that had the same issue – Your instructions for wiring were perfect. I just finished documenting my process for my own prosperity but just wanted to call out that it was awesome.

  5. Just reaching out as has others. Great stuff Mike, much appreciated. I’ve been holding off doing an old Sonoff 4ch pro and after doing one of my 2-gangs (serially following your instructions), I went ahead and did a few more, including that Sonoff (which was a tad harder TBH).

  6. Just finished getting an electrician to install 24 DETA smart switches including 1, 2, 3 and 4 gang. All flashed thanks to your guides. Working brilliantly. Thanks for putting this information out there.

    1. I did have one question tho, I assume it’s a simple answer. In Home Assistant, it appears as a switch and a status entity. I am assuming the status is the WiFi signal strength?

  7. I managed to flash my 3 Gang Switch!
    Thanks for the instructions. I ended up soldering on to Ground, RST, GPI0 with some little bare ends. Makes the boot up process easier.

    I cant figure out the GPIO settings:
    Button1 = GPIO16
    Relay2 = GPIO14
    Relay3 = GPIO12

    ESPHome warns me about using GPIO6-11 and the others dont seem to work?

    Here is my work in progress yaml

    substitutions:
    devicename: esppowderroom
    upper_devicename: Powder Room
    friendly_name: “Powder Room Switch”
    button1_name: “Heat” ### Left or Top
    button2_name: “Fan” ### Middle
    button3_name: “Light” ### Right or Bottom

    #################################
    esphome:
    name: esppowderroom
    platform: ESP8266
    board: esp01_1m

    wifi:
    ssid: !secret wifi_ssid
    password: !secret wifi_pass

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

    captive_portal:

    # Enable logging
    logger:

    # Enable Home Assistant API
    api:
    password: !secret api_pass

    ota:
    password: !secret ota_pass

    sensor:
    – platform: uptime
    name: $upper_devicename Uptime

    – platform: wifi_signal
    name: $upper_devicename WiFi Signal
    update_interval: 15s

    #################################

    status_led:
    pin:
    number: GPIO4
    inverted: True

    output:
    # Button1
    – platform: gpio
    pin: GPIO3
    id: relay1

    # Button2
    – platform: gpio
    pin: GPIO14
    id: relay2

    # Button3
    – platform: gpio
    pin: GPIO12
    id: relay3

    light:
    – platform: binary
    name: $upper_devicename $button3_name
    output: relay3
    id: light1

    switch:
    – platform: output
    output: relay2
    name: $upper_devicename $button2_name
    icon: “mdi:fan”
    id: fan1

    – platform: output
    name: $upper_devicename $button1_name
    output: relay1
    id: heat1

    – platform: restart
    name: $upper_devicename REBOOT

    # Buttons
    binary_sensor:

    # Button1
    – platform: gpio
    device_class: heat
    pin:
    number: GPIO16
    mode: INPUT_PULLUP
    inverted: True
    name: “${button1_name} Button”
    #toggle relay on push
    on_press:
    – logger.log: “GPIO HEAT pushed”
    – switch.toggle: heat1

      1. I figured it out with a hour more of Guess and Check…

        Here is the final working config (tested in prod for 2 days):

        substitutions:
        devicename: esppowderroom
        upper_devicename: Powder Room
        friendly_name: “Powder Room Switch”
        button1_name: “Heat” ### Left or Top
        button2_name: “Fan” ### Middle
        button3_name: “Light” ### Right or Bottom

        #################################
        esphome:
        name: esppowderroom
        platform: ESP8266
        board: esp01_1m

        wifi:
        ssid: !secret wifi_ssid
        password: !secret wifi_pass

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

        captive_portal:

        # Enable logging
        logger:

        # Enable Home Assistant API
        api:
        password: !secret api_pass

        ota:
        password: !secret ota_pass

        sensor:
        – platform: uptime
        name: $upper_devicename Uptime

        – platform: wifi_signal
        name: $upper_devicename WiFi Signal
        update_interval: 15s

        #################################

        output:
        ### Button1
        – platform: gpio
        pin: GPIO5
        id: relay1

        ### Button2
        – platform: gpio
        pin: GPIO14
        id: relay2

        ### Button3
        – platform: gpio
        pin: GPIO12
        id: relay3

        light:
        – platform: binary
        name: $upper_devicename $button3_name
        output: relay3
        id: light1

        switch:
        – platform: output
        output: relay2
        name: $upper_devicename $button2_name
        icon: “mdi:fan”
        id: fan1

        – platform: output
        name: $upper_devicename $button1_name
        output: relay1
        id: heat1

        – platform: restart
        name: $upper_devicename Restart

        # Buttons
        binary_sensor:
        ### Button1
        – platform: gpio
        device_class: heat
        pin:
        number: GPIO16
        mode: INPUT_PULLUP
        inverted: True
        name: “${button1_name} Button”
        ### toggle relay on push
        on_press:
        if:
        condition:
        switch.is_off: heat1
        then:
        – switch.turn_on: heat1
        – delay: 600s
        – switch.turn_off: heat1
        else:
        – switch.turn_off: heat1

        ### Button2
        – platform: gpio
        pin:
        number: GPIO04
        mode: INPUT_PULLUP
        inverted: True
        name: “${button2_name} Button”
        ### toggle relay on push
        on_press:
        if:
        condition:
        switch.is_off: fan1
        then:
        – switch.turn_on: fan1
        – delay: 600s
        – switch.turn_off: fan1
        else:
        – switch.turn_off: fan1

        ### Button3
        – platform: gpio
        device_class: light
        pin:
        number: GPIO3
        mode: INPUT_PULLUP
        inverted: True
        name: “${button3_name} Button”
        ### toggle relay on push
        on_press:
        – light.toggle: light1

Leave a Reply

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

WordPress.com Logo

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

Google photo

You are commenting using your Google 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