Announcement

Collapse
No announcement yet.

PLCBUS Connector for HomeSeer 2 Scripting API

Collapse
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    PLCBUS Connector for HomeSeer 2 Scripting API

    Plugin API:

    hs.Plugin("PLCBUS Connector").Version As String
    Get the plugin version

    hs.Plugin("PLCBUS Connector").Debug As Boolean
    Get or Set the plugin debug mode

    hs.Plugin("PLCBUS Connector").ReloadConfig() As Boolean
    Reloads the hspi_plcbus.ini INI settings. The API returns a boolean meaning success or failure. In case of failure, the Error message is printed to the HomeSeer event log.

    hs.Plugin("PLCBUS Connector").CreateLampDevice( deviceCode As String, deviceName As String ) As Boolean
    Creates a new PLCBUS Lamp device. The API returns a boolean meaning success or failure. In case of failure, the Error message is printed to the HomeSeer event log.

    hs.Plugin("PLCBUS Connector").DeleteLampDevice( deviceCode As String ) As Boolean
    Deletes a PLCBUS Lamp device. The API returns a boolean meaning success or failure. In case of failure, the Error message is printed to the HomeSeer event log.

    hs.Plugin("PLCBUS Connector").CreateApplianceDevice( deviceCode As String, deviceName As String ) As Boolean
    Creates a new PLCBUS Appliance device. The API returns a boolean meaning success or failure. In case of failure, the Error message is printed to the HomeSeer event log.

    hs.Plugin("PLCBUS Connector").DeleteApplianceDevice( deviceCode As String ) As Boolean
    Deletes a PLCBUS Appliance device. The API returns a boolean meaning success or failure. In case of failure, the Error message is printed to the HomeSeer event log.

    hs.Plugin("PLCBUS Connector").CreateSceneDevice( deviceCode As String, deviceName As String ) As Boolean
    Creates a new PLCBUS Scene device. The API returns a boolean meaning success or failure. In case of failure, the Error message is printed to the HomeSeer event log.

    hs.Plugin("PLCBUS Connector").DeleteSceneDevice( deviceCode As String ) As Boolean
    Deletes a Scene device and removes Scene programming from PLCBUS modules. The API returns a boolean meaning success or failure. In case of failure, the Error message is printed to the HomeSeer event log.

    hs.Plugin("PLCBUS Connector").AddSceneEntry( sceneDeviceCode As String, deviceCode As String, function As String, dimLevel As Integer, fadeRate As Integer) As Boolean
    Adds a new Scene entry to a Scene. The API returns a boolean meaning success or failure. In case of failure, the Error message is printed to the HomeSeer event log.

    - Function must be "OFF", "ON" (for Appliance devices only) or "PRESETDIM" (for Lamp devices only).
    - DimLevel must be 1-100
    - FadeRate must be 0 (instant) to 100 (very slow). I think this is the number of seconds.

    hs.Plugin("PLCBUS Connector").DeleteSceneEntry( sceneDeviceCode As String, deviceCode As String) As Boolean
    Removes a device from a Scene. The API returns a boolean meaning success or failure. In case of failure, the Error message is printed to the HomeSeer event log.

    hs.Plugin("PLCBUS Connector").ProgramScene( sceneDeviceCode As String ) As Boolean
    Programs PLCBUS modules for a previously defined Scene and save Scene settings to the plugin configuration file. Returns a boolean indicating success or failure. In case of failure, the Error message is printed to the HomeSeer event log.
    Last edited by stipus; November 18, 2007, 06:04 AM.
    --
    stipus

    #2
    PLCBUS Config API:


    hs.Plugin("PLCBUS Connector").ThreePhases As Boolean
    Get or Set the PLCBUS three phases mode.

    hs.Plugin("PLCBUS Connector").WaitForAck As Boolean
    Get or Set the PLCBUS wait for command acknowledgement mode.

    hs.Plugin("PLCBUS Connector").UserCode As Byte
    Get or Set the PLCBUS User Code

    hs.Plugin("PLCBUS Connector").GetUserCodeFromNextMessage() As Boolean
    Tries to automatically set the PLCBUS User Code from first PLCBUS message seen on the line.
    The API returns a boolean meaning success or failure (timeout after 10 seconds).
    Last edited by stipus; November 10, 2007, 10:10 AM.
    --
    stipus

    Comment


      #3
      PLCBUS Tools API:


      hs.Plugin("PLCBUS Connector").ReportInUseAddresses( houseCode As String ) As String
      Returns a string with all primary addresses in use on a specific House Code. Does not return addresses used for scenes.

      hs.Plugin("PLCBUS Connector").ReportOnlyOnAddresses( houseCode As String ) As String
      Returns a string with all primary addresses for switched ON modules on a specific House Code. Does not return addresses used for scenes.

      hs.Plugin("PLCBUS Connector").ReportSignalStrength( deviceCode As String ) As String
      Returns a string with PLCBUS signal strength from PLCBUS Interface to specified module

      hs.Plugin("PLCBUS Connector").ReportNoiseStrength( deviceCode As String ) As String
      Returns a string with PLCBUS noise strength at specified module

      hs.Plugin("PLCBUS Connector").ChangeReceiverAddress( oldDeviceCode As String, newDeviceCode As String ) As Boolean
      Change the PLCBUS primary address of a PLCBUS receiver module. With this API, you can easily reprogram a A1 lamp module to address B5...
      Currently this API does not check success or failure, and always returns True.

      hs.Plugin("PLCBUS Connector").EraseAllScenesFromModule( deviceCode As String) As String
      Returns a string indicating success or failure.
      Last edited by stipus; November 8, 2007, 01:16 PM.
      --
      stipus

      Comment


        #4
        PLCBUS Fast Polling API:


        hs.Plugin("PLCBUS Connector").FastPolling As Boolean
        Gets or sets Fast Polling Mode.

        hs.Plugin("PLCBUS Connector").FastPollingInterval As Integer
        Gets or sets the Fast Polling interval. Value must be >= 10 seconds

        hs.Plugin("PLCBUS Connector").FastPollingHouseCodes As String
        Gets or sets the House Codes that need Fast Polling, such as "ABC"


        Other polling functions:

        hs.Plugin("PLCBUS Connector").PollHouseCode( houseCode As String )
        This updates ON/OFF status for a whole house code at once. You can use this from a script to force the PLCBUS Connector into polling an house code.
        You should use this only if you disabled the plugin fast polling automatic functionnality.

        You can also use standard HomeSeer status request using the hs interface:

        hs.PollDevice( deviceCode as String )
        This updates ON/OFF/DIM Level status for a single PLCBUS device.


        Note that fast polling only updates the ON/OFF status, whereas individual status requests also update the DIM level.
        Last edited by stipus; January 28, 2012, 12:55 PM.
        --
        stipus

        Comment


          #5
          API to send Any PlcBus command (from 1.24.2.2)


          hs.Plugin( "PLCBUS Connector" ).SendPlcBusByteCommand( byteArrayString as String )

          the string parameter must be the array of bytes that are sent to the Plcbus 1141 interface. You have to know the Plcbus protocol to use this.

          This sends A1 ON for usercode 100
          hs.Plugin( "PLCBUS Connector" ).SendPlcBusByteCommand( "2,5,100,0,2,0,0,3" )

          This changes C3 user code from 255 to 130
          hs.Plugin( "PLCBUS Connector" ).SendPlcBusByteCommand( "2,5,255,34,16,130,34,3" )


          hs.Plugin( "PLCBUS Connector" ).SendPlcBusCommand( deviceCode as String, plcBusFunction as Integer, data1 as Integer, data2 as Integer, feedback as Boolean )

          This one is easier to use, but you can't control the user code.

          hs.Plugin( "PLCBUS Connector" ).SendPlcBusCommand( "A1", 2, 0, 0, false )

          The second argument (PlcBusFunction) must be one of:

          AllUnitsOff = 0,
          AllLightsOn = 1,
          On = 2, (data1 must be 100, data2 must be 0)
          Off = 3, (data1 must be 0, data2 must be 0)
          Dim = 4, (light will dim until fade-stop func=11 is received)
          Bright = 5, (light will bright until fade-stop func=11 is received)
          AllLightsOff = 6,
          AllUserLightsOn =7,
          AllUserUnitsOff =8,
          AllUserLightsOff = 9,
          Blink = 10,
          FadeStop = 11,
          PresetDim = 12, (data1=dim level, data2=rate)
          StatusOn = 13,
          StatusOff = 14,
          StatusRequest =15,
          ReceiverMasterAddressSetup =16,
          TransmitterMasterAddressSetup =17,
          SceneAddressSetup =18,
          SceneAddressErase =19,
          AllSceneAddressErase = 20,
          Reserved1 = 21,
          Reserved2 = 22,
          Reserved3 = 23,
          GetSignalStrength = 24,
          GetNoiseStrength = 25,
          ReportSignalStrength = 26,
          ReportNoiseStrength = 27,
          GetAllIdPulse = 28,
          GetOnlyOnIdPulse = 29,
          ReportAllIdPulse3Phase = 30,
          ReportOnlyOnIdPulse3Phase = 31

          Last edited by stipus; October 23, 2008, 12:41 PM.
          --
          stipus

          Comment


            #6
            Programming questions..

            Hi,
            In what language I should Program it?

            How to I check the address of the Plag I just connected to the computer?
            Send tests to all plug?
            change address?

            Thanks, Gil

            Is there A software to check it?

            Comment


              #7
              Originally posted by B007 View Post
              Hi,
              In what language I should Program it?
              The API is primarily for use from HomeSeer VB.NET scripts. However, it should work from any other supported .NET language.

              How to I check the address of the Plag I just connected to the computer?
              Send tests to all plug?
              change address?
              Sorry I don't understand. What did you connect to the computer ?

              If you add a new PlcBus plug and you don't know its address, the best is to reprogram it with a new address. You could also use the Plcbus tools in the plugin configuration interface to query all in-use addresses.
              --
              stipus

              Comment


                #8
                Stipus ,

                Is that possible to run "Fast Polling" by script ?
                For example , I don't want to enable "Fast Polling" function and I want to create a event , once run the event , run the script to get the update status of device.

                I find that , if I use this command :
                hs.Plugin("PLCBUS Connector").FastPolling As Boolean
                It run process fast polling , but not run it immediately. (For example , if I set the fast polling interval is a 30seconds , once I enable by script , it will process the 1st fast polling process after 30 seconds.

                If I use this command :
                hs.Plugin("PLCBUS Connector").ReportOnlyOnAddresses( houseCode As String ) As String
                It will return a string , but not update the device status.
                Any suggestion ?

                Comment


                  #9
                  Kevin,

                  To use Fast polling, try the following:

                  hs.Plugin("PLCBUS Connector").PollHouseCode( houseCode As String )
                  This updates ON/OFF status for a whole house code at once.

                  You can also use standard status request using the hs interface:

                  hs.PollDevice( "A1" )
                  This updates ON/OFF/DIM Level status for a single device
                  --
                  stipus

                  Comment


                    #10
                    Originally posted by stipus View Post
                    Kevin,

                    To use Fast polling, try the following:

                    hs.Plugin("PLCBUS Connector").PollHouseCode( houseCode As String )
                    This updates ON/OFF status for a whole house code at once.

                    You can also use standard status request using the hs interface:

                    hs.PollDevice( "A1" )
                    This updates ON/OFF/DIM Level status for a single device
                    Thanks Stipus , it work.
                    I have another question , if I run the API in script statment.
                    example :
                    &hs.Plugin("PLCBUS Connector").SendPlcBusCommand("D3", 2, 100, 0, false)
                    It work .
                    But if I put into script.

                    Sub Main()
                    hs.Plugin("PLCBUS Connector").SendPlcBusCommand("D3", 2, 100, 0, false)
                    End Sub

                    It will have error :
                    Running script, script run or compile error in file: testing waiting script1044:Cannot use parentheses when calling a Sub in line 2 More info: Cannot use parentheses when calling a Sub

                    What is the problem ?

                    Comment


                      #11
                      I think this is a syntax error because you are using an old version of visual basic. The syntax for procedures does not use parenthesis

                      For a function : functionResult = functionName( param1, param2 )
                      For a procedure: procedureName param1, param2

                      --> in your case:

                      Sub Main()
                      hs.Plugin("PLCBUS Connector").SendPlcBusCommand "D3", 2, 100, 0, false
                      End Sub

                      You should use VB.NET scripting. It's much more advanced than old VB Scripts.
                      --
                      stipus

                      Comment


                        #12
                        Originally posted by stipus View Post
                        I think this is a syntax error because you are using an old version of visual basic. The syntax for procedures does not use parenthesis

                        For a function : functionResult = functionName( param1, param2 )
                        For a procedure: procedureName param1, param2

                        --> in your case:

                        Sub Main()
                        hs.Plugin("PLCBUS Connector").SendPlcBusCommand "D3", 2, 100, 0, false
                        End Sub

                        You should use VB.NET scripting. It's much more advanced than old VB Scripts.
                        Thanks Stipus.

                        Have another question .
                        If I use your API for send the command. Example :
                        hs.Plugin("PLCBUS Connector").SendPlcBusCommand "D3", 2, 100, 0, false

                        Command send out , D3 can turn on successfully. But :
                        No Log in HS Log , Device status will not update.

                        If I use X10 API for send the command. Example :
                        hs.ExecX10 "D3", "on", 0, 0

                        Command send out , D3 also can turn on successfully. But:
                        It have a log for "Device Control" and also will update the device status.

                        So what is the different between PLCBUS Connector's API and X10 API ?
                        In what situation I should use your API , what situation I should use X10 API ?

                        Sorry Stipus , so many question....

                        Comment


                          #13
                          To command devices, you should use the standard HomeSeer X10 API such as hs.ExecX10() or hs.PollDevice(), and the plugin will convert everything to PLCBUS, and update device status.

                          There are some additional PLCBUS functions only available from the PLCBUS API, such as fast polling, PlcBus tools, declaring devices and programming scenes.

                          The plugin supports only one "PlcBus User Code". If you need to send commands to more than one user code, or send special commands, you must use the SendPlcBusByteCommand() API.
                          --
                          stipus

                          Comment

                          Working...
                          X