Martin Jerry ST01 3-way and ESPHome

I picked up a Martin Jerry ST01 3-way switch, which I plan to hook up to the power side with a dumb 3-way on the load side. I know that Tasmota will work with it, but I’m an ESPHome guy.

There was a thread about ESPHome compatible 3-way switches but seemed to move on to the Moes and Treatlife versions. It also spoke of Tasmota quite a bit. I never really determined whether somebody got ESPHome working on the MJ switch or not.

In that discussion, a load sensor on GPIO 14 was mentioned. Looking at the Martin Jerry ST01 board and the TYWE3S, I do NOT see a solder pad on GPIO 14… it appears to be unused from what I can tell.

There are only a few pins active. Note that 3.3v and GND are reversed between the back and front of the board, so the others may be too:

GPIO 3 & GPIO 4 - LED (red and blue, not sure which one is which yet)
GPIO 12 - Assume relay, goes down to the power supply board labeled “CK” on back
GPIO 13 - Button for sure (pulls go GND) that also goes down to the PS board labeled “SR” on back

I’m beginning to think that a separate MCU (8-pin unmarked chip near the 4-pin connector on the power supply board) controls the relay.

Normally one would define an “output” with the GPIO pin to control the relay, then assign that to a “binary_switch” or a “light”. Any ideas on whether that would work if it’s also an input? In other words, would it reflect in the binary_swich or the light if the status changes remotely (goes high or low)?

I do have some ideas, but has anybody been able to get ESPHome working on this switch?

Edit: slightly different device name, but similar pinout to the 3way. Also you can learn a lot from the tasmota page. Martin Jerry ST01 3 Way Switch (MJ-ST01) Configuration for Tasmota

Got a working ESPHome config that I’ve tested, for those who are looking for a working YAML. It was shockingly simple and pretty much the same config as their normal 1-way switch.

According to the logs, whatever they are using to detect load or swap of the travelers down on the PSU board is simply using the button (GPIO 13) to signal the ESP module. This is why the physical button on the main board also has a connection to the power supply board via the 4-pin connector.

This means that whether you push the physical button on the MJ switch or toggle the light from the dumb 3-way switch, both are just a button press to the ESP8266 module. Very clever.

Test rig:

  • Martin Jerry on the live side
  • Dumb 3-way switch on the load side.

Blue LED when load is on, no LED when off. Red LED is status.

Here’s the working ESPHome YAML which presents as a switch in HA.

# ##################################
# Martin Jerry 3-way Switch ST01
# ##################################
# D2 GPIO4: red led (inverted)
# D1 GPIO5: blue led (inverted)
# D6 GPIO12: relay
# D7 GPIO13: button (inverted, input_pullup)
# ##################################

# Change to your preference
substitutions:
  device_name: mj3waytest
  friendly_name: MJ 3way Test

esphome:
  name: $device_name
  comment: $friendly_name
  
esp8266:
  # Using esp01 even though esptool shows 2MB flash
  board: esp01_1m

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

# Enable logging
logger:

# Enable Home Assistant API
api:

# Enable OTA updates
ota:

# Enable web server
web_server:
  port: 80

# Status LED
status_led: 
  pin:
    number: GPIO4   # Red LED
    inverted: True


# Button, use 10ms debounce (seems to work for me)
binary_sensor:
  - platform: gpio
    name: ${friendly_name} Button
    id: button
    pin:
      number: GPIO13
      mode: INPUT_PULLUP
      inverted: True
    internal: True
    filters:
      - delayed_on: 10ms
      - delayed_off: 10ms
    on_press:
      - light.toggle: main_light
      
# Blue LED
switch:
  - platform: gpio
    name: ${friendly_name} Blue LED
    id: blue_led
    pin:
      number: GPIO5
      inverted: True
    internal: True

# Relay
output:
  - platform: gpio
    id: relay
    pin:
      number: GPIO12

# I prefer to use 'light' instead of 'switch', since mine will
# be used to control a light
light:
  - platform: binary
    name: $friendly_name
    output: relay
    id: main_light
    on_turn_on:
      - switch.turn_on:  blue_led
    on_turn_off:
      - switch.turn_off: blue_led


1 Like

Thank you for the helpful description of how the high-voltage and low-voltage sides of the ST01 interact, this is very helpful! I’m trying to find a configuration where I can have the aesthetics of the ST01 on both of the 3-way switches, and still ensure that the basic on/off light changes don’t have any dependency on the wifi. I’m hoping that perhaps by putting an ST01 in for both of the 3-way switches, I’ll get the behavior I’m looking for. But I won’t know until I can test it later this week when they arrive.