sun- and time-based triggers

http://automagucally.weebly.com

Moderators: davka003, Telldus

Post Reply
louie
Posts: 14
Joined: Fri Mar 17, 2023 9:45 am

sun- and time-based triggers

Post by louie »

I have a setup with light going in the early morning, and the turn off when the sun rises. This isn't a problem the dark half of the year, but soon the sun will rise before "early morning". Have anyone a nice solution for this?

Something like "at 05 as long as the sun hasn't risen" etc :)
KHolm
Posts: 163
Joined: Fri Mar 17, 2023 9:45 am

Re: sun- and time-based triggers

Post by KHolm »

+1
krambriw
Posts: 654
Joined: Fri Mar 17, 2023 9:45 am

Re: sun- and time-based triggers

Post by krambriw »

This topic is not so simple (even if one might think so at first thought).

Check this thread about the SunTracker plugin I made for EventGhost once upon a time. It is written in python so the code could be *borrowed* if python is good for the automagically

http://www.eventghost.net/forum/viewtopic.php?f=9&t=982
KHolm
Posts: 163
Joined: Fri Mar 17, 2023 9:45 am

Re: sun- and time-based triggers

Post by KHolm »

Hi,
I think this can be solved directly in Automagally, not as extensive as the SunTracker though.

Wanted Scenario:
- Turn ON at 5am, unless sun is up
- Turn OFF when sun raises

1. Create a new Global Variable named sunIsDown, type Boolean.

2. Create a Send Signal Device
Name: SendSunIsUpSignal
Signal to send at ON/Activate: sunIsNowUp

3. Create a Send Signal Device
Name: SendSunIsDownSignal
Signal to send at ON/Activate: sunIsNowDown

4. Create a Store Global Variable signal handler
Description: SetSunDownFalse
Pattern to match: sunIsNowUp
Variable to update: sunIsDown
Store this constant instead of parsed variable: False

5. Create a Store Global Variable signal handler
Description: SetSunDownTrue
Pattern to match: sunIsNowDown
Variable to update: sunIsDown
Store this constant instead of parsed variable: True

6. Create a Scheduled event:
Device: SendSunIsUpSignal
Command: Activate
RelativeTo: sunrise
Minutes relative to sunset/sunrise: -1 (one minute before to avoid race with OFF signal)
Do the following weekdays: Mon-Sun

7. Create a scheduled event:
Device: SendSunIsDownSignal
Command: Activate
RelativeTo: sunset
Minutes relative to sunset/sunrise: 0
Do the following weekdays: Mon-Sun

8. Create a scheduled event that executes only if sun is down
Device: WHATEVERYOURLAMPIDIS
Command: On
RelativeTo: AbsoluteTime
Execution time: 05:00:00
Condition: sunIsDown
Do the following weekdays: Mon-Sun

9. Create a scheduled event that always executes (No need for conditional off)
Device: WHATEVERYOURLAMPIDIS
Command: Off
RelativeTo: sunrise
Minutes relative to sunset/sunrise: 0
Do the following weekdays: Mon-Sun

There is a glitch in the above. Tell me if you can find it :-)

The same approach can be used for dawn, a bit different though. You'll figure it out.

/Marcus
krambriw
Posts: 654
Joined: Fri Mar 17, 2023 9:45 am

Re: sun- and time-based triggers

Post by krambriw »

Well, maybe not in your specified scenario, but you are not handling a whole day cycle (starting from midnight ending next midnight).

Here are examples of *glitches* I can't see that you are handling

- turning ON in the evening at sunset and OFF either later the same day or even more complicated, the NEXT night, like 02.00
- synchronization, if you restart at any time, correct statuses should be sent out to devices to set them in the correct state according to schedules and sun status
- individual settings for different day types (my experience is that you sooner or later will need individual settings for Mon-Sun, Vacation and Empty House modes)

BestR, Walter
davka003
Posts: 187
Joined: Fri Mar 17, 2023 9:45 am
Location: Sweden
Contact:

Re: sun- and time-based triggers

Post by davka003 »

This is actually quite hard to solve with all conditions.

Just dont forget the following cases, as they applies to me and I won't let anything into the main that is not working :-)

There are places and times of the year where sunset is after midnight.
There are places and times when next sunset is not within 24 hours.
There are places and times when next dawn is not within 24 hours.

Make sure time corrections with high values also works (minutes relative to sunset).

I know these sunset/relative times/daylight savings time can make you crazy!

But my suggestion would be like kHolm.
My home automation software: Automagically @ Raspberry Pi http://automagically.weebly.com
krambriw
Posts: 654
Joined: Fri Mar 17, 2023 9:45 am

Re: sun- and time-based triggers

Post by krambriw »

Yes, I was just mentioning ... (and all that what you listed so far is actually covered in my SunTracker plugin for EG)

And it takes lot of time to code/test, after almost six years, still pushing it forward to get everything working properly...and with new wishes coming from community,,,it never stops

Code: Select all

##############################################################################
# Revision history:
#
# 2014-02-24  Added new day type, 'empty house', and new empty house mode
# 2013-12-27  Fixed a bug in function for setting vacation mode. Vacation mode
#             set from external signal is now also saved persistent.
#             Synchronization is now deactived during vacation mode
.
.
.
.
# 2008-04-28  Still stumbling, had to add better string control(StrCheck)
# 2008-04-25  A "little" Bug fix
# 2008-04-22  First version published
##############################################################################

davka003
Posts: 187
Joined: Fri Mar 17, 2023 9:45 am
Location: Sweden
Contact:

Re: sun- and time-based triggers

Post by davka003 »

Automagically support it to but it hasnt yet stans the test of time for more than 1 year.

The reason listing the cases was to make sure noone rushes to make fixed without thinking.
My home automation software: Automagically @ Raspberry Pi http://automagically.weebly.com
jneander
Posts: 32
Joined: Fri Mar 17, 2023 9:45 am

Re: sun- and time-based triggers

Post by jneander »

krambriw wrote:This topic is not so simple (even if one might think so at first thought).

Check this thread about the SunTracker plugin I made for EventGhost once upon a time. It is written in python so the code could be *borrowed* if python is good for the automagically

http://www.eventghost.net/forum/viewtopic.php?f=9&t=982
Walter is there anyone porting this to automagically? If not, can I give it a go and use your code to port this to automagically?
krambriw
Posts: 654
Joined: Fri Mar 17, 2023 9:45 am

Re: sun- and time-based triggers

Post by krambriw »

Sure you can (visst, inga problem)

mvh Walter
Post Reply