KS-602f 3-way switch

Unfortunately I have no idea how it communicates.

Yes but Tasmota does and their code is open source. So look at the code and look at the config and translate it to esphome.

Or don’t, and be happy with tasmota.

How did you get the chip into flash mode. I cannot seem to get tasmota to flash to it. I used the header in the top right have not had any success.

1 Like

I didn’t have an issue with getting it to flash. Just make sure GPIO0 is pulled low when it boots up.

Did you have it wired up to the usb to serial adapter like this? Did you solder in wires or just push Dupont connectors in the holes?KS-602F_wiring

1 Like

Yeah, that’s how I wired it. I use a NodeMCU with EN pulled to ground for flashing, but it’s the same as the usb to serial adapter. I didn’t solder, I just push the wires in place and hold at an angle to make contact. I think I got it to flash on the first try.

Did any of you get the KS-602F working with ESPHome? I successfully used Tuya Convert to get custom flash on it no problem, but having trouble finding an ESPHome yaml config that lets me actually operate the switch. https://esphome.io/components/light/tuya.html Isn’t too much help as the GPIOs and such in the example aren’t necessarily for this particular model of switch.

Ok, just kidding. I got the right UART pins and it’s working now. Here is the config I used in case anybody else happens along this thread looking for info. (My .common.yaml includes all the other config you need (api, wifi creds, etc.))

ESPHome makes you define a dimmer ‘datapoint’ even though this is not a dimmer, just a 3-way switch. It seems to work fine as it is and I just used the example value form the ESPHome docs.

I don’t see any way to control the LEDs or interface with the button or relay directly, which is a real bummer as I change the normal LED pattern on my other switches to be off when the light is off. The default for this switch is green when off and red when on. I would also love to access double-press or long-press functionality, but not seeing a way here… :frowning_face:

substitutions:
  device_name: kitchencounters       # hostname & entity_id
  friendly_name: Kitchen Counters    # Displayed in HA frontend

logger:
  baud_rate: 0
  
<<: !include .common.yaml

esphome:
  name: ${device_name}
  platform: ESP8266
  board: esp01_1m

uart:
  rx_pin: GPIO3
  tx_pin: GPIO1
  baud_rate: 9600

# Register the Tuya MCU connection
tuya:

# Create a light using the dimmer
light:
  - platform: "tuya"
    name: "${friendly_name}"
    dimmer_datapoint: 3
    switch_datapoint: 1

Have you seen that when flashing this light or if WiFi disconnects and reconnects the switch toggles?

I haven’t actually noticed what mine specifically does yet (I just got it installed), but one of the (imo very few) advantages of the separate MCU model is that you can flash the chip all day and it won’t affect the basic switch functionality or state of the switch since that is all controlled separately. So, neither event should affect the light unless you ESP code was actually altering the state on boot or something like that.

I was thinking state on boot, just cant find a setting to get it not to toggle.

Was a bigger issues when i had the router restarting on Saturdays at 4am and being woken up by the light turning on! :smiley:

@latic What’s your full YAML? Maybe it has to do with the default restore_mode: setting for a light:?

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?