Here i have made some example Autoit3 scripts to switch circles with the Plugwise Stretch 2.0, you can adjust these script easily to VB.NET or PHP!
Also on my website here: http://phoenixinteractive.mine.nu/websi ... f=27&t=117
Have fun!
Autoit3 script to switch Plugwise Circles with a Stretch 2.0 with firmware 1.0.x
Code: Select all
------------------------------------------------------------------------------
; Autoit3 script to switch Plugwise Circles with a Stretch 2.0 with firmware 1.0.x)
; v1.0, 2012-04-28 by Sebastiaan Ebeltjes
; Greetings from Deventer, The Netherlands
; ------------------------------------------------------------------------------
; Stretch 2.0 setup
Global $StretchIp = "192.168.1.102" ;The IP adres of the Stretch 2.0, like: 192.168.1.X
Global $StretchId = "STRETCHID" ; The 8 letters of the Stretch 2.0 ID
; Switch setup (circle)
Global $ApplianceId = "71abf031c54f400ca77c8ae6957ad7cf" ;The ID of the circle, look in http://[STRETCHIP]/minirest/appliances
Global $SwitchStatus = "on" ;on/off
; Kernel
Global $PostAdres = "http://" & $StretchIp & "/minirest/appliances;id=" & $ApplianceId & "/power_state=" & $SwitchStatus
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", $PostAdres, False)
$oHTTP.SetRequestHeader("Host", $StretchIp)
$oHTTP.SetRequestHeader("Authorization", "Basic " & _Base64Encode("stretch:" & $StretchId))
$oHTTP.Send()
Global $PostResponse = $oHTTP.ResponseText
If $oHTTP.Status <> "200" Then MsgBox(64, "Foutmelding", $PostResponse)
Exit
Func _Base64Encode($sData)
Local $oXml = ObjCreate("Msxml2.DOMDocument")
If Not IsObj($oXml) Then
SetError(1, 1, 0)
EndIf
Local $oElement = $oXml.createElement("b64")
If Not IsObj($oElement) Then
SetError(2, 2, 0)
EndIf
$oElement.dataType = "bin.base64"
$oElement.nodeTypedValue = Binary($sData)
Local $sReturn = $oElement.Text
If StringLen($sReturn) = 0 Then
SetError(3, 3, 0)
EndIf
Return $sReturn
EndFunc
Autoit3 script to switch Plugwise Circles with a Stretch 2.0 with firmware 2.0.x
Code: Select all
; ------------------------------------------------------------------------------
; Autoit3 script to switch Plugwise Circles with a Stretch 2.0 with firmware 2.0.x)
; v1.0, 2013-10-07 by Sebastiaan Ebeltjes
; Greetings from Deventer, The Netherlands
; ------------------------------------------------------------------------------
; Stretch 2.0 setup
Global $StretchIp = "192.168.1.102" ;The IP adres of the Stretch 2.0, like: 192.168.1.X
Global $StretchId = "STRETCHID" ; The 8 letters of the Stretch 2.0 ID
; Switch setup (circle)
Global $ApplianceId = "71abf031c54f400ca77c8ae6957ad7cf" ;The ID of the circle, look in http://[STRETCHIP]/core/appliances
Global $SwitchStatus = "on" ;on/off
; Kernel
Global $PostAdres = "http://" & $StretchIp & "/core/appliances;id=" & $ApplianceId & "/relay"
Global $PostGegevens = "<relay><state>" & $SwitchStatus & "</state></relay>"
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", $PostAdres, False)
$oHTTP.SetRequestHeader("Host", $StretchIp)
$oHTTP.SetRequestHeader("Connection", "Close")
$oHTTP.SetRequestHeader("Content-Type", "application/xml")
$oHTTP.SetRequestHeader("Authorization", "Basic " & _Base64Encode("stretch:" & $StretchId))
$oHTTP.Send($PostGegevens)
$PostResponse = $oHTTP.ResponseText
If $oHTTP.Status <> "200" Then MsgBox(64, "Foutmelding", $PostResponse)
Exit
Func _Base64Encode($sData)
Local $oXml = ObjCreate("Msxml2.DOMDocument")
If Not IsObj($oXml) Then
SetError(1, 1, 0)
EndIf
Local $oElement = $oXml.createElement("b64")
If Not IsObj($oElement) Then
SetError(2, 2, 0)
EndIf
$oElement.dataType = "bin.base64"
$oElement.nodeTypedValue = Binary($sData)
Local $sReturn = $oElement.Text
If StringLen($sReturn) = 0 Then
SetError(3, 3, 0)
EndIf
Return $sReturn
EndFunc ;_Base64Encode