Announcement

Collapse
No announcement yet.

Last Received X10 Code

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

    Last Received X10 Code

    Hi. Is there a way to "read" the last received X10 code from a script? At the beginning of a script I want have the script check to see whether the last X10 code was, for example B9 OFF, and proceed differently than if it was something else.

    I have a few scripts that run in the evening, but if I have friends over, I want an easy way to change how they proceed before my lights start turning on and off.

    Thanks!

    #2
    Have a look at LastX10 in the Homeseer help files.
    💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

    Comment


      #3
      look at script help for hs.LastX10

      Comment


        #4
        My help system seems to be acting up, so I'll have to try to get into it later, but the name sounds like exactly what I was looking for.

        Hmm, I couldn't get into help remotely, but got right in from the local computer. Anyway, that'll do what I needed.

        I have not done any programming in like 5 years, so I'm trying to dust off that part of my brain.

        Would the code look something like:

        LastX10 (housecode; device; command; extra1; extra2)
        IF ((housecode="B") AND (device=9) AND (command="off"))
        sub_1
        ELSE
        sub_2
        EndIf

        And that would test for the last command as B9 OFF. Is that close to being correct?


        Thanks!
        Last edited by ; May 3, 2006, 02:18 PM.

        Comment


          #5
          Not quite..

          Try this:
          PHP Code:
          Sub main()

          Dim GetX10
          Dim HC

          GetX10
          =hs.lastX10
          HC
          =hs.stringitem(GetX10,2,";")

          If 
          HC="B9" then
          Msgbox 
          "Hit"
          else
          Msgbox "Miss"
          end if

          End sub 
          Just change the Msgbox statements for your own code.
          Jon

          Comment


            #6
            That last example just detects a B9 X10 signal - either on OR off

            To make it detect a on or off as well, you could expand the script as follows:

            PHP Code:
            Sub main() 

            Dim GetX10 
            Dim HC 
            Dim Command

            GetX10
            =hs.lastX10 
            HC
            =hs.stringitem(GetX10,2,";"
            Command=hs.stringitem(GetX10,3,";"

            If 
            HC="B9" and Command="3" then 
            Msgbox 
            "Hit" 
            else 
            Msgbox "Miss" 
            end if 

            End sub 
            If you look in the help files, the command value is provided as a table. The most important ones are:

            2=On
            3=Off

            So in the above example, you would get a message box appearing if the last X10 was B9 Off
            Jon

            Comment


              #7
              Thanks Jon! Geez, my programming skills are getting rusty!

              Comment

              Working...
              X