logo elektroda
logo elektroda
X
logo elektroda

Automating Daylight Savings Adjustments for NTP with Scripting or driver update

randomalias324 5877 62
ADVERTISEMENT
  • #61 21597196
    4N6nerd
    Level 3  
    >>21597185
    OUCH! so sorry! I checked my post with my actual code and it's not '&&' that is missing but ' ' that is missing

    My post says "31-$mday $day<=6" while it should be "31-$mday+$day<=6"

    I'll repair my previous post right away.

    Thanks for the heads-up! "Dankjewel" ;)



    Edit: + signs get removed on initial post. After editting it back it stays. :P
  • ADVERTISEMENT
  • #62 21818755
    lktrdng
    Level 5  
    >>21564898 I also took some from this code and changed to my coding style :P
    I see in github the command to set dst but as up today, using OpenBK7231N_1.18.248.rbl is not available, any way to check since when the commands are available?

    
    // timezones definition for location
    alias winter_time ntp_timeZoneOfs +4
    alias summer_time ntp_timeZoneOfs +5
    
    // Timezone calculations inspired in https://www.elektroda.com/rtvforum/topic4086621-30.html#21564898
    // summer otherwise winter
    
    // April-September: always summer
    alias check-dst-1 if $month>3&&$month<10 then summer_time else check-dst-2
    // March/October non-Sundays in last week OR early October
    alias check-dst-2 if ($month==3&&31-$mday+$day<=6&&$day>0)||($month==10&&31-$mday+$day>6) then summer_time else check-dst-3
    // Sunday edge cases only
    alias check-dst-3 if ($month==3&&31-$mday+$day<=6&&$day==0&&$hour>=2)||($month==10&&31-$mday+$day<=6&&$day==0&&$hour<3) then summer_time else winter_time
    
    //calculate dst at startup
    check-dst-1
    
    //schedule close time
    //close at sunrise 
    addClockEvent $sunrise 0xff 2 auto-close
    
    //Every day at 4:00, re-add the clock event to get the sunset/sunrise updated and check dst
    addClockEvent 4:00 0xff 10 backlog removeClockEvent 2; addClockEvent $sunrise 0xff 2 auto-close check-dst-1
  • #63 21819576
    max4elektroda
    Level 23  
    lktrdng wrote:
    I see in github the command to set dst but as up today, using OpenBK7231N_1.18.248.rbl is not available, any way to check since when the commands are available?


    Though present, DST is disabled for almost all platforms.
    For Beken see here:
    https://github.com/openshwprojects/OpenBK7231T_App/tree/main/src/obk_config.h#L253

    I made a PR with DST for Beken, if you have a git user, you can download the firmwares here:
    https://github.com/openshwprojects/OpenBK7231T_App/actions/runs/21337440082

Topic summary

The discussion centers on automating daylight savings time (DST) adjustments for devices using OpenBeken firmware with NTP time synchronization relayed via TuyaMCU. The default NTP driver lacks built-in DST support, requiring manual offset changes twice yearly. Users explored scripting solutions in autoexec.bat to dynamically adjust the ntp_timeZoneOfs parameter based on date and time conditions, leveraging available logical operators (&&, ||), nested if statements, aliases, and clock events. Examples include scripts for Sydney and CET time zones that calculate DST start and end using weekday and month rules. Advanced users shared custom driver code and pull requests adding DST commands and automatic adjustments with minimal flash overhead. Testing revealed that MQTT connectivity affects device stability, with resets occurring when MQTT is disabled; setting a default WiFi state in TuyaMCU mitigates this. The firmware supports clock events for scheduled actions, and recent updates separate clock functions from NTP for modularity. Various hardware platforms (BL602, LN882H, W600, ESP32 variants, TR6260, RTL87X0C) were tested for NTP and clock event functionality, with XR809 lacking support. Documentation on the scripting language is limited; it supports if statements, aliases, labels, goto, and backlog for multiple commands but lacks general variable support. The community continues to refine DST handling and clock features in OpenBeken firmware to improve usability for time-displaying IoT devices.
Summary generated by the language model.
ADVERTISEMENT