KS-602f 3-way switch

substitutions:
  # https://esphome.io/guides/configuration-types.html#substitutions
  device_name: bedroomlight
  friendly_name: Bedroom Light
  icon: "mdi:lightbulb"
  
esphome:
  name: ${device_name}
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: "****"
  password: "****"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Bedroomlight Fallback Hotspot"
    password: "AQBamb13afiL"

captive_portal:

# Enable logging
logger:
  baud_rate: 0
  level: none

# Enable Home Assistant API
api:

ota:

web_server:
  port: "80"


# My dimmer used the hardware serial port on the alternate pins
uart:
  rx_pin: GPIO3
  tx_pin: GPIO1
  baud_rate: 9600

# Register the Tuya MCU connection
tuya:

light:
  - platform: "tuya"
    name: "Bedroom Light"
    dimmer_datapoint: 2
    switch_datapoint: 1
    restore_mode: ALWAYS_OFF

This is what I’m trying right now.

Before hand I didnt have the restore_mode set and dimmer_datapoint was 3

on_boot is not the same as the wifi disconnecting and reconnecting.

@nickrout sounds like you are saying the toggle is happening at wifi connect. That’d make sense as when flashing the device it does restart and would need to connect wifi.

You did give me an idea that I could use onboot to narrow down the point the light is turning on.

When i have the light on and configure:

    priority: 200.1
    then:
    - light.turn_off: bedroomlight

The light will first go off and a second or so later come back on.

Even using:

on_boot:
    priority: -1000.1

light comes back on

Did you manage to identify the GPIO’s for the KS-602F 3 way switch?

@SrGeek, yes. If you scroll up to my previous comment you will see my code that includes the necessary GOIPs.

Has anyone noticed with this switch that if it is ON and you click ON it will go off. If I continue to click ON the switch toggles ON to OFF to ON. It appears that the MCU just toggles whether it gets an ON or OFF.

Hello I have tried to flash using the above diagram. My device does not seem to go into boot mode. I have IO0 sharing the ground pin from my FTDI232 serial to usb. Was there an indicator when you flashed it?

Does anyone know how this should be configured (Tasmota 8.2.0)? Using the standard Tuya MCU module selection, I can integrate with HA and hear the switch flip when clicking the HA button (led doesn’t change). When I push in the physical button on the device, I get no change in HA to reflect the button press.

Ideas?

Hello smurphy. I know this reply is probably way too late here. But I tripped across a couple of these in rooms in my house that I had forgotten about. I think I bought them in 2019…they remained uninstalled for a long time. I finally installed them when covid hit and just always used them with the Tuya firmware. I pulled one out of the wall and decided to have a go at it in 2024. I messed with it a fairly long while and discovered that even though I was wiring it up (correct to your diagram), and I was holding IO-0 low on power-up, I was just getting a green led light, and after a second it would switch to a red LED and stay there. I then took off the IO-0 from being held low and successfully figured out that this thing is setup to communicate at 9600 baud. I used the esptool.py on OSX to connect to it, so that’s why my ports might look a little odd;

esptool.py --port /dev/cu.usbserial-ABSCDGI9 --baud 9600 --no-stub write_flash -fm dout 0x0 ~/Downloads/tasmota.bin

And that’s all I did…once I figured out the baud rate and that I didn’t need the stub…it went just fine.