Hi @philipp.ossler,
I realise this a slightly dated topic but I thought i’d share my recent findings with you and I have a hunch we can probably solve this without creating an issue so please bear with me.
I broke down the components of the expression to see the outputs of the variables in the expression i.e.
date,duration etc. Here is what I observed in instances where the event is fired twice,
For an expression set as follows,
= { time: time("11:05:00@Etc/UTC"),
date: if (time(now()) < time) then today() else today() + duration("P1D"),
theDuration: date and time(date, time) - now(),
cycleWithDuration: cycle(theDuration)
}.cycleWithDuration
Here is the output for the first event that was fired,
time(now()) = 11:04:59.945@Etc/UTC**
today() = 2021-06-11
date = 2021-06-11
theDuration = R/PT0.055S**
cycle(theDuration) = PT0.055S
Please note the duration PT0.055S, which i beleive might explain why a second event firing at almost the same time.
For the same time i.e. time(“11:05:00@Etc/UTC”), the second event that was fired has the following output,
time(now()) = 11:05:00.15@Etc/UTC
today() = 2021-06-11
date = 2021-06-12
theDuration = R/PT23H59M59.85S
cycle(theDuration) = PT23H59M59.85S
Now my thinking is if we could enhance the expression so that it will exclude all durations that do not have an hour included. A somewhat simplified solution, but maybe you have a better idea. Here is my attempt to enhance the expression,
= { time: time("11:05:00@Etc/UTC"),
date: if (time(now()) < time) then today() else today() + duration("P1D"),
theDuration: date and time(date, time) - now(),
cycleWithDuration: if (is defined(duration(string(theDuration)).hours)) then cycle(theDuration) else cycle(date and time(today() + duration("P1D")))
}.cycleWithDuration
So in cycleWithDuration I am trying to add a condition so that if the duration does not have an hour component, a day should be added to the duration. I am not so good with FEEL expressions but I was hoping you would get where my thinking is with this and tell me how i could implement the condition on the expression.
Thank you