Skip to content

Kesen KS 604S

Michael Ingraham edited this page Apr 18, 2019 · 36 revisions

This Tuya Wi-Fi module ESP8266 based device has a really attractive form factor and functionality (in-wall, single gang, dual outlet, USB port, each individually controllable).

@DavinKD was able to flash this device OTA using Tuya-Convert. This device must be flashed using this OTA method. Flashing this device by attaching leads to the serial interface requires disassembling and unsoldering the internal AC components to get access to the needed contacts. This makes flashing the device by this method highly undesirable.

Shopping

Configuration

It appears that there are different versions of the KS-604S. The device that @DavinKD flashed (likely purchased from Amazon in early to mid March 2019) has a different GPIO configuration than devices purchased from Alibaba in late March.

Rear

Amazon Device

{"NAME":"KS-604S","GPIO":[255,255,56,255,255,17,255,255,22,21,255,255,18],"FLAG":1,"BASE":18}

GPIO Function Configuration
2 Device Status (Green) LED1i (56)
5 Top Button Button1 (17)
12 Bottom Receptacle Relay2 (22)
13 Top Receptacle Relay1 (21)
16 Bottom Button Button2 (18)

The USB port on this variant is not switchable.

Alibaba Device

{"NAME":"KS-604S","GPIO":[56,255,255,17,57,18,255,255,22,21,32,23,255],"FLAG":0,"BASE":18}

GPIO Function Configuration
0 Device Status (Green) LED1i (56)
3 Top Button Button1 (17)
4 Top LED (Orange) LED2i (57)
5 Bottom Button Button2 (18)
12 Bottom Receptacle Relay2 (22)
13 Top Receptacle Relay1 (21)
14 Bottom LED (Orange) Relay4i (32)
15 USB Port Relay3 (23)

This configuration requires LedMask (introduced in 6.5.0.7) and SetOption63 (introduced in 6.5.0.9).

Currently, Tasmota only supports up two LEDs to indicate relay state and connectivity status. With two LEDs defined, LED1 will act as the Wi-Fi/MQTT status LED and LED2 will act as the LED that indicates relay power.

In order to have the power indicators follow the state of the relays, LedMask must be used to so that only Relay1 controls the second LED. The other orange LED GPIO must be configured as a virtual relay. A rule is used to change the state of the LED "relay" when the real relay is toggled.

Also, to avoid excessive flash writes caused by the addition of the virtual relay, disable state saves using SetOption0. In this case, Tasmota will not be able to restore the last known state so PowerOnState 3 is not an option. Select the desired power on state for the device's relays.

The following Console statements define the necessary settings and rules for configuring the indicator behavior as described above.

Backlog SerialLog 0; SetOption0 0; PowerOnState 0; SetOption63 1; LEDState 1; LEDMask 0x0001
Rule1 ON System#Boot DO Power3 On ENDON ON Power2#State DO Power4 %value% ENDON
Rule1 1
Clone this wiki locally
You can’t perform that action at this time.