Announcement

Collapse
No announcement yet.

Scripting Help

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

    Scripting Help

    Hi,

    I'm trying to log the value of some Zigbee temperature and humidiy sensors in the HS4 log via the &nhs.writelog command. I've got it working fine referencing the values with hs.devicevalue:

    Click image for larger version

Name:	Screenshot 2023-03-07 235218.jpg
Views:	188
Size:	21.9 KB
ID:	1597034

    Click image for larger version

Name:	Screenshot 2023-03-08 001358.jpg
Views:	160
Size:	6.9 KB
ID:	1597037


    But if I use hs.devicevaluebyname (which would be my preference), then I always get a value of -1:

    Click image for larger version

Name:	Screenshot 2023-03-08 000312.jpg
Views:	153
Size:	23.5 KB
ID:	1597036

    Click image for larger version

Name:	Screenshot 2023-03-07 235504.jpg
Views:	156
Size:	6.8 KB
ID:	1597035

    I've tried multiple iterations of the device name, but always get the same results. I believe this is a problem with the device name I'm using since I get the same -1 result even if I use garbage for the device name. Hoping someone can point out what I'm doing wrong.

    #2
    I tried it and could not get it to work with any HS4 created devices. Most probably linked to the parent/feature relationship changes in HS4.

    It does still work fine with HS3 created devices (in HS4) but not surprising as it is a HS3 scripting function.

    There is not an equivalent HS4 function I can see either...

    Jon

    Comment


      #3
      tenholde, don't you use "name" a lot? Have you noticed this?
      HomeSeer Version: HS4 Pro Edition 4.2.19.0 (Windows - Running as a Service)
      Operating System: Microsoft Windows 11 Pro - Desktop
      Z-Wave Devices via two Z-Net G3s
      Zigbee Devices via RaspBee on RPi 3b+
      WiFi Devices via Internal Router.

      Enabled Plug-Ins
      AK SmartDevice 4.0.5.1,AK Weather 4.0.5.134,AmbientWeather 3.0.1.9,Big6 3.44.0.0,BLBackup 2.0.63.0,BLGData 3.0.55.0,BLLock 3.0.39.0,BLUPS 2.0.26.0,Device History 4.5.0.2,EasyTrigger 3.0.0.76,Harmony Hub 4.0.14.0,HSBuddy 4.48.707.0,JowiHue 4.1.0.3,LG ThinQ 4.0.24.4,SDJ-Health 3.1.1.4,TPLinkSmartHome4 2022.12.30.0,UltraCID3 3.0.6681.34300,Z-Wave 4.1.0.3

      Comment


        #4
        I prefer to use a device/feature name as that is less likely to change than the device ref (which screws up existing events). You can use GetFeatureRefByFullname to get the devref and then use hs.DeviceValue. See the link below for more information:


        https://tenholder.net/tenWare2/Scrip...eRefByFullname
        tenholde

        Comment


          #5
          tenholde said:
          I prefer to use a device/feature name as that is less likely to change than the device ref (which screws up existing events).
          My thoughts exactly.

          I understand what you're suggesting as a solution, but I was hoping to accomplish this as a one line immediate script command in order to keep it simple.

          Is there some place that lists all the Homeseer script commands and functions? I've searched through the documentation and cant seem to find this.

          Comment


            #6
            Well, there is this: http://help.homeseer.com/help/HS3/static/

            However, it is for HS3 scripting, is incomplete, has errors, and is sorely lacking in examples, but it is all HST has given us to work with. Probably the best approach is to engage in self-help as far as possible, using the documents available, then get the brain trust available, here, to help sort your attempt out.
            HomeSeer Version: HS4 Pro Edition 4.2.19.0 (Windows - Running as a Service)
            Operating System: Microsoft Windows 11 Pro - Desktop
            Z-Wave Devices via two Z-Net G3s
            Zigbee Devices via RaspBee on RPi 3b+
            WiFi Devices via Internal Router.

            Enabled Plug-Ins
            AK SmartDevice 4.0.5.1,AK Weather 4.0.5.134,AmbientWeather 3.0.1.9,Big6 3.44.0.0,BLBackup 2.0.63.0,BLGData 3.0.55.0,BLLock 3.0.39.0,BLUPS 2.0.26.0,Device History 4.5.0.2,EasyTrigger 3.0.0.76,Harmony Hub 4.0.14.0,HSBuddy 4.48.707.0,JowiHue 4.1.0.3,LG ThinQ 4.0.24.4,SDJ-Health 3.1.1.4,TPLinkSmartHome4 2022.12.30.0,UltraCID3 3.0.6681.34300,Z-Wave 4.1.0.3

            Comment


              #7
              To find the device by name it uses the following case-insensitive checks, iterating over all devices and stopping on the first match - and treating devices and features the same:

              Entered string =
              Location + " " + Name AND Location <> ""
              OR Location2 + " " + Name AND Location2 <> ""
              OR Location + " " + Location2 + " " + Name
              OR Location2 + " " + Location + " " + Name
              OR Name


              So in your case you'd want to look for "Zigbee Dining Room Humidity" for maximum accuracy.

              Comment


                #8
                For the actual scripting, attached is a dump of all the public members of hsapplication - some of the new ones may be obvious, but without proper documentation it would be trial-and-error.

                HS4 scripting.txt

                The plugin documentation https://homeseer.github.io/Plugin-SD...tml?vb#methods has a lot of overlap, so some of that helps.

                For example, a nice new method which simplifies CAPI control is SendControlForFeatureByValue

                Comment


                  #9
                  tenGlobalMethods.GetFeatureRefByFullname has been updated to include an optional parameter FeatureNameOnly. If set to True, then the Featurename parameter should only be the Name without Location and Location2.

                  https://tenholder.net/tenWare2/Scrip...tallation.aspx

                  See documentation at: https://tenholder.net/tenWare2/Scrip...eRefByFullname

                  Or if you use tenScripting: https://tenholder.net/tenWare2/tenSc...tallation.aspx

                  tenholde

                  Comment

                  Working...
                  X