Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I have an event that I want to happen 5 hours after sunset.
#1
I have an event that I want to happen 5 hours after sunset.
The sunset trigger only allowes 60 minutes before or after. What would be the best way to accomplish this? Can I start a timer on sunset for 5 hours and have that start an event? If yes, how?

Thank you
Reply
#2
What does the event actually do? Is it just a single field write, or something more complex? If you just need to do a single field write, you could use a timed field write. Have a triggered event at sunset do a timed field write that is due to happen five hours later.

Another option would be to set up a daily scheduled event to run at a given hour of the day. Have a triggered event that runs at sunset update the scheduled event time for that scheduled event, so that it runs at a slightly different time every day, i.e. update its time to be five hours from the current time when the sunset event is triggered.
Dean Roddey
Explorans limites defectum
Reply
#3
I would want to write a few fields (turn off a few lights).
The second option sounds better. Two questions:
1) Wouldn't it be a scheduled event that runs at sunset not a triggered?
2) How do I have an event update the event time of a different event?

Thank you
Reply
#4
Yeh, scheduled event that runs at sunset.

One of the action targets is for manipulating the event server. Its commands allow you to modify the times of scheduled events from an action. See the docs on the Event Server action target, for the docs on how those commands work.

Go to /Help/Docs/Actions/Big Picture in the browser window. That'll take you to the reference area for actions. One of the subtopics there is the Event Server Target.
Dean Roddey
Explorans limites defectum
Reply
#5
So I see there that there is a SetSchEvTime command. But that appears to be to set it to a set time. Howe would I use that for 5 hours from now.
The only way I can think of (and I am not sure if this is doable even)
Have a different command write a globalvariable which is current time + 5 hours, and then use the SetSchEvTime to set it to that variable.

Thank you
Reply
#6
In the sunset scheduled event, get the current time. Add five hours to it. There's a command to adjust at time. There's also one to get the time as the broken out parts (hours, minutes, secs.) You can use those parts to build up the required time value string to set the scheduled event. Since the time parts will reflect five hours after the current time, that will make it run five hours later that night.

I need to go to sleep. I can elaborate more tomorrow if you haven't found those things.
Dean Roddey
Explorans limites defectum
Reply
#7
(03-23-2017, 09:37 PM)Dean Roddey Wrote: In the sunset scheduled event, get the current time. Add five hours to it. There's a command to adjust at time. There's also one to get the time as the broken out parts (hours, minutes, secs.) You can use those parts to build up the required time value string to set the scheduled event. Since the time parts will reflect five hours after the current time, that will make it run five hours later that night.

I need to go to sleep. I can elaborate more tomorrow if you haven't found those things.

THank you. I may be getting closer. I tried the following, but I am getting an error when running saying that "Variable GVar:5hrsaftersunset was not found"

// Calculate five hours later
GlobalVars::SetNowPlus
    P1=GVar:5hrsaftersunset
    P2=Minutes
    P3=300

GlobalVars::SetTimeVar
    P1=GVar:5hrsaftersunsetclean
    P2=%GVar:5hrsaftersunset
    P3=24HH:MM

EventSrv::SetSchEvTime
    P1=/User/specailevent
    P2=%GVar:5hrsaftersunsetclean
    P3=

End

Thank you
Reply
#8
It has to be %(GVar:xxx) format not %GVar:xxx.
Dean Roddey
Explorans limites defectum
Reply
#9
BTW, that 24HH:MM thing isn't going to work. It wants a space separated set of values. Here is what you want:

Code:
LocalVars::CreateVariable(LVar:TarTime, Time, , );
LocalVars::SetNowPlus(LVar:TarTime, Minutes, 300)
System::GetTimeParts(%(LVar:TarTime), LVar:Hour, LVar:Min, LVar:Sec)
EventSrv::SetSchEvTime(/User/whatever, 0 %(LVar:Hour) %(LVar:Min), );

1. So we create a time variable, all the variables are local since they don't need to last longer than this action.
2. Then we do the set now plus as you were already doing, to create a time stamp five hours from now.
3. Then we get the time parts, which gets us the hours, minutes and seconds of that time stamp.
4. For a scheduled event, it wants two values. First is a time in the form "dd hh mm", so day hour and minute. For a daily event, which yours should be the day is meaningless so I just set that to zero. Then I added the new target hour and minute.
5. It also wants a 'day mask' but for a daily event that doesn't have any meaning because they run every day, so you don't have to pass the mask. I just passed in an empty string. You could also pass in 7 ones, i.e. 1111111.

That's all it takes.

The actual output is:

Code:
----------------------------------------------------------
CMD: 001.  (179320ms) - LocalVars::CreateVariable
    P1=LVar:TarTime
    P2=Time
    P3=
    P4=

CMD: 002.  (0us) - LocalVars::SetNowPlus
    P1=LVar:TarTime
    P2=Minutes
    P3=300

VAR: Set variable 'LVar:TarTime'
       =0x34F2E66DC26390

CMD: 003.  (0us) - System::GetTimeParts
    P1=0x34F2E66DC26390
    P2=LVar:Hour
    P3=LVar:Min
    P4=LVar:Sec

VAR: Set variable 'LVar:Hour'
       =17
VAR: Set variable 'LVar:Min'
       =37
VAR: Set variable 'LVar:Sec'
       =8

CMD: 004.  (0us) - EventSrv::SetSchEvTime
    P1=/User/whatever
    P2=0 17 37
    P3=
Dean Roddey
Explorans limites defectum
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Event Server Error Bugman 4 250 06-05-2022, 08:54 AM
Last Post: Bugman
  Triggered Event w/ Elk AreaArm EST 18 6,015 12-04-2020, 05:37 PM
Last Post: gReatAutomation
  Triggered Event only works every second time znelbok 2 1,043 10-27-2020, 12:05 PM
Last Post: znelbok
  Global Variables in the Event Server context lleo 1 1,065 05-16-2020, 11:21 AM
Last Post: Dean Roddey
  Sunrise/Sunset potts.mike 10 4,160 02-03-2020, 02:25 PM
Last Post: simplextech
  [FEATURE] Event Run Action simplextech 4 2,418 01-09-2020, 02:04 PM
Last Post: simplextech
  Media playing from Event simplextech 11 3,940 01-07-2020, 06:09 PM
Last Post: simplextech
  Triggered Event on Timer Question znelbok 7 3,411 12-09-2019, 02:10 PM
Last Post: znelbok
  Triggered Event and Standard Triggers gReatAutomation 5 2,060 08-23-2019, 12:38 PM
Last Post: Dean Roddey
  LogicServer Elapsed Time and Triggered Event gReatAutomation 6 2,395 08-17-2019, 07:53 AM
Last Post: gReatAutomation

Forum Jump:


Users browsing this thread: 1 Guest(s)