Announcement

Collapse
No announcement yet.

An "immediate script" event and HS-structured-interface don't do the same thing

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

    An "immediate script" event and HS-structured-interface don't do the same thing

    I am new to forum culture and technology, so please excuse my errors.


    I am trying to set a Fibaro relay zwave device (called "Windows GrOffice Upper Open", RefID=231) to be turned on by an event. The Fibaro relay causes a motorized window to open, I think that is incidental.


    For other reasons, I would like to do this with a script line. I can make it work perfectly with an event defined using a "Set Device" action (see A below).


    However, when I try to do what seems like should be the same thing with a script phrase (see B below), it does not work, by which I mean it does not actuate the Fibaro relay. (231=RefId of the device and 255 is the "ON" value.)



    I have set up the two cases to be manually triggered to eliminate some subtlety in the triggering and conditions.


    In both cases the target device shows change of status and graphics. That seem identical, but the Fibaro relay is only closed with the former approach.



    Does anyone have an idea why these two apparently equivalent approaches do not work the same?


    Thanks in advance for any insight.




    Log results of running A then B:
    Click image for larger version

Name:	HS log.jpg
Views:	1
Size:	167.8 KB
ID:	1212825
    Attached Files
    Last edited by quinn; July 21, 2018, 09:51 PM. Reason: image entry error

    #2
    Setting a devices value with hs.setdevicevaluebyref (or any of the associated commands) will only set the HS device to that value. The plugin may not and probably will not know about that change in value to do anything about it.

    To control a device from a script then you need to look at the HS control API, otherwise referred to as CAPI. It is quite well documented now and I believe tenholde has a tool that probably would help you shortcut the guesswork and get a scripting command straight away. Failing that look at help file - http://help.homeseer.com/help/HS3/st...ce_control_api

    I would imagine that you would need something like this;

    hs.CAPIControlHandler(hs.CAPIGetSingleControl(231, True, "On", False, False))

    Comment


      #3
      The script statement you have only affects the virtual device, or representation in the HS3 application. In order to change the physical device, you need to perform some extra steps. See the section on "Device Control API (CAPI)" in the HS3 help file. Here is some code that sets a volume virtual device, then performs the CAPI stuff to set the actual device.

      Code:
              hs.SetDeviceValueByRef(devRef, vol, False)
              Dim cc As HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(devRef, True, "Volume (value)%", False, False)
              cc.ControlValue = vol
              Dim cr As HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)

      Comment


        #4
        Thanks to both zwolfpack and mrhappy ... I thought that it must be something like that ... will run down the CAPI road and get back with a report and hopefully a detailed solution.
        Last edited by quinn; July 22, 2018, 05:58 PM. Reason: typo

        Comment


          #5
          Originally posted by quinn View Post
          Thanks to both zwolfpack and mrhappy ... I thought that it must be something like ... will run down the CAPI road and get back with a report and hopefully a detailed solution.
          Be sure to check out Ed's tenScriptAid tool. It makes constructing CAPI code quick and pretty easy.
          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


            #6
            Thank you gentlemen. Both of your solutions worked perfectly.


            I spent some time reading and trying to understand the external device interface called CAPI as presented in the User Documentation . It is a bit under-explained and rather complex, but I think I have got the gist of it.


            Needless to say, your examples specifically referencing my issue were of immense value, if not essential. to my getting on.


            There are one or two questions arising from your examples if you have time to comment:
            • I missed the documentation of the HomeSeerAPI object hierarchy implied by the expression "HomeSeerAPI.CAPI.CapiControl". It only turns up in the HomeSeer HS3 - End User Document in relationship to LogEntry. Is this documented elsewhere in more detail?
            • The method "CapiGetSingleControl" has a third parameter called "Label", a String. I gather this refers to the "Status" string defined in the Status Graphics tab of the device's detail page. Some of the fields in these tabs are self apparent, but there again I can find no specific documentation or description of these. Exactly how "Value" relates to "Status"/"Label" and which drives which, I don't understand.

            I really don't know the etiquette of forums, so if I have exceeded the bounds allowed by these additional questions, I apologize.



            Finally, a word of explanation: what I am hoping to accomplish here is to learn enough to do a respectable job of configuring my installation anew in HS3, having abandoned Vera 3 a three months ago. As a point of interest, my objective now is to eliminate a lot of repetitive event coding by passing parameters into a few scripts which can be more easily maintained than a dozen or so essentially duplicate events defined in the what I call the conventional structured event interface. Any thoughts on that would be appreciated.

            Comment


              #7
              Originally posted by Uncle Michael View Post
              Be sure to check out Ed's tenScriptAid tool. It makes constructing CAPI code quick and pretty easy.
              The tenScrip tool looks interesting and thanks for mentioning. Will keep it in mind for when I get the basics of scripting under control.

              Comment

              Working...
              X