Announcement

Collapse
No announcement yet.

HS4 Scripting Extension (by ten)

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

    HS4 Scripting Extension (by ten)

    A library of a few script extensions callable from any script that might be useful for some. http://tenholder.net/tenWare2/Script.../Overview.aspx

    Code:
    Note:  [I]tenScripting4 [/I]now makes it easy for you to develop your own Global Methods, callable from ANY HS4 script.
    
    [URL]http://tenholder.net/tenWare2/tenScripting4/GlobalMethods.aspx[/URL]
    You can turn ON all devices that are in both Categories Lights and Office with just:

    Dim Result = DeviceOn(hs, GetRefsInBothLists(GetRefsByCategoryName(hs4, "Office"), GetRefsByCategoryName(hs4, "Lights")))


    Here are a few of the extensions:



    DeviceOn(hs, DevRef as Integer) as String
    DeviceOn(hs, DevRefs as List(Of Integer) as String


    DeviceOff(hs, DevRef as Integer) as String
    DeviceOff(hs, DevRefs as List(Of Integer) as String


    ToggleDeviceOnOff(hs, DevRef as Integer) as String

    GetCategoriesByRef(hs4, DevRef as Integer) as List(Of String)

    GetRefsByCategoryName(hs4, CatName as String) as List(Of Integer)

    tenholde

    #2
    Sweet! Thanks for another innovative piece of software!

    Comment


      #3
      First of all I want to say thanks for the HS4 script extension.

      I need help with the script extension for GetFeatureRefByFullname() in vb script?
      Must I include Floor and Room name for the Feature name? Any way I can get the feature ref id by just specifying the device name and its feature name?

      Comment


        #4
        Need floor and room for both device and feature. Even then, the combination is not always unique. tenScriptAid4 will detect and report all duplicates
        tenholde

        Comment


          #5
          Check misc tab on tenScriptAid4

          While GetFeatureRefByFullname would need the fully qualified Device (root) name, I could modify it to optionally just look for the Name of the feature. Let me know if this would be helpful.
          tenholde

          Comment


            #6
            Hi tenholde,
            Thanks for replying to my question.
            Yes it would be helpful. With HS4 now I have changed all my devices name + features name to be unique. The room and floor is mainly used to categorize it.

            Comment


              #7
              Hi Tenholder,

              I'm using your .dll to GetFeatureRefByFullname() and turning ZigbeePlus device on of off with DeviceON() DeviceOFF()
              Is there also a way to SET feature values/strings within a .vb script.
              If not can you add extentions to set features just like DeviceOn?

              Regards,
              Hans

              Comment


                #8
                No need for additional extensions. Get DevRef by FullName and then use standard scripting references, such as:

                Dim DevRef As Integer
                DevRef = GetFeatureRefByFullname(hs, "tenPlugin tenBrultech House", "tenPlugin tenBrultech House TriggerHigh")
                hs4.UpdatePropertyByRef(DevRef, EProperty.Value, 37) 'set device value
                hs4.UpdatePropertyByRef(DevRef, EProperty.StatusString, "High Trigger is 37") 'set device string​

                tenholde

                Comment


                  #9
                  Originally posted by tenholde View Post
                  No need for additional extensions. Get DevRef by FullName and then use standard scripting references, such as:

                  Dim DevRef As Integer
                  DevRef = GetFeatureRefByFullname(hs, "tenPlugin tenBrultech House", "tenPlugin tenBrultech House TriggerHigh")
                  hs4.UpdatePropertyByRef(DevRef, EProperty.Value, 37) 'set device value
                  hs4.UpdatePropertyByRef(DevRef, EProperty.StatusString, "High Trigger is 37") 'set device string​
                  Thanks for your answer.

                  How to use this in a .vb script. I'm getting 'Eproperty' is not declared.
                  Do I need to import something?

                  Regards,
                  Hans

                  Comment


                    #10
                    Try:

                    hs4.UpdatePropertyByRef(DevRef, HomeSeer.PluginSdk.Devices.EProperty.Value, 37) 'set device value

                    tenholde

                    Comment


                      #11
                      Originally posted by tenholde View Post
                      Try:

                      hs4.UpdatePropertyByRef(DevRef, HomeSeer.PluginSdk.Devices.EProperty.Value, 37) 'set device value
                      Still not working...
                      I get this eror in the logfile:
                      Error 00 Running script: Exception has been thrown by the target of an invocation

                      This is my script:

                      ------------------------------------------------------
                      Imports System.IO
                      Imports System.Net
                      Imports tenGlobalMethods
                      Imports System.Collections.Generic
                      Imports System.Threading

                      Sub Main()

                      Dim DevRef As Integer

                      DevRef = GetFeatureRefByFullname(hs, "Plugin Zigbeeplus Lamp-4", "Plugin Zigbeeplus Brightness")
                      hs4.UpdatePropertyByRef(DevRef, HomeSeer.PluginSdk.Devices.EProperty.Value, 37) 'set device value​

                      End Sub

                      Comment


                        #12
                        Try:

                        ​​​​Public Sub Main(parms as Object)

                        tenholde

                        Comment


                          #13
                          Originally posted by tenholde View Post
                          Try:

                          ​​​​Public Sub Main(parms as Object)
                          That makes no difference.

                          Setting value is NOT working
                          hs4.UpdatePropertyByRef(DevRef, HomeSeer.PluginSdk.Devices.EProperty.Value, 78) 'set device value​

                          But, setting statustring IS working without error's (Checked the settings with tenScriptAid

                          hs4.UpdatePropertyByRef(DevRef, HomeSeer.PluginSdk.Devices.EProperty.StatusString, "78 %") 'set device string

                          Any idea why the value gives the error?
                          Click image for larger version

Name:	Screenshot 2023-07-24 191442.png
Views:	136
Size:	155.4 KB
ID:	1626245

                          Comment


                            #14
                            Did the error go away?
                            tenholde

                            Comment


                              #15
                              No, see pervious post 13 .Value gives a error .Statusstring is ok

                              Comment

                              Working...
                              X