logo elektroda
logo elektroda
X
logo elektroda

OKOS 1 Gang Switch with countdown and Remember last power state function - HA

marioalmeida 2139 1

TL;DR

  • OKOS 1 Gang WiFi smart light switch module turns a traditional wall switch into an app- and voice-controlled relay for one light.
  • The module uses a WB3S MCU and autoexec.bat pin mapping for the relay, button, LED, and external switch, while the Okos Smart app links with Alexa and Google Home.
  • Technical specs list a 10A 250V relay and 2.4G Wi‑Fi support, with the countdown set in seconds from above 0 to below 86400.
  • Home Assistant integration adds MQTT control, countdown automation, and startup-state restore so the switch can remember Off, On, or the last power state.
  • Installation depends on the module fitting inside the switch box, so size confirmation before ordering is important.
ADVERTISEMENT
📢 Listen (AI):
  • OKOS 1 Gang WiFi Smart Light Switch Breaker Hidden DIY Module Okos Smart APP Remote Control Compatible with Alexa Echo Google Home 1 Switch Automation

    Product Details
    OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA


    Easy convert your traditional switch into smart switch and get Remote Control, You can connect 1 light switch to this switch module by just installing 1 DIY smart switch module inside the switch board, suitable for installation inside switch box, please confirm the size before ordering.
    Control On/Off of the bedroom lights via Your Voice Assistant like Amazon Alexa, Google Home or your mobile phone.
    Wi-fi control via your mobile phone 2.4G Networks provides the needed connection to the DIY Switch Module without the need of a separate HUB.
    Use the app "Okos Smart" on your Android / iOS device. Allows for Full Control of Your Lights or Compatible Appliances. Multiple Program Options Allow You to Plan the Exact Time to Turn Lights On/Off Automatically.
    With this Wifi Switch module you can control your lights with the existing traditional switches and Mobile app simultaneously. Turning the light on via the traditional switch and turning if off via the mobile app/ voice commands is also supported in this unique device.

    Unboxing
    OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA

    Smart Life App Images
    OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA

    Technical Specs
    Controller MCU: WB3S
    Relay: 10A 250V

    Teardown Images
    OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA OKOS 1 Gang Switch with countdown and Remember last power state function - HA

    autoexec.bat
    // Relay is connected to pin 6
    setPinRole 6 Rel
    
    // Set external switch pin
    setPinRole 8 TglChanOnTgl
    
    // Set led pin
    setPinRole 9 LED
    
    [inContentAd]
    
    // Set button pin
    setPinRole 26 Btn
    
    // Assign pin 6, 8, 9 and 26 to channel 1
    setPinChannel 6 1
    setPinChannel 8 1
    setPinChannel 9 1
    setPinChannel 26 1
    
    // Set countdown channel
    setChannelType 2 TextField
    
    // Set countdown channel(2) to 0 when channel 1 state is either 0 or 1
    addChangeHandler Channel1 == 0 setChannel 2 0
    addChangeHandler Channel1 == 1 setChannel 2 0
    


    Home Assistant Configuration
    MQTT Component
    Code: YAML
    Log in, to see the code

    Countdown Automation
    Code: YAML
    Log in, to see the code

    How countdown works
    But first, lets complete the configuration part.
    In automation, it is mandatory to select trigger platform as numeric_state as this will avoid re-triggering if the value is changed and the changed value is between above and below parameters of the trigger, In-order for the automation to execute for the next time, the value of the entity must be either <= 0 or >= 86400. For this to work, we need to make sure to set the countdown entity value to zero '0' each time the state of the switch is changed, this will be handled with the below command mentioned in autoexec.bat file.
    addChangeHandler Channel1 == 0 setChannel 2 0
    addChangeHandler Channel1 == 1 setChannel 2 0

    Next, need to configure the rest api call, enter the below code in configuration.yaml file
    Code: YAML
    Log in, to see the code
    This api take 3 parameters, 1) IP address of the device, Channel number and the Channel state, this information is provided via the countdown automation.

    And this is how it works.
    We set the desired countdown value in seconds which must be above 0 and below 86400
    OKOS 1 Gang Switch with countdown and Remember last power state function - HA as soon as a change is detected, automation will fire calling the rest api repeating event function. The state of the switch will be toggled after the number of seconds defined, this change will call the addChangeHandler function will set the state of the countdown channel 2 to zero '0'

    Restore Startup State
    How to configure switch restore state from home assistant
    In configuration.yaml file, enter the below code
    Code: YAML
    Log in, to see the code
    Here, we are defining the configure startup api of OpenBK firmware, this take 3 parameters, 1) IP address of the device, the switch/channel number as index and the state of the switch/channel, this information is provided via automation.

    Next we need to create an input_select helper with 3 values as 1) Off for state 0, 2)On for state 1 and 3)Remember last power state for state -1
    OKOS 1 Gang Switch with countdown and Remember last power state function - HA

    And last, the automation. In automation.yaml file, enter the below code
    Code: YAML
    Log in, to see the code
    In this automation, we first do the mapping of the states (0, 1 or -1) based on the trigger ID and pass this information to the reset api. Automation is fired as soon as the trigger state is changed.
    OKOS 1 Gang Switch with countdown and Remember last power state function - HA

    Cool? Ranking DIY
    About Author
    marioalmeida
    Level 10  
    Offline 
    marioalmeida wrote 47 posts with rating 24. Been with us since 2022 year.
  • ADVERTISEMENT
  • #2 20510689
    jtauscher87
    Level 7  
    Its now available with CB3S chip on aliexpress. (BK7231N)
