logo elektroda
logo elektroda
X
logo elektroda

Preventing DeepSleep with button press on TH08 (BK7231N) for autoexec.bat Updates

tahunasky 54 0
ADVERTISEMENT
  • #1 21826680
    tahunasky
    Level 2  
    I have a TH08 / 1? WiFi sensor https://openbekeniot.github.io/webapp/devices/Tuya_TH08.html. I have got it working; however, I want to be able to stop it from going into DeepSleep so I can update autoexec.bat or whatever - pressing the button stops autoexec from starting the DeepSleep command.

    Firmware version: Built on Jan 27, 2026 23:02:13, version 1.18.250

    Config
    
    {
      "vendor": "Tuya",
      "bDetailed": "0",
      "name": "Full Device Name Here",
      "model": "enter short model name here",
      "chip": "BK7231N",
      "board": "CBU",
      "flags": "0",
      "keywords": [
        "TODO",
        "TODO",
        "TODO"
      ],
      "pins": {
        "7": "dInput;5;0",
        "8": "BAT_Relay;3;0",
        "14": "Btn;4;0",
        "16": "WifiLED_n;0;0",
        "20": "CHT83XX_SCK;0;0",
        "22": "CHT83XX_SDA;0;1",
        "23": "BAT_ADC;2"
      },
      "command": "backlog PowerSave 1; startDriver battery; addEventHandler OnHold 14 stopAllscripts; startDriver CHT83XX; CHT_Calibrate 0 6",
      "image": "https://obrazki.elektroda.pl/YOUR_IMAGE.jpg",
      "wiki": "https://www.elektroda.com/rtvforum/topic_YOUR_TOPIC.html"
    }
    


    autoexec.bat
    
    CHT_Calibrate 0 6
    setChannelType 0 Temperature_div10
    setChannelType 1 Humidity
    waitFor MQTTState 1
    delay_s 1
    publish temp-humdity/device_1 "{"temp":$CH0,"humdity":$CH1,"bat_voltage":$batteryVoltage,"bat_percent":$batteryLevel}" 1
    delay_s 30
    DeepSleep 180
    


    The button is attached to P14 on the WiFi module.
    If I add "addEventHandler OnHold 14 stopAllscripts" to configuration, it doesn't execute autoexec.bat.
    If I put "addEventHandler OnHold 14 stopAllscripts" at the beginning of autoexec.bat, it doesn't work.

    The log shows it is registering the button press, but doesn't stop autoexec from running.
    
    Info:SENSOR:DRV_CHT83XX_ReadEnv: Temperature:32.968750C Humidity:72.519165%
    Info:MAIN:Time 454, idle 63163/s, free 71656, MQTT 1(1), bWifi 1, secondsWithNoPing 383, socks 2/38 POWERSAVE
    Info:GEN:14 Button_OnLongPressHold
    Info:EVENT:EventHandlers_FireEvent: executing command stopAllscripts
    Info:GEN:14 Button_OnLongPressHold
    Info:EVENT:EventHandlers_FireEvent: executing command stopAllscripts
    Info:GEN:No change in channel 0 (still set to 329) - ignoring
    Info:GEN:No change in channel 1 (still set to 72) - ignoring
    


    At the moment, I have delay_s 30 in autoexec.bat to give me time to do updates, etc.

    How can I get this to work, or is there something else I can do to stop the device from going into DeepSleep until I reboot?

    Thanks
    AI: Just to clarify, when you press and hold the button on P14, do you want the device to completely skip entering DeepSleep for that cycle, or should it stay awake until you manually trigger DeepSleep again?
    stay awake until I reboot
    AI: After the stopAllscripts command is executed (as shown in your logs), does the device still go into DeepSleep, or does something else happen? Are there any error messages or unexpected behaviors in the logs after this point?
    No, it does not run autoexec.bat, so it doesn't go into DeepSleep
  • ADVERTISEMENT
ADVERTISEMENT