Announcement

Collapse
No announcement yet.

X10 Plugin: using ExecX10() from a script

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

    #16
    Progress...

    I rebuilt the device again. Instead of "Brightness" my device has "Level". So I replaced Brightness with Level in your script and the brightness changed.

    Haven't got it working just right, but that is the first time I was able to change the brightness from a script.

    I'll see what I can change to improve it.

    Thanks!

    Comment


      #17
      Originally posted by frankc View Post
      Progress...I rebuilt the device again. Instead of "Brightness" my device has "Level". So I replaced Brightness with Level in your script and the brightness changed.
      Excellent!
      You should definitely head over to Ed's site and check out TenScriptAid. It may detect the differences you are finding automatically and allow you to move forward more quickly.
      Mike____________________________________________________________ __________________
      HS3 Pro Edition 3.0.0.548, NUC i3

      HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

      Comment


        #18
        Great advice. I've been using TenScriptAid to get the code for commands in scripts. I'll look at it again to see how it might help in this regard.

        More Progress...

        I altered the S-G page to include just the 'range'. So range goes from 0 to 100 now. From the script, I can change the brightness from dark to bright. Problem is the levels are not consistent. For example, if I set the level to a 5, the bulb is barely on. I can then set values increasingly larger and the bulb brightness follows. But when set back to 5, the brightness may not drop from the brighter level. If I set it 0, bulb goes out, then I can again increase the brightness.

        Perhaps something odd with the CM15A plugin?

        This is the first time I've adjusted the brightness from a script.

        Thank you!

        Comment


          #19
          Originally posted by Uncle Michael View Post
          Excellent!
          You should definitely head over to Ed's site and check out TenScriptAid.
          The cards seem to be stacked against me. I tried using tenScriptAid and I can find the device but the "Select a value" window in the CAPIControl window does not allow a selection to be made. I posted on the tenScriptAid site explaining the problem.

          But one thing it already shows is that "Level (value)%" is what should be used. But I can't actually obtain the full statement to use.

          Ed will get it fixed.

          Comment


            #20
            Originally posted by Uncle Michael View Post
            Excellent!
            You should definitely head over to Ed's site and check out TenScriptAid. It may detect the differences you are finding automatically and allow you to move forward more quickly.
            I was able to get tenScriptAid to display the script necessary to set a dimming level for my device. I can't change tenScriptAid from 0%, but that is OK. It is the same code you had shared.

            Code:
            Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(145, True, "Level(value)%", False, False)
            cc.ControlValue = 0
            Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)
            So, getting closer...

            Comment


              #21
              Unfortunately the CM15a plugin very different internally, and less capable than the CM11a/Ti103 "X10" plugin. This is due in lagre part to limitations of the ActiveHome SDK which is used to interface between the HS CM15a plugin and the CM15a hardware device.

              ExecX10() only works for the "X10" plugin and the CM15a plugin calls this function exec() instead. You must supply all of the parameters or the function will fail:
              Code:
              exec(HouseCode as String, DeviceCode as String, Command as String, Value as String, Data1 as Short, Data2 as Short)
              It also looks like exec() never provides a return so sRet=exec("B", "2", "dim", "20", 0, 0) will always return "" for sRet.

              As for the missing Device Type button, I see that all of the code to support DeviceTypes is missing from the source that I received from HST. I will request the source for previous versions to see if I can figure out what happened. What is odd is that the button and functionality are in the current Linux version v3.0.0.4. What is the version of the plugin listed on your Manage Plugins page?

              Note that there is no easy way to access this setting for a CM15a device using scripts or modifying the DB. The Device Type listed on the Advanced tab tells you what plugin the device uses and is not related to the Device Type of the device.

              Please give the exec() plugin function a try and let us know if works.
              Last edited by mfisher; January 6, 2018, 11:44 AM.
              Best regards,
              -Mark-

              If you're not out on the edge, you're taking up too much room!
              Interested in 3D maps? Check out my company site: Solid Terrain Modeling

              Comment


                #22
                Originally posted by mfisher View Post
                Please give the exec() plugin function and let us know if works.
                Thank you for the help!

                I tried these:

                Dim HouseCode As String = "A"
                Dim DeviceCode As String = "8"
                Dim Command As String = "dim"
                Dim Value As String = "20"
                Dim Data1 As Short = 0
                Dim data2 As Short = 0
                sRet = exec(HouseCode, DeviceCode, Command, Value, Data1, data2) --> exec is not declared

                sRet = exec("A", "8", "dim", "20", 0, 0) --> exec is not declared
                sRet = exec("A", "8", "on", 0, 0) --> exec is not declared.
                sRet = hs.exec("A", "8", "on", 0, 0) --> 'exec' is not a member of Homeseer...

                Is there another way to use exec() ?

                The CM15A plugin version is 3.0.0.8.

                You have addressed each question I had. Thank you for that. I am hoping they will provide you with the older source code.

                Thanks again.
                Last edited by frankc; June 9, 2016, 11:52 AM. Reason: Added another statement line

                Comment


                  #23
                  Since you're attempting to call a function located within a plugin (not part of HS) you'll need to call it using PluginFunction() as mentioned above. Try this:
                  Code:
                  Dim sRet As String
                  Dim X10plugin As HomeSeerAPI.PluginAccess = New HomeSeerAPI.PluginAccess(hs, "CM15A", "")
                  Dim HouseCode As String = "A"
                  Dim DeviceCode As String = "8"
                  Dim Command As String = "dim"
                  Dim Value As String = "20"
                  Dim Data1 As Short = 0
                  Dim Data2 As Short = 0
                  sRet = X10plugin.PluginFunction("exec", {HouseCode, DeviceCode, Command, Value, Data1, Data2})
                  Best regards,
                  -Mark-

                  If you're not out on the edge, you're taking up too much room!
                  Interested in 3D maps? Check out my company site: Solid Terrain Modeling

                  Comment


                    #24
                    Originally posted by mfisher View Post
                    Since you're attempting to call a function located within a plugin (not part of HS) you'll need to call it using PluginFunction() as mentioned above.
                    Thank you for the explanation.

                    The only return I get is: "Nothing". There is no change in brightness. I tried it starting with the light on and off and dimmed. I tried using "dim" at various levels from 1 to 100.

                    I also tried "on" and "off" each at levels of 0 and 100. Should on and off be recognized, or just "dim"?

                    Anything else I should try? By the way, like you said, I still get a return of "Nothing" whether I use "exec" or any other string.

                    Comment


                      #25
                      The current 'exec' function code never assigns a value to be returned so it will always return 'nothing.'

                      I am on travel and will have to set this up on my dev machine when I get back to see if I can get it to work.
                      Best regards,
                      -Mark-

                      If you're not out on the edge, you're taking up too much room!
                      Interested in 3D maps? Check out my company site: Solid Terrain Modeling

                      Comment


                        #26
                        Thanks Mark,

                        From a script it returns "Nothing". In the HS log, it returns a blank response.

                        I've tried other stuff, but cannot get the device to react to the script.

                        Travel safely and thanks for the help.

                        Frank

                        Comment


                          #27
                          Ok, my bad - while the CM15a plugin includes the PluginFunction() function, it does not include any methods we can use to send commands (such as ExecX10 or Exec) to the CM15a device! The X10 plugin does include this functionality and I just assumed (I know) that the CM15a plugin would as well. So sorry for the wild goose chase.

                          HST is pretty good about getting back to me quickly so I expect I'll hear from them soon with the older source and can work on getting the missing DevType drop-down fixed soon.
                          Best regards,
                          -Mark-

                          If you're not out on the edge, you're taking up too much room!
                          Interested in 3D maps? Check out my company site: Solid Terrain Modeling

                          Comment


                            #28
                            No problem at all Mark. I appreciate your efforts.

                            When you live on the edge, your bound to slip off now and then.

                            We'll just await HST's response to your request.

                            Thanks again Mark,

                            Frank

                            Comment


                              #29
                              I figured out how to put this info into a script, but on the Device Management page the icon still shows "On" and not the dim value. The light does dim 10% each time I run the script. I have the device set as standard. It is a x10 light switch, WS467.

                              Why would that be?

                              Thanks,
                              Tim

                              Code:
                              Sub Main(ByVal Params As Object)
                              
                              Dim Code As String = "B5"     ' Device Code
                                Dim Cmd As String = "Dim"      ' Command
                                Dim DimVal As Integer = 10     ' Dim %
                                Dim Data2 As Integer = 0      ' Extended data or Preset Dim % (non-standard)
                                Dim Wait As Boolean = False   ' Always set to FALSE!!
                                Dim sRet As String
                              
                                ' Create an object that references the X10 plugin
                                Dim X10plugin as HomeSeerAPI.PluginAccess = New HomeSeerAPI.PluginAccess(hs, "X10","")
                              
                                ' Call the ExecX10() function within the plugin
                                Sret = X10plugin.PluginFunction("ExecX10",{Code,Cmd,DimVal,Data2,Wait})
                              
                              
                              
                              end sub
                              FB Page - https://www.facebook.com/pages/Capt-Tim/209398425902188

                              HSTouch Layouts - https://www.facebook.com/media/set/?...5902188&type=3

                              Comment


                                #30
                                The ExecX10() plugin function simply causes the plugin to transmit the requested data onto the power line. The plugin does not update the status of devices in HS when you use this function. ExecX10() should only be used in cases where you need to send a specific command to a device, such as an extended command or preset dim, that is not available or practical to use from the HS event UI.

                                Instead, you should change the HS device value. When you do that, HS calls the plugin with the change, the plugin sends the command(s) over the power line and then updates the HS device with the new value if there were no transmit errors.
                                Best regards,
                                -Mark-

                                If you're not out on the edge, you're taking up too much room!
                                Interested in 3D maps? Check out my company site: Solid Terrain Modeling

                                Comment

                                Working...
                                X