Announcement

Collapse
No announcement yet.

Trying to run script using ScriptName and ScriptFunc in the deviceclass object

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

    Trying to run script using ScriptName and ScriptFunc in the deviceclass object

    {"data-align":"none","data-attachmentid":"1401556","data-size":"thumb"} Has anyone used the feature to run a script whenever a device changes using the ScriptName and ScriptFunc properties in the DeviceClass object?

    I am trying to trigger a script from a device change using the ScriptName and ScriptFunc properties in the DeviceClass object to save having to put in a bunch of events (for a bunch of devices). I wrote the following little script as a test with one device:

    Sub SetDevices(Parm as Object)
    Dim hsdev As Scheduler.Classes.DeviceClass
    Dim devType
    Dim Devrf = ZMDev
    hsdev = CType(hs.GetDeviceByRef(Devrf), Scheduler.Classes.DeviceClass)
    devType = hsdev.DeviceType_Get(hs)
    devType.Device_API = HomeseerAPI.DeviceTypeInfo.eDeviceAPI.Script
    devType.Device_Type = 1 ; run on any change
    hsdev.DeviceType_Set(hs) = devType
    hsdev.ScriptName(hs) = "StatusScript.vb"
    hsdev.ScriptFunc(hs) = "DevUpdate"
    hs.SaveEventsDevices

    end sub

    And then I ran it. Based on the screenshot below it appears to have worked (the device type says it is to run a script on any change). But when the device changes, I am not getting into the script and there is nothing in the log except the normal message saying there was a device change from the CAPI handler. (I also but the full path in the ScriptName but stil no luck.

    DevUpdate, for now, is a very simple script just so I can see it is working (or not in this case):
    Public Sub DevUpdate( Parm as object)
    hs.writelog("test", "In DevUpdate")

    hs.writelog("DevUpdate", "Parm(0)="&parm(0))
    hs.writelog("DevUpdate", "Parm(1)="&parm(1))
    hs.writelog("DevUpdate", "Parm(2)="&parm(2))
    hs.writelog("DevUpdate", "Parm(3)="&parm(3))

    end sub

    Nothing shows up inthe log when I change the device from the Homeseer UI nor when the device is changed programmatically from a script. I have a bunch of devices that all need to run the same schript whern they change---this seemed so much simpler than having events for each device. Is there something simple I am doing wrong

    Click image for larger version

Name:	DevAdvStat.png
Views:	343
Size:	201.6 KB
ID:	1401558

    #2
    I can't find my post about this but this was broken at one point and I am honestly not sure if it was ever fixed, it arose at a time when I think changes were made to the event process (possibly threading). I did report it in a thread but never saw it answered either way whether it was fixed...perhaps someone who used it might be able to answer.

    Comment


      #3
      Thanks for the update. Kind of unfortunate, but I was going to write a script to set up all the devices anyway. I suppose that script, instead, could create an event for each device. Anyone out there know the status. Maybe I'll open a trouble ticket to at least find out the status.

      Comment


        #4
        Ever hear anything back? v4.1.10.0 does not work either. Seems like supporting events would be fairly important.

        Comment


          #5
          Count me in on this. Just finished setting up the Device Class to support calling a script (no small effort, btw), and then I found this thread. SO FRUSTRATING! I get the same result. I get a log message from the CAPI Control Handler, but the script is never called. Ugh.

          The frustration is not only that it doesn't work, but the workaround is to create a bunch of separate events - each associated with a child device (I have several child devices). I can write a script to create all the events, but it's such an ugly workaround. I'm going to pollute my "Events" list with a bunch of crud that didn't need to be there. Sigh.

          Comment


            #6
            This is why God created Event Groups and Event Types. Should help a little with the clutter.


            Jim Speiser
            38-year veteran of Home Automation
            Still don't know squat

            Comment


              #7
              Thanks for the encouragement . I see that God also created RegisterStatusChangeCB which seems like a really big hammer for this particular nail, but it appeals to my inner control freak. There's something enticing about being able to sniff every device change in the system . Thanks for the info. I keep learning as I go here.

              Comment

              Working...
              X