Announcement

Collapse
No announcement yet.

Having trouble set API device with script

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

    Having trouble set API device with script

    I have a arduino API output created and it turns on and off correctly from the device management screen.

    I can't figure out how to turn it on and off from a script.

    Here is the script (vbs)

    **********************
    ' this code toggles the devices ArduinoDevice and VirtualDevice each time it is run

    sub main
    ArduinoDevice = "Arduino Devices Arduino Plugin Board:3, API output:0"
    VirtualDevice = "Virtual Virtual dummy"

    ' This does not work using the Arduino device
    dvRef = hs.GetDeviceRefByName(ArduinoDevice) ' this does return a correct device ref
    dvRef2 = hs.GetDeviceRefByName(VirtualDevice)
    if hs.IsOn(dvRef) then
    hs.CAPIControlHandler(hs.CAPIGetSingleControl(dvRef,True,"Of f",False,False)) 'turn device off
    else
    hs.CAPIControlHandler(hs.CAPIGetSingleControl(dvRef,True,"On ",False,False)) 'turn device on
    end if

    ' same code works with the virtual device
    if hs.IsOn(dvRef2) then
    hs.CAPIControlHandler(hs.CAPIGetSingleControl(dvRef2,True,"O ff",False,False)) 'turn device off
    hs.writelog "debug", "Off"
    else
    hs.CAPIControlHandler(hs.CAPIGetSingleControl(dvRef2,True,"O n",False,False)) 'turn device on
    hs.writelog "debug", "On"
    end if

    end sub

    **********
    The script runs with no errors. In the log, it shows that an event was run which ran the script. It also says that the virtual virtual dummy device was set. Nothing about the arduino device.

    #2
    I think HS.ISON is your problem.

    Try setting the device value pairs for on and off and off then set the control use for them and it should work but I would just check for the on value you are looking for.

    Greig.
    Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
    X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
    Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
    Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
    Scripts =
    Various

    Comment


      #3
      Originally posted by enigmatheatre View Post
      I think HS.ISON is your problem.

      Try setting the device value pairs for on and off and off then set the control use for them and it should work but I would just check for the on value you are looking for.

      Greig.
      The hs.ison was the problem. I approached the problem from another direction and it is now all working.

      Comment

      Working...
      X