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.

Is it possible to create a flow that will trigger 30 minutes before sunset?

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

  • PeaoPeao Member
    You could create a flow with trigger sunset and set a delay of 23h 30m to the action. 
  • I think by delaying the action of a sunset trigger with 23 and a half hour or something like that
  • Peao said:
    You could create a flow with trigger sunset and set a delay of 23h 30m to the action. 

    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. 
  • There is a way of doing this using the BetterLogic app and it's mathjs stuff and the $timenow variable. See for example: https://forum.athom.com/discussion/comment/15118/#Comment_15118

    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.
  • Delaying 23.30 hours could indeed be the solution to solve this temporary. Thanks for the idea! It would be great if we could use parameters like sunset in logic calculations that can operate as a trigger.

  • Use a lux sensor.... 
  • Erwin75 said:
    Use a lux sensor.... 
    Thanks for the answer, but... that was not the question  :)
  • I've done something similar in my flows (start increase of LIFX light intensity from 1hr before sunset) by playing around with:

    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.
  • WathLamersWathLamers Member
    edited August 2016
    sorry for the dutch;
    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?
  • sorry for the dutch;
    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?
    If the sunset core functionality does feature an api of somesort it could be possible by creating app. But good look finding out if it is available to other apps.
  • @WathLamers @jjtbsomhorst I find it easiest to save the sunset time from the previous day in a variable. This variable survives reboots, and sunset time never changes significantly in a day.
  • JPeJPe Member
    edited August 2016
    It will significantly change 2 times a year, if you are using DST !!

  • Hi all.

    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?
  • Isn't there a Issue/feature request on Github?

    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. 
  • Yes, would be awesome feature to get back ;)
  • Or just adding cards with begin and end of the civil twilight. 
  • For calculation you can used the best UTC time. Then for presentation local time.
    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.

Sign In or Register to comment.