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:	61
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

      Working...
      X