Better logic calculate time

hi all,

for a very long time i would like to calculatie time.
In a variable (String) i have: 09:30
i would like to substract 75 minutes from it or add hours (whatever).

How can i do that?

I cannot find any solutions for it, not on github and not on here. Please help!

What was said here: Time calculations in Better logic

i dont understand at all.

Hi Edgar,

Where does the 9:30 come from? What are the +/- 75 minutes needed for?

Please give an example, maybe I can help you then.

1 Like

thnx for your reply and that you wanne look into it.

the time can excist on multiple reasons. But in this case it is the time when i have to start to work tomorrow. To determine this i use iCalandar to Voice app.

But there is no option for to determine when you are done working. The app doesn’t support endtime of appointment. But i work full time so i can add 8,30 hours and then i know when i am free.
Also, when i have to work at 9.30 then my alarmclock have to go off 75 minutes earlier.

My alarmclock works allready fully but i want to have more :slight_smile:

I think there are several possibilities:

  • create a separate appointment in the linked calendar (iCalandar) for the start and the end of working time
  • use the Chronograph App (or similar) to create a timer/countdown over 8 hours and 30 minutes. Start the timer/countdown at the start of work. After the timer/countdown (8 hours 30 minutes) has expired, an action can be performed (e.g. start another flow)

A few more questions about your alarm clock or wake-up time. Which two alarm times do you need exactly? Which time? How did you enter the different working hours in the calendar? 09:30 - 18:00 and 10:45 - 19:15?

Thnx! But that is not what i want, i want to know when i am done working (when i will be free).
f.e. i want to know today, when i will be free tomorrow… as long as iCalendar 2 voice doesnt have the option to read the endtime, i only can assume it is 8,5 ours later, but i cannot add this to start time.

I’m on the road at the moment and can’t try much. I will test something later and get back to you.
I may have to sleep on it for a night as well. :wink:

1 Like

If not done yet, you can also have a look at the official post of the “iCalendar to Voice” app, maybe there are some ideas to solve your problem.

i asked several times, even on github, but no response. app seems to be dead sadly.

thanks you like to check out things. i hope it is possible. like the link i posted before here, it should be possible. but i dont understand what is says. maybe you do?

Performing calculations and writing the calculated value to a variable is not the big problem.
To do calculations with a time is not possible in my opinion, at least I don’t know how. In my opinion, only calculations with natural numbers and decimal numbers are possible. Therefore I try to find another way like you imagined it.
So if you could just write down the flow as it should look like in theory so that I understand your requirement better.

It is actualy very simple:

if iCalendar to voice appointmen is in 12 hours
and appoitment (tag=afspraak) = work
then: workstarttime = afspraak (lets say it is 08:00)
write notification: your alarmclock is set to 06:45 (- 75 minutes)
write variable: workendtime = entime

if this works, then i bet i can create others, like adding minutes or hours myself.

Sorry, I guess I can’t help you.
I can’t get the iCalender app to read “Work” (name of the appointment) from the calendar. It always shows only “Test”. Do you?
And to calculate the time does not work (in my opinion). Are you able to fill a variable with a time? If so, then probably only a text variable and no numeric variable with which you can make calculations, right?
Is it possible to fill one variable with the hours and another variable with the minutes? Then you could calculate the time at least in minutes or in hours (with decimal). I’m not sure if this could help.

I did my best, but unfortunately it was not enough… :man_shrugging:t4:

What i had sometime ago before Homey crashed and lost all flows was a variable time for running flows. You cannot use time in a variable( tried everything)but you can use numbers. In the countdown app you can use a variable with numbers. In that case numbers represent seconds. For my case i needed to know how long a flow ran until it ended. When the flow started a timer started; for instance 1000 sec. When the flow ended, the remaining seconds were put into a variable. Then a new flow calculated the time the flow ran. This number was set into a variable. This number i used for a timer that started with that number as second(as a tag). I also added some seconds for security reasons. Maybe this is something which can help you with your puzzle.

too bad… however it is strange if it can’t be done.
Thank you for trying @DirkG

but yes, when you test icalendar 2voice, you can edit the word test, but you can also test with the word test off course. It is for sure not possible with icalendar.
but maybe (or as i read in the link in my OP) it should be possible with Better Logic but i don’t know how.

@Marcel_Ubels no, that doesn’t work for me. i just have a variable: 08:00 and i wanne subtract 75 minutes from it, so my alarmclock should go off at 06:45

Same issue here, still no solution?

I want my car to start charging X minutes (device (car) > charging time left) before a set time (the time I want to leave)

Maybe you can calculate it with HomeyScript, like in:

Or the app: Flow Utilities?