Announcement

Collapse
No announcement yet.

Discussion thread for Homeland Security status script

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

    #16
    How do I add the icons to the script? I used the main script and added the status lines to the end.

    HELP !!!

    Fit4Life

    Comment


      #17
      here is the code i have now

      hs.SetDeviceString "z15", strAlert
      hs.SetDeviceLastChange "z15", now

      Fit4Life

      Comment


        #18
        You can accomplish this in one line if desired like:


        Form:
        hs.SetDeviceString "z15", strAlert hs.SetDeviceLastChange "z15", now

        To:
        hs.SetDeviceString "z15", strAlert, True

        -Rupp
        💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

        Comment


          #19
          Try this:

          Private Sub AlertChange(strAlert)

          select case strAlert
          case "Low"
          strImage = "low-i.jpg"
          strColor = "#008000"

          case "Guarded"
          strImage = "guarded-i.jpg"
          strColor = "#000080"

          case "Elevated"
          strImage = "elevated-i.jpg"
          strColor = "#FFCC00"

          case "High"
          strImage = "high-i.jpg"
          strColor = "#FF9933"

          case "Severe"
          strImage = "severe-i.jpg"
          strColor = "#800000"

          end select

          strHTML = "<img border='0' src='homeland/" & strImage & "' height='16' width='16' "
          strHTML = strHTML & "align='absmiddle'> "
          strHTML = strHTML & "<font color='" & strColor & "'>" & strAlert & "</font>"
          'strHTML = strHTML & strAlert
          hs.SetDeviceString "Z15",strHTML

          End Sub

          Comment


            #20
            Steve,

            Here is the entire script. I changed the names of the files and the location and HomeSeer gives me an error.

            Error~!~Web Server Error 404, cannot serve file: C:\Program Files\HomeSeer\html/icons/devices/


            here is the entire script

            sub main()

            dim strPage, strAdvise, strAlert, strMinutes
            dim ev, evOldTime

            strPage = hs.GetURL("www.whitehouse.gov","/homeland",FALSE,80)

            strMinutes = 0

            strAdvise = instr(1,lcase(strPage),"severe.jpg")
            if strAdvise > 0 then
            strAlert = "Red - Severe"
            strMinutes = 15 'check every 15 minutes
            end if

            strAdvise = instr(1,lcase(strPage),"high.jpg")
            if strAdvise > 0 then
            strAlert = "Orange = High"
            strMinutes = 30 'check every 1/2 hour
            end if

            strAdvise = instr(1,lcase(strPage),"elevated.jpg")
            if strAdvise > 0 then
            strAlert = "Yellow - Elevated"
            strMinutes = 60 'check every hour
            end if

            strAdvise = instr(1,lcase(strPage),"guarded.jpg")
            if strAdvise > 0 then
            strAlert = "Blue - Guarded"
            strMinutes = 180 'check every 3 hours
            end if

            strAdvise = instr(1,lcase(strPage),"low.jpg")
            if strAdvise > 0 then
            strAlert = "Green - Low"
            strMinutes = 360 'check every 6 hours
            end if


            if strMinutes > 0 then
            set ev = hs.GetEventEx("Homeland")
            evOldTime = ev.rec_secs
            if ev.rec_mins <> strMinutes then
            ev.rec_mins = strMinutes
            ev.rec_secs = 0
            AlertChange(strAlert)
            end if
            end if

            end sub

            '------------------------------------------

            Private Sub AlertChange(strAlert)


            select case strAlert
            case "Low"
            strImage = "low.gif"
            strColor = "#008000"

            case "Guarded"
            strImage = "guarded.gif"
            strColor = "#000080"

            case "Elevated"
            strImage = "elevated.gif"
            strColor = "#FFCC00"

            case "High"
            strImage = "high,gif"
            strColor = "#FF9933"

            case "Severe"
            strImage = "severe.gif"
            strColor = "#800000"

            end select

            strHTML = "<img border='0' src='/icons/devices/" & strImage & "' height='16' width='16' "
            strHTML = strHTML & "align='absmiddle'> "
            strHTML = strHTML & "<font color='" & strColor & "'>" & strAlert & "</font>"
            'strHTML = strHTML & strAlert
            hs.SetDeviceString "Z15",strHTML

            End Sub

            Comment


              #21
              Getting a script error: object doesn't support property or method:'hs.getEventx' in line 59. I named the text file homeland and the event homeland. Any suggestions. Thank you

              Comment


                #22
                I think I was smoking crack! Sheesh

                Try this at the end of main:

                if strMinutes > 0 then

                ev_count = hs.EventCount
                for i=1 to ev_count
                set ev=hs.GetEvent(i)
                if ev.name = "Homeland" then
                evOldTime = ev.rec_secs
                if ev.rec_mins <> strMinutes then
                ev.rec_mins = strMinutes
                ev.rec_secs = 0
                AlertChange(strAlert)
                end if
                end if
                next
                end if

                Comment


                  #23
                  all is named as you suggested and I still get the same error. I will try adding the code to the end of the script and see if it works.

                  Comment


                    #24
                    Thanks, that did it.

                    Comment


                      #25
                      OK, I've tried this script & can't get it to work, but I see there are all kinds of corrections, etc. here.

                      Does anyone have a script that works?

                      Thanks!

                      Comment


                        #26
                        31sunset

                        Here is the script i am using. It is working great.

                        Fit4Life
                        Attached Files

                        Comment


                          #27
                          OK, here's the error I get in my log:

                          Web server error 404: Cannot serve file: C:\program files\homeseer\html/homeland

                          Any ideas?

                          Thanks!

                          Comment


                            #28
                            You need to download the icons and place them in the html directory and then if so desired any directory you want. This is where my images are:
                            src='images/". Then edit the script to use this directory. Edit the line that has this code.
                            src='icons/devices/"

                            -Rupp
                            💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                            Comment


                              #29
                              Rick Bonari posted a question in the Script library. Tha answer to that is I missed taking that line out due to a revision.

                              You can safely take out evOldTime = ev.rec_secs. Sorry about that.

                              Comment


                                #30
                                I must be having a brain freeze. I can't get the icons to display.

                                Whe the program executes I get:

                                Error~!~Web Server Error 404, cannot serve file: C:\Program Files\HomeSeer\html/icons/devices/

                                My icons are in c:\programs files\homeseer\html\icons\devices

                                Script says:
                                strHTML = "<img border='0' src='icons/devices/" & strImage & "' height='22' width='119' "
                                strHTML = strHTML & "align='absmiddle'> "
                                strHTML = strHTML & "<font color='" & strColor & "'><b>" & strAlert & "</b></font>"
                                'strHTML = strHTML & strAlert
                                hs.SetDeviceString "x15",strHTML

                                I'm sure it's simple, but sure got me confused... I could use some help... thanks

                                Comment

                                Working...
                                X