Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Checking what the last sunrise/sunset event was

  1. #1
    Join Date
    May 2004
    Posts
    2,588

    Default Checking what the last sunrise/sunset event was

    Hi guys,
    I was going through my GML tonight, trying to figure out better ways of dealing with certain time-dependent modes.
    The scheduler is great for firing events at certain times, but I've found that if I need to reboot or if the system is down for any reason at those times, then I run into problems.
    One example is my night-light mode that brightens a light to 30% until 30 seconds after motion stops in the hallway between midnight and sunrise. This would be simple if the sunrise did not vary. What usually ends up happening is that I have saved my GML and after restarting, Girder loads the file with that group enabled, even though it may be 4 in the afternoon. I've been trying to figure out how to check the time range and modify what groups are enabled in the GML at startup. This was fairly simple to accomplish with my volume restriction group that adjusts the volume in the bathroom and prevents anyone from going above the permitted level within certain definite ranges. However, these did not involve the sun. Is there a way to see what the last sunrise/sunset event was based on the times that are stored in the scheduler?

    Can someone please point me in the right direction? Thanks!
    Beware of the robot.

  2. #2
    Join Date
    May 2004
    Posts
    2,588

    Default

    No one has any ideas about this? If someone can tell me the syntax for the function to get the sunrise/sunset times then I can work with that.
    Thanks.
    Beware of the robot.

  3. #3
    Join Date
    May 2004
    Location
    Cardigan, UK
    Posts
    9,278

    Default

    I'll see what I can discover tomorrow. Remind me if I don't get back to you.
    --Rob

  4. #4
    Join Date
    May 2004
    Posts
    2,588

    Default

    Thank you. That would be much appreciated.
    Beware of the robot.

  5. #5
    Join Date
    May 2004
    Posts
    2,588

    Default

    Just a little reminder. Thanks.
    Beware of the robot.

  6. #6
    Join Date
    May 2004
    Location
    Cardigan, UK
    Posts
    9,278

    Default

    Okay, it looks as though the Sunrise/Sunset component creates a scheduler object, you should be able to access this using
    Code:
    local sched = scheduler.GetScheduler(10051)
    once you have a scheduler you can use
    Code:
    local tasks = sched:GetTasks()
    to get access to the tasks.
    --Rob

  7. #7
    Join Date
    May 2004
    Location
    Cardigan, UK
    Posts
    9,278

    Default

    Further to that it seems that there's a setting that isn't currently exposed in the configuration file. In fact there seem to be no settings exposed at all.

    For now, if you edit luascript\Components\SunriseSunset.lua and find the DefaultSettings table, and change it to

    Code:
    local DefaultSettings = {
        GenerateLastEventOnStartup = false,
    }
    then I believe that will stop the spurious triggering of the event that you are seeing.
    --Rob

  8. #8
    Join Date
    May 2004
    Posts
    2,588

    Default

    Good man!! Thanks Rob! I'll give it a try. This will help squash a lot of bugs in my system and enable me to add a few more features.
    Beware of the robot.

  9. #9
    Join Date
    May 2004
    Posts
    2,588

    Default

    ummm... did you try this out, Rob? It doesn't work for me.
    Code:
    [string "Laptop.gml:\New\Scripting"]:2: attempt to index global `sched' (a nil value)
    stack traceback:
        [string "Laptop.gml:\New\Scripting"]:2: in main chunk
    I can list the names of the scheduled events, using sched = scheduler.GetSchedulers(10051), but I can't get the times for those events.
    Beware of the robot.

  10. #10
    Join Date
    May 2004
    Location
    Cardigan, UK
    Posts
    9,278

    Default

    Did you have the two script fragments in the same script action?

    Can you post the code you used?
    --Rob

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •