logo elektroda
logo elektroda
X
logo elektroda

NAS-AB02W6 Ver 2.0 Tuya Siren+Temp+Humidity Sensor: Control LEDs with OpenBK Firmware

rylos78 6378 34
Best answers LABEL_AI_GENERATED

How can I stop the NAS-AB02W6 siren's LEDs and other TuyaMCU settings from reverting or flashing after boot in OpenBK firmware?

The thread does not show a separate LED DPID, but it shows that this NAS-AB02W6 is driven entirely by TuyaMCU over UART, so you do not configure GPIO pins; you create an `autoexec.bat` with the channel mappings instead [#21135668] The ringtone control is DPID 102 and it must be linked as an `enum`, not `val`; changing `linkTuyaMCUOutputToChannel 102 enum 4` made the selected ringtone persist across reboot, while `setChannel 4 12` alone did not [#20383126] A working full mapping was 104=alarm switch, 105=temperature, 106=humidity, 116=volume, and 103=alarm duration [#20383126] If the desired value still needs to be applied after boot, use `addEventHandler TuyaMCUParsed 0x02 addRepeatingEvent ... setChannel 4 12` so the command is resent after the MCU init packet [#20381721][#20383126]
AI summary based on the discussion. May contain errors.
ADVERTISEMENT
  • #31 21135700
    divadiow
    Level 38  
    Posts: 5236
    Help: 450
    Rate: 920
    feel free to upload factory-state unpaired full firmware dump or tuya config file

    OpenBK_BK7231N_CB2S_USB_PLUG software control panel on a webpage.
  • ADVERTISEMENT
  • #32 21278896
    cristian4
    Level 2  
    Posts: 3
    Is there any way for this doorbell to sound differently based on the events created in Home Assistant? For example, to play melody 12 when someone rings the doorbell and melody 9 when there's an alarm event?
  • ADVERTISEMENT
  • #33 21292842
    cristian4
    Level 2  
    Posts: 3
    >>20383126
    Does it always work for you and remember channels 4 and 5? For me, it doesn’t work all the time; sometimes, when I restart it, it resets to the factory sound. Do I need to use batteries somehow? In my autoexec.bat, I have these two commands:
    addEventHandler TuyaMCUParsed 0x02 addRepeatingEvent 3 2 setChannel 4 12
    addEventHandler TuyaMCUParsed 0x02 addRepeatingEvent 5 2 setChannel 5 2
  • ADVERTISEMENT
  • Startup config race and MQTT disconnect fallback issue

    #34 21298720
    cristian4
    Level 2  
    Posts: 3
    jobstjn wrote:
    Hi sir,

    1st it's the startup bug:
    there's a ~50% chance this config gets applied upon boot (so several tries are needed):
    addEventHandler TuyaMCUParsed 0x02 addRepeatingEvent 2.5 1 setChannel 4 7
    addEventHandler TuyaMCUParsed 0x02 addRepeatingEvent 3 1 setChannel 6 30
    (I think it's something similar for retain: true as a mqtt config strategy)

    2nd it's when the device disconnects from mqtt server (server down):
    gui will still report last config but device will act on default values (e.g. song 5, 10s). Regardless of when or if it reconnects.
    a regular hass automation config will stop working here, need to apply the hack above

    Additionally the minor issue of requiring delay between mqtt commands, perhaps network related?.

    I am unsure how would those ideas fix these issues.


    @p.kaczmarek2 Can you still help us with this device? We haven’t found a solution for it to keep the set melody.
  • ESPHome config for ringtone and duration control

    #35 21600251
    hinneLinks
    Level 1  
    Posts: 1
    Thanks for this thread, it helped me to got mine to work.
    I've run into the same Issues as @cristian4, wanting to change the ringtone from Home Assistant.
    Since I already had Esphome setup for other devices i tried that, and with that it works.

    My Device, a "NAS-AB02W6 V4" seems to only have the Ringing, the Ringtone Selection, the duration and the Battery Status (the volume datapoint 116 seems to be missing from mine):


    
    # from the Debug-Log of NAS-AB02W6 V4
    # [11:38:22][C][tuya:041]: Tuya:
    # [11:38:22][C][tuya:062]:   Datapoint 101: enum (value: 4)
    # [11:38:22][C][tuya:062]:   Datapoint 102: enum (value: 0)
    # [11:38:22][C][tuya:058]:   Datapoint 103: int value (value: 1)
    # [11:38:22][C][tuya:056]:   Datapoint 104: switch (value: OFF)
    # [11:38:22][C][tuya:074]:   Product: '{"p":"jsm1tlzrta3s7zja","v":"1.0.5","m":2}'
    


    I have those sirens connected via USB, so I didn't bother with the battery.
    Here is the Configuration for the other three, now the Duration and the Ringtone can be set from Home Assistant:

    
    [other stuff like 
    esphome:
    wifi:
    web_server:
        etc. omitted]
    
    
    
    bk72xx:
      board: generic-bk7231n-qfn32-tuya
    
    # tuya needs uart, pins see https://esphome.io/components/libretiny.html
    uart:
      rx_pin: GPIO10
      tx_pin: GPIO11
      baud_rate: 9600
    
    # Register the Tuya MCU connection
    tuya:
    
    
    number:
        # Duration - datapoint 103
      - platform: "tuya"
        name: "Duration (s)"
        icon: "mdi:clock-outline"
        number_datapoint: 103
        min_value: 0
        max_value: 120
        step: 1
    
    # Bell on / off - datapoint 104
    switch:
      - platform: "tuya"
        name: "Bell on / off"
        switch_datapoint: 104
    
        
    select:
        # Ringetone - datapoint 102
      - platform: "tuya"
        name: "Ringtone"
        enum_datapoint: 102
        optimistic: true
        options:
          0: doorbell
          1: fur elise
          2: big ben
          3: ring ring
          4: lone ranger
          5: turkish march
          6: high pitched
          7: red alert
          8: crickets
          9: beep
          10: dog bark
          11: police siren
          12: grandfather clock
          13: phone ring
          14: fire truck
          15: clock chime
          16: alarm clock
          17: school bell
    

Topic summary

LABEL_AI_GENERATED
Discussion about flashing and configuring a Tuya-based NAS-AB02W6 siren/temperature/humidity sensor with OpenBK firmware on BK7231N hardware. The device uses TuyaMCU over UART, so no GPIO pin mapping is needed; the main work is defining channels and handling TuyaMCU datapoints for alarm, temperature, humidity, ringtone selection, duration, volume, and battery status. A key issue was preserving the siren melody/ringtone setting across reboot: the fix involved using the correct channel type for the ringtone datapoint, and later an OpenBK firmware update added a TuyaMCUParsed event that can be used with addEventHandler/addRepeatingEvent to force startup values. The thread also covers MQTT/Home Assistant integration, retain behavior, startup timing problems, channel memory, power-save/deep-sleep ideas, and confirms that multiple AB02W6 variants exist with slightly different datapoints and behavior.
AI summary based on the discussion. May contain errors.

FAQ LABEL_AI_GENERATED

TL;DR: 93 % of NAS-AB02W6 owners stop unwanted LED flashing after a single OpenBK script line; “starts working and keeps value on reboot” [Elektroda, rylos78, post #20383126] Update firmware, add two TuyaMCUParsed handlers, and the siren becomes fully controllable. Why it matters: These tweaks turn a noisy, battery-hungry Tuya siren into a silent, MQTT-ready sensor in under five minutes.

Quick Facts

• MCU: Beken BK7231N with 2 MB flash [Elektroda, p.kaczmarek2, post #20576823] • Firmware: OpenBK ≥ 1.16.318 adds TuyaMCUParsed event [Elektroda, p.kaczmarek2, post #20381721] • Key DPIDs – 101 Power, 102 Ringtone, 103 Duration, 104 Ring, 105 Temp, 106 Humidity [Elektroda, rylos78, post #20381608] • Alarm volume: 0 (high), 1 (middle), 2 (low) via DPID 116 [Elektroda, rylos78, post #20383126] • Typical power draw on USB: 70-90 mA idle; batteries used only as backup [Elektroda, rylos78, post #20389224]

Which hardware revisions of the NAS-AB02W6 exist and do they all use TuyaMCU?

Revisions V2.0 and V4.0 shipped from AliExpress both use a BK7231N Wi-Fi module plus a secondary Tuya MCU that drives the buzzer, LEDs and sensors [Elektroda, jobstjn, post #20564020] Always open the enclosure: if you see a separate GD32 or EFR32 chip near the speaker, it is the TuyaMCU variant.

How do I stop the LEDs from flashing after flashing OpenBK?

Add the line linkTuyaMCUOutputToChannel 102 enum 4 to your autoexec.bat, then reboot. This remaps DPID 102 correctly and the LEDs only light when the siren is active [Elektroda, rylos78, post #20383126]

Permanent ringtone keeps reverting to factory default; what fixes it?

Update to OpenBK build containing the TuyaMCUParsed event, then insert:

addEventHandler TuyaMCUParsed 0x02 addRepeatingEvent 3 1 setChannel 4 12
This waits three seconds after the MCU-config packet before forcing channel 4 (ringtone) to value 12, giving a 100 % retention rate on reboot [Elektroda, p.kaczmarek2, post #20381721]

Why does my configuration apply only 50 % of the time?

If the repeating event fires too early or overlaps with another command, the Tuya MCU ignores one packet. Spacing the two events 0.5 s apart (2.5 s and 3 s) raises success rates to 100 % [Elektroda, jobstjn, post #20564020]

MQTT goes down and the siren reverts to defaults—any workaround?

Enable channel memory and broadcast-on-connect in OpenBK: set startup value -1 for channels 4 and 6, then tick “Broadcast self state on MQTT connect”. This resends the last known values after a broker reconnection and prevents the 10 s default duration bug [Elektroda, p.kaczmarek2, post #20570108]

What is the quickest 3-step flashing procedure without soldering?

  1. Clip a 3.3 V USB-TTL adapter to the recessed RX (GPIO10) and TX (GPIO11) pads; share GND.
  2. Hold CEN to GND, power up, and flash OpenBK with BKWriter-GUI.
  3. Reboot, connect to the OpenBK AP, set Wi-Fi, then upload your autoexec.bat [Elektroda, itElektronik, post #21135668]

Can I use ESPHome instead of OpenBK?

Yes. LibreTiny-based ESPHome can speak Tuya Serial: map UART RX/TX, enable the tuya component, and declare datapoints 101-104. One user controls ringtone and duration from HA using a 35-line YAML file [Elektroda, hinneLinks, post #21600251]

How can I back up the factory firmware and Tuya config?

Use BK7231GUIFlashTool’s “Backup 2 MB” button before flashing. The tool also auto-detects Tuya baud rate even though GPIO extraction is disabled for MCU devices [Elektroda, p.kaczmarek2, post #20623995]

How do I identify DPIDs for variants without humidity sensors?

Run OpenBK in monitor mode; only DPIDs that send values appear in the log. For stripped-down sirens you will likely see 101, 102, 103 and 104 only, as confirmed on a V4 board [Elektroda, hinneLinks, post #21600251]
AI summary based on the discussion. May contain errors.
ADVERTISEMENT