Announcement

Collapse
No announcement yet.

Script for Days until

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

    Script for Days until

    Looking for something to set a HS variable to the number of days between current and some future holiday such as Christmas or New Years.

    Any suggestions?

    #2
    Something based around this bit of vbs should do

    msgbox (datediff ("d",Now(),"4/7/2006"))

    (Note - the date format appears to follow locale settings - so for me the above date string is the 4th of July not the 7th of April)

    HTH

    Malarcy

    Comment


      #3
      sub main()
      dim daysTillXmas

      daysTillXmas = DateDiff("d", Now , "24-Dec")
      hs.speak "There are " & daysTillXmas & " days until christmas. Ho ho ho."

      end sub
      HS4Pro on a Raspberry Pi4
      54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
      Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

      HSTouch Clients: 1 Android

      Comment


        #4
        Last year someone wanted a script to announce New Years. The attached script might give you some ideas.
        Attached Files

        Comment


          #5
          Thanks to all

          Got some good ones. They all do excactly what I wanted.

          I found another one in JAVA that also works in an ASP page.

          Don

          Comment


            #6
            http://board.homeseer.com/showthread.php?t=114057

            Comment


              #7
              Don this will set a VD text to the number of days till the date entered.
              PHP Code:
              sub main()
               
              iNumDays datediff("d",Now,"12/25/2006")
               
              hs.setDeviceString "A1"iNumDays
              end sub 
              💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

              Comment


                #8
                Thanks

                Another one to add to my collection. All work great.

                Comment


                  #9
                  Originally posted by rmasonjr View Post
                  sub main()
                  dim daysTillXmas

                  daysTillXmas = DateDiff("d", Now , "24-Dec")
                  hs.speak "There are " & daysTillXmas & " days until christmas. Ho ho ho."

                  end sub
                  Where do you put this in the event to speak the values? When I copy and paste the text above, the system reads the values as literal text.

                  Comment


                    #10
                    Place the attached file in your scripts directory and then create an event to run the script xmas.txt.
                    Attached Files
                    Jon

                    Comment


                      #11
                      Originally posted by jacobegan View Post

                      Where do you put this in the event to speak the values? When I copy and paste the text above, the system reads the values as literal text.
                      Thats an older script, so let's bring it up to date with this:

                      Create an Event called "Days Until Xmas"
                      The trigger can be anything like, the time as at 7:00p
                      Run a Script or Script Command
                      Click the Edit button
                      Where you select a script file, just add DaysUntil.vb to the end of the path - this will create a new script called DaysUntil.vb
                      Click image for larger version

Name:	screenshot1.png
Views:	213
Size:	8.5 KB
ID:	1342719

                      Now, in the script body, make it look like this:

                      Click image for larger version

Name:	screenshot2.png
Views:	248
Size:	30.3 KB
ID:	1342720


                      Here is the text version of the script to paste:
                      Code:
                      Sub Main(parm as object)
                      dim daysTillXmas as Integer
                      
                      daysTillXmas = DateDiff("d", Now , "24-Dec")
                      hs.speak("There are " & daysTillXmas & " days until christmas. Ho ho ho.")
                      End Sub
                      HS4Pro on a Raspberry Pi4
                      54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                      Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                      HSTouch Clients: 1 Android

                      Comment


                        #12
                        Thank you both. That got it.

                        Comment


                          #13
                          Originally posted by jacobegan View Post
                          Thank you both. That got it.
                          Thanks for bringing up this old post. I had forgotten how much my kids loved hearing this during christmas time. They are older now and I miss that
                          HS4Pro on a Raspberry Pi4
                          54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                          Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                          HSTouch Clients: 1 Android

                          Comment


                            #14
                            Originally posted by rmasonjr View Post

                            Thanks for bringing up this old post. I had forgotten how much my kids loved hearing this during christmas time. They are older now and I miss that
                            Over 13 years it would appear. They must be grown up!
                            Jon

                            Comment


                              #15
                              Originally posted by jon00 View Post

                              Over 13 years it would appear. They must be grown up!
                              Yeah, this post made me realize how older they are.
                              HS4Pro on a Raspberry Pi4
                              54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                              Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                              HSTouch Clients: 1 Android

                              Comment

                              Working...
                              X