FAQ
TL;DR: After 1 PR merged, OpenBeken’s addClockEvent supports robust, computed scheduling; "I've merged your PR," noted maintainer p.kaczmarek2. For OBK scripters asking how to schedule variable times, use TimerSeconds or multi-variable expansion. [Elektroda, p.kaczmarek2, post #20935893]
Why it matters: It lets you automate lights and scenes at precise, changing times without brittle math or broken handlers.
Quick Facts
- Time can be a single integer (TimerSeconds from midnight); e.g., setChannel 10 $sunset+1800 then addClockEvent $CH10. [Elektroda, ilengyel, post #20924564]
- Only the first three addClockEvent arguments expand; the handler body stays literal, so $CH10 won’t resolve early. [Elektroda, ilengyel, post #20924564]
- Multi-expand token support enables $hour:$minute inputs; tokenizer and clock-event self-tests were added. [Elektroda, ilengyel, post #20932902]
- Expanding all variables can expand handler commands too; selective expansion is required to avoid breaking scripts. [Elektroda, p.kaczmarek2, post #20923004]
- Modulo operator and braces are planned for the expression engine to simplify time math. [Elektroda, p.kaczmarek2, post #20931598]
What changed in addClockEvent after the recent merge?
A pull request was merged to improve clock operations and argument expansion. The maintainer requested a tutorial to guide users, signaling mainline availability. Check the tutorial and examples to adopt the updated usage patterns. [Elektroda, p.kaczmarek2, post #20935893]
How do I schedule a dynamic time using seconds from midnight?
Use the TimerSeconds approach.
- Compute seconds: setChannel 10 $sunset+1800.
- Schedule: addClockEvent $CH10 0xff 5 echo Light ON at $CH10.
- Verify: listClockEvents shows the scheduled time and literal handler.
This avoids overflow math and keeps your handler intact. [Elektroda, ilengyel, post #20924564]
What’s the difference between sunset and $sunset in addClockEvent?
Using sunset recalculates daily, tracking the correct astronomical time. Using $sunset expands once at scheduling, so it triggers at the same fixed clock time each day. Choose sunset for drifting daylight, $sunset for a fixed daily time. [Elektroda, ilengyel, post #20920436]
Can I pass $hour:$minute directly to addClockEvent?
Yes, with multi-expand token support you can pass both hour and minute in one go. Example: addClockEvent $hour:$minute 0xff 4 echo timeExpanded. Self-tests were added to validate multi-expansion behavior in tokenizer and clock events. [Elektroda, ilengyel, post #20932902]
Will variables inside the handler expand when I schedule the event?
No. Only the first three addClockEvent arguments expand. The handler body stays literal, so references like $CH10 remain unchanged at schedule time, preventing unintended substitutions. [Elektroda, ilengyel, post #20924564]
Which approach is more flexible—variable expansion or TimerSeconds?
Both are useful. TimerSeconds simplifies math and comparisons. Token-based hour:minute expansion allows finer control of fields. As the maintainer put it, "Idea 2 is simpler, but not as much as flexible as idea 1, when done correctly." [Elektroda, p.kaczmarek2, post #20923004]
What options were proposed for variable time calculations?
Two options were proposed: 1) tokenizer-based multi-expand to allow $hour:$minute; 2) accept a single integer time representing seconds since midnight (TimerSeconds). The author preferred option 2 for easier comparisons and arithmetic. [Elektroda, ilengyel, post #20920436]
How do I avoid minute overflow without a modulo operator?
Skip manual H:M math and use a single seconds value. Without mod, expressions like ($minute+45)%60 are awkward. TimerSeconds avoids overflow edge cases and makes comparisons simpler. Compute once, then schedule with addClockEvent $CHn. [Elektroda, ilengyel, post #20920436]
Is modulo and parentheses support coming to OpenBeken expressions?
Yes. The maintainer stated they want module operator and braces support and planned to look into it. This will simplify time arithmetic and precedence control in scripts. [Elektroda, p.kaczmarek2, post #20931598]
Are numeric expressions floats in OpenBeken?
Yes, contributors observed numeric values are floats. For modulo on floats, fmodf semantics apply. This helps frame how a future mod operator could behave in expressions. [Elektroda, ilengyel, post #20932902]
How can I test tokenizer and clock-event changes safely?
Use the Simulator and add self-tests before changing the tokenizer. Submit tests for review to catch regressions, then iterate on improvements without breaking compatibility. This workflow was encouraged by the maintainer. [Elektroda, p.kaczmarek2, post #20931598]
Could enabling “expand all variables” break my scripts?
Yes. Expanding all variables would also expand variables in the handler command at schedule time. That can alter behavior and break existing scripts unless expansion is selective. [Elektroda, p.kaczmarek2, post #20923004]
Do you have a real-world example I can copy?
Yes. A porch-light automation uses NTP, sunrise/sunset offsets, and staged dimming. It schedules sunset+30 minutes, then night-time low and off windows, with a manual timer trigger. Adapt it to your channels and location. [Elektroda, ilengyel, post #20936417]
Where can I find the step-by-step tutorial?
The author published a tutorial in the project’s Tutorials section. It includes examples and screenshots to help new users apply the features quickly. [Elektroda, ilengyel, post #20942300]