Martin Jerry ST02 3-way Tasmota switch

I purchased The MJ st02 with tasmota preinstalled. I was able to successfully get esphome installed through tasmota web interface with no need to open and solder wires. I used a yaml config other users had posted but could not control the switch from home assistant. I emailed Martin and Jerry and they informed me that the tasmota version is using a tuyamcu 2nd microcontroller to control the light. I have found that esphome also supports communicating with this tuyamcu but I have no idea how to set up the yaml to configure it properly.

I am curious if others have encountered this and if anyone has gotten it working with esphome.

1 Like

I too would love to get this working.

I have the same tx/rx with tuya configured but no data points come up and I get:

Initialization failed. Current init_state: 0

From the reviews on amazon, this is the tasmota settings:

I reset the module and couldn’t get it to work right, so I contacted support. They responded in a few hours, and told me what I needed to know. If you find yourself in this situation:

1. Configure the module as 'Tuya MCU (54)'
2. Set the template to:

{"NAME":"MJ 3Way Switch","GPIO":[255,255,255,255,52,53,0,0,21,9,157,255,0],"FLAG":0,"BASE":18}

3. In the console, enter:

switchmode1 5
TuyaMCU 11,1

But I don’t know how to convert that to esphome.

Update: I got it working but the status isn’t correct, it always shows as off even though setting on will toggle the light:


  rx_pin: GPIO3

  tx_pin: GPIO1

  baud_rate: 9600 #115200



  - platform: wifi_signal

    name: ${friendly_name} WiFi Signal

    update_interval: 60s

  - platform: uptime

    name: ${friendly_name} Uptime


  - platform: "tuya"

    name: ${friendly_name}

    switch_datapoint: 1

There is also a Data Point 7 which is an int value that is always 0 from what I can tell.

How do I get the status to reflect properly so that the light is on when it’s on? Anyone know?

1 Like

@JohnGalt1717 I posted on github asking the same question of you.
I just purchased five of these switches which I did not realize that there wa no esphome yaml for it.
I have been tinkering for a few days with it based on the yaml you posted, but I am missing something.

Would you mind posting the entire yaml code that pertains to the switch.
Thank you for the help.

Sorry yes. That’s the best I can do too.

1 Like

@JohnGalt1717 hi. i stumbled on this thread after A LOT of research on how the switch behaves, TuyaMCU, etc… anyway, this is what i used to get the switch to report the actual status. you should be able to modify this from “switch” to “light” to suit your original post

  - platform: tuya
    sensor_datapoint: 1
    name: ${devicetitle} Tuya Switch State
    id: ${deviceid}_tuya_switch_state
    internal: true

  - platform: tuya
    switch_datapoint: 1
    name: ${devicetitle} Tuya Switch
    id: ${deviceid}_tuya_switch
    internal: true
  - platform: template
    name: ${devicetitle} Switch
    id: ${deviceid}_switch
    lambda: |-
      if (id(${deviceid}_tuya_switch_state).state) {
        return true;
      } else {
        return false;
      - switch.turn_on: ${deviceid}_tuya_switch
      - switch.turn_off: ${deviceid}_tuya_switch

hope it helps.