Calculating time diffence between 2 events in homey script

Hey guys,

I am trying to calculate the daily time difference to determine the rate of light dimming between sunset and dusk.

I have tried a couple of option but all of them seems to have a limitation.

Here are the options I tried and why they failed.

-To calculate the time difference I tried to save the store the time in a variable in better logic app. The problem here is that the time stored in the variable are only the two digits of de 24 hour format.

  • I Tried using mathjs in betterlogic by subtracting “dusk-sunset” but I get weird value as output.

So to sum up I calculate time difference because I cant store the data in flow nor script. And I cant mathematically calculate the difference .

Any tips?

my tip is search this forum for (time) calculation

you could make a Homescript and send two parameters, time1 & time2
convert them to timestamps, substract them, and than you could convert that back to time. or… use my script i posted recently, in Dutch:

var dateParts = '17-09-2013 10:08'.match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/);

console.log(dateParts); // ["17-09-2013 10:08", "17", "09", "2013", "10", "08"]

source: jquery - Converting a datetime string to timestamp in Javascript - Stack Overflow

1 Like

Check the Flow Utilities app

Example [APP][Pro] Flow Utilities - #6 by martijnpoppen

1 Like

Question for Advanced Flows: Is there an option to temporarily suspend a flow?

It’s a bit Off Topic

But, yes, that can be done the same way as in the OLD flows:
image

image

I meant a one-card solution

The good old disable a flow also works for Advanced Flows!
Even from a simple flow