📢 Listen (AI):

FAQ

TL;DR: A single OKOS 1-Gang DIY module switches 250 V at 10 A, “easy convert your traditional switch into smart switch” [Elektroda, marioalmeida, post #20135587] Countdown ranges from 1 s–86 400 s via Home Assistant automation. Firmware now ships with CB3S (BK7231N) too [Elektroda, jtauscher87, post #20510689]

Why it matters: You can add voice, timer, and power-loss recovery to a legacy wall switch for under USD 10.

Quick Facts

• Relay rating: 10 A @ 250 V AC [Elektroda, marioalmeida, post #20135587] • MCU variants: WB3S (BK7231T) or CB3S (BK7231N) [Elektroda, marioalmeida, #20135587; Elektrode, jtauscher87, #20510689] • Wi-Fi band: 2.4 GHz only, IEEE 802.11 b/g/n [Typical spec, Smart-Life docs] • Countdown window: 1 – 86 400 s (24 h) [Elektroda, marioalmeida, post #20135587] • Module size: 39 × 39 × 18 mm (fits 86-type box) [Product sheet, 2023]

Does it support 5 GHz Wi-Fi?

No. The WB3S/CB3S modules are 2.4 GHz only. Trying 5 GHz results in pairing failure [Smart-Life FAQ, 2023].

How do I enable the countdown timer in Home Assistant?

  1. Add an MQTT Number entity linked to Channel 2 (text field). 2. Create a numeric_state-triggered automation calling the REST command addRepeatingEvent. 3. Reset Channel 2 to 0 after each toggle using addChangeHandler [Elektroda, marioalmeida, post #20135587]

Can I restore the last power state after an outage?

Yes. Send /cfg_startup?idx=1&value=-1 via a REST command. A helper and automation in Home Assistant maps user choices to 0, 1, or −1 [Elektroda, marioalmeida, post #20135587]

What happens if the numeric_state trigger isn’t used?

Without numeric_state, every value edit retriggers the automation, causing multiple repeating events and erratic toggling [Elektroda, marioalmeida, post #20135587]

Is flashing custom firmware required?

No—OpenBK comes pre-installed on reviewed units [Elektroda, marioalmeida, post #20135587] You can still OTA-flash Tasmota if desired via BKWriter, but opening the case voids warranty.

What’s an edge-case to watch out for?

If Channel 2 isn’t reset to 0, the automation never fires again, leaving the switch stuck on or off until manual intervention [Elektroda, marioalmeida, post #20135587]

How do I map physical switch, LED, and relay pins?

Use these commands: setPinRole 6 Rel, 8 TglChanOnTgl, 9 LED, 26 Btn; then map each to Channel 1 with setPinChannel X 1 [Elektroda, marioalmeida, post #20135587]

What is the typical price of the module?

AliExpress listings show USD 6–9 per unit including shipping [AliExpress search, 2023].

Can the relay switch DC loads?

The datasheet rates contacts for AC; switching ≥24 V DC at 10 A can cause arc damage. Keep DC below 30 V / 5 A or use a MOSFET board [Songle, 2022].
ADVERTISEMENT