This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
Is it possible to create a flow that will trigger 30 minutes before sunset?
nteuniss
Member
In our house I would like to turn on some lights 30 minutes before sunset. Any thoughts how this can be accomplished by creating a flow?
Comments
Could be a solution, but flow doesn't survive a reboot/crash.... So if homey crashes or for some reason reboots, the lights won't go on.
Not the most elegant solution but it works for now and survives a reboot. Athom has plans to implement this functionality into the core but it's probably way down the backlog.
1. Setting a sunset time variable each day: WHEN sunset starts, THEN set var_sunset to $timenow.
2. Every minute/second/whatever, update a var_currenttime value: WHEN time-update, THEN: set var_currenttime to $timenow
3. Check with a third flow (or incorporate it in the second) if it's within the timeframe you want. Use the modulo function to change var_currenttime and var_sunset (which is milliseconds from epoch) to minutes from midnight and compare.
Tip: First try it out in excel or something to see what you need to do with the numbers. You also have to take timezone into account.
als je nu aan homey vraagt; hoelaat gaat de zon onder ? krijg je het antwoord.
Dat betekent dat homey weet hoelaat de zon onder gaat.
Is er een mogelijkheid deze variabele uit te lezen, of moet dit vanuit Athom gebeuren?
google translate;
Now if you ask homey; what time the sun goes down? you will get the answer. That means homey know what time the sun goes down. Is it possible to read this variable, whether this should be done from athom?
Just had a thought.. Via http://sunrise-sunset.org/api it should be possible to let homey lookup the sunset time. Based on that time you can calculate what time the flow should act (for example Sunset -30). For a developer it should be possible to create an app for this?
for example, every night at 04.00 (four oçlock in the night because of the DST), it can lookup the sunset of the day and set the time the flow should act. Someone who is in for a challenge?
In one of the earliest FW releases there where (if i'm right) cards like "X time before sunset", "X time before sunrise", etc. This was removed on the road to fix the time cards and its still surprises me that these cards are not back after X FW releases.
The sun data is available within Homey, so it should be a piece of a cake to make these cards.
Would be great if Athom just gives us these cards back.
Finding start and end summertime is also easier. For Europa: 01:00 UTC on the both switching dates.
Next is working with the juliandate very helpful to add or subtract days from a date.
Even with time, all is that a tiny part of the juliandate. 1 h = 1/24 or 0,04166666666666666666666666666667
The juliandate for 17 August 2016 12h UTC = 2457618.
Because I read here something about NPM this link https://www.npmjs.com/package/julian-date.