Calculating Time before Sunrise.

I have an interesting problem that requires solving for WAF.

Presently, I have Kitchen blinds that retract (go Up) at Sunrise using the DAY/NIGHT Trigger in PLEG.
WAF requires them to Open 15 min’s or so before (in reality the time period changes as Twilight alters through the year).
I thought this would be easy, however there is no Advance in Actions only Delay, not to be the undeterred, I looked at the Day/Night trigger, also there is no Advance and no way of performing a Time calculation that I can see.
Next was the Heliotrope, again I could find no setting for Sun below the horizon before Sunrise that would equate to the start of Civil Morning Twilight.
The thought occurred that I could use !Day as the trigger with an Action for !Day and using a Delay might be a solution however it doesn’t sound logical and might take several days to test. I need a solution earlier.

The Heliotrope would be ideal as the Twilight period alters through the year but can it be done in PLEG?

I use PLEG to offset from sunrise or sunset using a schedule. Attached is my example.

Thanks, I’ll keep it mind but I’m looking for a Twilight solution, not fixed period.

I ran across your thread, and this seemed like something one of my plugins can almost do, and I’m willing to spice it up to take it the last mile.

SiteSensor will query a remote API and parse the JSON response. As it turns out, there’s a free API for getting sunset/sunrise and civil/nautical twilight start/end for any lat/long. Here: https://sunrise-sunset.org/

This is the API call for my home town: https://api.sunrise-sunset.org/json?lat=33.3969&lng=-84.5963&date=today&formatted=0

I’ve put this into a SiteSensor configuration, and I can get the twilight start and end times fetched and stored as strings. The only thing missing that you need is parsing the time string to an actual timestamp so it can be compared to current time. The API returns ISO 8601, which is easy. I’m working on adding a simple time parser to SiteSensor right now, and once that’s working, that would be all you need to have SiteSensor go to triggered state from twilight start to end. And you could supply offsets as needed as well.

Sounds like it might become a replacement for the Day/Night PI if it comes together.
Looking forward to trying it out.

PLEG lets you use a + or - time period relative to Sunrise or Sunset, and it changes throughout the year. I used it for my pool pump control which I wrote a blog article about which outlines the PLEG logic.

[url=https://www.livehouseautomation.com.au/blogs/news/save-money-running-your-pool-with-home-automation]https://www.livehouseautomation.com.au/blogs/news/save-money-running-your-pool-with-home-automation[/url]

You could see the total run times changing on a day to day basis as the sunrise/sunset times shifted.

This capability is built in to Vera already, both in scenes and Luup calls. Certainly no need to go to an external site to do this, PLEG or no PLEG.

Timers documented here…

http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#function:_call_timer

I once messed around with this kind of thing but I used a virtual switch instead of PLEG. There’s a trigger in the Heliotrope plugin that fires when the sun’s altitude goes over a certain value. For civil twilight you want -6 degrees. I made the trigger run a scene that turned on a virtual switch. With PLEG you might be able to watch the Altitude variable directly.

In the higher latitudes (North and South) using Heliotrope to determine a useful morning or evening transition is much more appropriate than some fixed time offset (using the day/night plugin or luup.call_timer) from actual sunrise/sunset.

PLEG can be used to monitor the Heliotrope trigger or the sun angle value directly to be used in logic of your choosing …

I once messed around with this kind of thing but I used a virtual switch instead of PLEG. There’s a trigger in the Heliotrope plugin that fires when the sun’s altitude goes over a certain value. For civil twilight you want -6 degrees. I made the trigger run a scene that turned on a virtual switch. With PLEG you might be able to watch the Altitude variable directly.[/quote]

I’ve gone hunting for this trigger but can’t find it in the version I have.
what/where am I missing?

edit: I think I found it what I was looking for, just need 24 hours to test.