Homey Community Forum

Time calculations in Better logic

app
#1

I’m trying to use the app Better logic to calculate the time between two events in Sun events.
Is there anyone who know how to calculate the time difference and present it in minutes?

#2

You could make a calculation with the Sun events as variable, but you’ll need to find a way to remove the colon between the numbers. I don’t know if this is possible in a flow or that you may have to script it manually…

#3

Use the timenow with a MathJS card and covert the epoch time to mins.

use 2 flows with the

execute mathJS card

with $timenow$ to a betterlogic variable for SunEvent1 & SunEvent2.
Then to calculate the difference rounded to the nearest minutes

round(($SunEvent2$ - $SunEvent1$)/60)

#4

Thank you, that helped.

My goal was to calculate the time for the so called “golden hour” (app sun events) in the morning and the evening. That time I use to dim som lights to keep them in a comfort level during sun transition from eg bright to dark.

To do that, I use the function “change brightness over time” in Fibaro dimmer 2.
When I calculated the time for the sun transition from the day before (close enough).
Then in the evening (at Evening golden hour starts) I turn the lights ON to dim level 100%.
Then start “change brightness over time” with the time calculated from the MathJS function, and dim the brightness down to 15% (in my case). This creates a perfect brightness of the light from when it’s bright outside, until it’s dark.

Thanks again for the help.