Announcement

Collapse
No announcement yet.

Script Help.

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

    Script Help.

    Hello.
    I have a simple trigger that sends

    &hs.RunEx "Pioneer.txt", "SendCommand", "VU"

    to my Pioneer Receiver.

    I would like the command sent to be different based on the status of a device. In non script speak this would be...

    If device&1 = "Power Off"
    then send "&hs.RunEx "Pioneer.txt", "SendCommand", "VU""
    else send "&hs.RunEx "Pioneer.txt", "SendCommand", "ZU""


    Could someone help me translate this into vb?

    Thanks

    Jon

    #2
    Off the top of my head and untested
    Code:
    sub main()
    if hs.deviceStatus("&1") = 3 then 
       hs.runEx ("Pioneer.txt", "SendCommand", "VU")
    else
       hs.runEx ("Pioneer.txt", "SendCommand", "ZU")
    end if
    end sub
    remember that the syntax for runEx is : hs.RunEx("test.txt","launch_app","notepad.exe")
    so is vu and executable?
    put this in a file with a .txt extention and test
    💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

    Comment


      #3
      Thanks Rupp - I understand all of that apart from the

      hs.deviceStatus("&1") = 3

      What does the 3 represent and how does this relate to "Power Off"

      (VU by the way is the RS232 command that the script sends to the receiver on COM - representing 'Volume Up')

      Jon

      Comment


        #4
        Jon,
        Device status stores the status like this.
        2 = ON
        3 = OFF
        4 = DIM
        17 = UNKNOWN

        I "assumed" the device was off so thus the line. Is the device not off?
        💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

        Comment


          #5
          Ah - I understand. The Device is the Russound plugin ZONE device. I will try this tonight and see if 3 works. More generically, if the status is "Power Off" can I use this as

          hs.deviceStatus("&1") = "Power Off"

          or is it more complicated than that.

          Also, I've looked about on the board, but didn't see anything - is there a 'beginners guide to VB' for homeseer, or any other reference that would help me with the syntax? I can program a bit of Basic and Applescript, but don't have reference for VBscript

          Jon

          Comment


            #6
            If what you see is Power Off and there is no html included in the deviceString then you can use if hs.deviceString("&1") = "Power Off"
            To test to see what is actually stored in the deviceString you can use this in the immidiate window to test.
            &msgbox(hs.deviceString("&1"))
            This will pop up a messagebox on your HS server so make sure you only test it locally. It will show the exact string.
            💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

            Comment


              #7
              Great - thanks for the guidance
              Jon

              Comment


                #8
                You're welcome. Let us know what shows and we can get you going on this.
                💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                Comment


                  #9
                  Originally posted by Rupp View Post
                  You're welcome. Let us know what shows and we can get you going on this.
                  Hi Rupp,

                  Ok, some success. I had to remove the () on line 3 and line 5 and then the script would process. However, I was getting ZU when I expected VU, so I tried the &msgbox command and got "Power Off", so I changed the if to use "Power Off", but I still got ZU.

                  So, rather than using the &1 device (my Russound Zone), I switched to _35 which is a simple on off light. Using this device, the script works properly.

                  So, my only remaining issue now is how to read my &1 device. I attach a screenshot of what I see - but 3 and "Power Off" haven't worked for me.

                  Any suggestions?

                  Jon
                  Attached Files

                  Comment


                    #10
                    You need to do an &msgbox(hs.deviceString "&1") and post what shows.
                    💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                    Comment


                      #11
                      Originally posted by Rupp View Post
                      You need to do an &msgbox(hs.deviceString "&1") and post what shows.
                      I did that and it shows Power Off

                      Comment


                        #12
                        Try this:
                        Code:
                        sub main()
                        if ucase(hs.deviceString("&1")) = "POWER OFF" then 
                           hs.runEx ("Pioneer.txt", "SendCommand", "VU")
                        else
                           hs.runEx ("Pioneer.txt", "SendCommand", "ZU")
                        end if
                        end sub
                        💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                        Comment


                          #13
                          Originally posted by Rupp View Post
                          Try this:
                          Code:
                          sub main()
                          if ucase(hs.deviceString("&1")) = "POWER OFF" then 
                             hs.runEx ("Pioneer.txt", "SendCommand", "VU")
                          else
                             hs.runEx ("Pioneer.txt", "SendCommand", "ZU")
                          end if
                          end sub
                          Nope - still get ZU.

                          Sorry about this - its an odd one - I know the script is ok because it works on a light.

                          Do you think there is something peculiar about the Russound status?

                          Jon

                          Comment


                            #14
                            Try this.

                            &msgbox("+++" & hs.deviceString "&1" & "+++") and post a screen shot of the messagebox
                            💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                            Comment


                              #15
                              Did you see this addition?
                              💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                              Comment

                              Working...
                              X