Announcement

Collapse
No announcement yet.

Need scripting to toggle device please

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

  • Need scripting to toggle device please

    With the new CAPI stuff I'm at a total lose as to how to accomplish this.

    I would like a script that can toggle a device based on it's current status.

    Example:
    I use BLControl with NFC, when I put my phone next to a NFC Sticker it can turn a device on or off. What I would like is a script that I can tell it to run that would get the device status and then do the opposite. If it's on, turn it off kind of thing.

    Basically:

    Get device status (on/off)
    if device = on then
    set device = off
    writelog "Turning device off"
    elseif device = off
    set device = on
    writelog "Turning device on"
    else
    writelog "I didn't understand status"
    end if


    I'm pretty good at modifying stuff but to start from scratch, I've got no clue.

    Thanks.
    Bryan
    Software/Hardware: Win10 Pro, HS 3 Pro, HS Touch, Echo, Edgeport/4, Z-Net w/88 Devices, Insteon PLM w/19 Devices, Nest, GC-100-6, W800RF32A, WS-2080 Weather Station (KMADRACU10)
    Plug-in/Scripts: Alexa API, BLBackup, BLGData, BLLED, BLLock, BLRF, BLTVGuide, Blue Iris, BLUPS, Current Cost 3P, DirectTV, FitbitSeer, Insteon, Nest, Pushover 3P, Random, Restart, Tasker, UltraGCIR3, UltraWeatherWU, Z-Wave

  • #2
    Try this ists a copy from tenscripting
    PHP Code:
       Public Sub Main(ByVal Parms As String)
            
    ''
            '' 
    Toggle the Specified Device ON/OFF
            
    ''   DIM is considered ON
            
    ''
            '' 
    Specify the Device Nameincluding Locations, as a Parm
            Dim devValue 
    As Double
            Dim theDevice 
    As String

            
    '' Get Device from the Parms
            theDevice 
    Parms.ToString
            
    '' Get the Device Status
            devValue 
    hs.DeviceValueByName(theDevice)
            
    '' Toggle it
            Select 
    Case devValue
                
    Case Is 0
                    
    '' Device ON or DIMturn it OFF
                    hs
    .SetDeviceValueByName(theDevice0)
                Case 
    0
                    
    '' Device OFFturn it ON
                    hs
    .SetDeviceValueByName(theDevice100)
            
    End Select
        End Sub 
    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
      I just got that question answered here ya go:
      http://board.homeseer.com/showthread.php?t=168359

      Comment


      • #4
        You guys are awesome! Thank you very much. Just in case the other post disappears over time. I'll post the code here too.

        Just use the device Reference ID as the Parameter when running this script.

        PHP Code:
        Sub Main(ByVal theDevice As String)
            
        ''
            '' 
        Toggle the Specified Device ON/OFF
            
        '' DIM is considered ON
            
        ''
            '' 
        Specify the Device Nameincluding Locations, as a Parm
            Dim devValue 
        As Double
            
        ''

            '' 
        Get the Device Status
            devValue 
        hs.DeviceValue(theDevice)
            
        '' Toggle it
            Select 
        Case devValue
            
        Case Is 0
                
        '' Device ON or DIMturn it OFF 
                hs
        .CAPIControlHandler(hs.CAPIGetSingleControl(theDevice,true ,"off",false,true))
            Case 
        0
                
        '' Device OFFturn it ON
                hs
        .CAPIControlHandler(hs.CAPIGetSingleControl(theDevice,true ,"on",false,true))
            
        End Select
        End Sub 
        Thanks again!
        Bryan
        Software/Hardware: Win10 Pro, HS 3 Pro, HS Touch, Echo, Edgeport/4, Z-Net w/88 Devices, Insteon PLM w/19 Devices, Nest, GC-100-6, W800RF32A, WS-2080 Weather Station (KMADRACU10)
        Plug-in/Scripts: Alexa API, BLBackup, BLGData, BLLED, BLLock, BLRF, BLTVGuide, Blue Iris, BLUPS, Current Cost 3P, DirectTV, FitbitSeer, Insteon, Nest, Pushover 3P, Random, Restart, Tasker, UltraGCIR3, UltraWeatherWU, Z-Wave

        Comment

        Working...
        X