I would like to create a clock event based on a calculated variable, but finding it might not be possible with the current code. I see the default tokenizer settings only allow single complete constant expansions. For example,
addClockEvent 22:34 $ch13 1 echo daysExpanded
addClockEvent $ch14:$ch15 0xff 2 echo timeExpanded
addClockEvent $ch14 0xff 3 echo timeExpanded
are not okay.
I see 2 options:
1. Enable TOKENIZER_ALTERNATE_EXPAND_AT_START flag for the add clock event's string tokenizer. This would allow a script like
setChannel 14 $hour+1
setChannel 15 $minute+45 // does not handle minute overflow
addClockEvent $ch14:$ch15 0xff 4 echo timeExpanded
2. Allow a single integer value for the time parameter that would represent a TimerSeconds type from midnight. This would allow a script like:
setChannel 10 $sunset+1800
addClockEvent $ch10 0xff 5 echo timeExpanded
Personally, my preference is the second option since the time calculations and comparisons are a lot easier when they are a single integer, but I understand there will be a few quirks in the second option:
addClockEvent 7 0xff 6 echo Triggered7SecondsAfterMidnight
addClockEvent 7:00 0xff 7 echo Triggered7am
addClockEvent 7:00:00 0xff 8 echo AlsoTriggered7am
addClockEvent sunset 0xff 9 echo TriggeredCorrectSunsetEveryDay
addClockEvent $sunset 0xff 10 echo TriggeredAtTheSameTimeEveryDay
I can be convinced for the first option if there is an easy way to extract hours and minutes from a TimerSeconds type. I am not seeing a way currently since evaluate expression treats everything as a float and there is no MOD operator, which I suspect is also due to only float.