Announcement

Collapse
No announcement yet.

Execute Event Based on Script Time

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Execute Event Based on Script Time

    Hello everyone,

    I need to run an event based on time that is output from a script. The script is a javascript file, but the output is made by a <script> statement within an html file. The result is a very simple text output like: 08:01

    I need to be able to run an event based on this output. Is it possible to achieve this with Homeseer events? If yes, could you please help me out how I can get started?

    Thank you so much!

    #2
    OK, I was able to create virtual devices and set the desired time to their device string (something like 08:01). The big question is, how do I trigger an event based on the virtual device string time?

    Is this possible? If not, how can I use the time from a script and run the event based on that time?

    Please help, thanks!

    Comment


      #3
      Take a look at the EasyTrigger plugin.
      Attached Files

      Comment


        #4
        Thanks for the reply!

        How would it be possible to run an event based on the device's string time? I do not see such option within EasyTrigger... Is there a way to make that happen somehow?

        Thanks!

        Comment


          #5
          Originally posted by MegaZ View Post
          Thanks for the reply!

          How would it be possible to run an event based on the device's string time? I do not see such option within EasyTrigger... Is there a way to make that happen somehow?

          Thanks!
          The only possible way I see of doing this is using a script where you read the time and create an event in code to use that time as a trigger.
          💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

          Comment


            #6
            Originally posted by MegaZ View Post
            Thanks for the reply!

            How would it be possible to run an event based on the device's string time? I do not see such option within EasyTrigger... Is there a way to make that happen somehow?

            Thanks!
            Sorry, I thought where you said "... set the desired time to their device string ..." you meant the device string. That's what I showed that EasyTrigger could trigger on. If you are talking about the device last change time then you'll probably need a script as @Rupp says. If you describe what you are trying to accomplish others might have better suggestions.

            Comment


              #7
              Thanks for all the help guys. I figured out a way to do it:

              1) Make a script that changes a virtual device string at a particular time and make this script run every minute
              2) Use EasyTrigger to watch for device string change events. The moment the change occurs, run an event action

              The only thing I don't like about this methodology, is that this script runs every minute. But considering that I am doing this on a pretty powerful machine, I really don't mind it - looks like the CPU usage is under control.

              For those who are wondering, I am doing this to make the system call for prayer (Islamic prayer five times a day). I use a C# script that I obtained from http://praytimes.org/code/ and I have modified it a little to work with HomeSeer. After a few hours of modifying code and testing, I am happy to report that it is all working. Sonos is triggering a call for prayer at designated times and it is all very accurate!

              If anyone is looking forward to some information on how to do this, let me know and I will be happy to assist.

              Comment


                #8
                Is there no other way to do this? Like setting one event that fires at a given time and calls an event which starts a timer within HS. Then when that runs down, repeat the process, presumably until some other specific time of day.

                One of the most horrendous wastes of CPU resources is ill-conceived delays or timers. Thus many tools have specific features for just that purpose. HS has timers, would they not be useful here?

                Comment


                  #9
                  Originally posted by wkearney99 View Post
                  Is there no other way to do this? Like setting one event that fires at a given time and calls an event which starts a timer within HS. Then when that runs down, repeat the process, presumably until some other specific time of day.

                  One of the most horrendous wastes of CPU resources is ill-conceived delays or timers. Thus many tools have specific features for just that purpose. HS has timers, would they not be useful here?
                  It would be wonderful if there was a different way to do it. I have a script that can output all prayer times for a given day, but those times change based on a number of different factors, so those times cannot be put into simple logic and timers. The script itself is quite complicated and takes into account latitude and longitude to calculate the right times.

                  The way I have it now is obviously a waste of resources, but I just could not come up with a better way to do it. If there was a way to start an event based on the description from a device string, I could easily do it by creating 5 different virtual devices and assigning the right time to each device, so that the event is triggered only five times a day instead of every minute. I spent many hours trying to find a way to start an event based on a device string, but I could not find anything.

                  Do you have any suggestions on how to make this work?

                  Comment


                    #10
                    Here is a sample output from the script:

                    06:00
                    07:19
                    12:07
                    15:16
                    16:56
                    16:56
                    18:15

                    The above would be good for today, but the times will be slightly different for tomorrow and very different a few months from now (based on sunrise and sunset times, angle of the sun, etc).

                    Those are the exact times an event must run. Would you be able to recommend how I could create a timer to do this?

                    Thank you so much!

                    Comment


                      #11
                      How about this?

                      https://help.homeseer.com/help/HS3/s...settimetrigger

                      At midnight each day, run the script that gets the prayer times for the upcoming day. Then set up an event with a time trigger for each of those times.

                      Comment


                        #12
                        You are wonderful sir, thank you so much!

                        I changed the script to run once a day at 12:01:00, then created separate events for each prayer. The script changes the timer on each of those events and they run perfectly fine - just tested it out.

                        If anyone would like me to share the source code and how I was able to achieve this, please let me know!

                        Once again, thank you for all the wonderful support and help.

                        Comment


                          #13
                          Originally posted by MegaZ View Post
                          You are wonderful sir, thank you so much!

                          I changed the script to run once a day at 12:01:00, then created separate events for each prayer. The script changes the timer on each of those events and they run perfectly fine - just tested it out.

                          If anyone would like me to share the source code and how I was able to achieve this, please let me know!

                          Once again, thank you for all the wonderful support and help.
                          Please do

                          Comment

                          Working...
                          X