Last active
January 25, 2016 04:22
-
-
Save bkeifer/15e4b9ef2519dbdbeb2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
THIS WORKS: | |
------------------ | |
curl -X POST -H 'Accept: */*' -H 'Content-type: text/xml; charset=utf-8' -H 'SOAPAction: "urn:Belkin:service:deviceevent:1#SetAttributes"' -d '<?xml version="1.0" encoding="utf-8"?> | |
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> | |
<s:Body> | |
<u:SetAttributes xmlns:u="urn:Belkin:service:deviceevent:1"> | |
<attributeList><attribute><name>FanMode</name><value>2</value></attribute><attribute><name>DesiredHumidity</name><value>NULL</value></attribute><attribute><name>CurrentHumidity</name><value>NULL</value></attribute><attribute><name>WaterAdvise</name><value>NULL</value></attribute><attribute><name>NoWater</name><value>NULL</value></attribute><attribute><name>FilterLife</name><value>NULL</value></attribute><attribute><name>ExpiredFilterTime</name><value>NULL</value></attribute></attributeList> | |
</u:SetAttributes> | |
</s:Body> | |
</s:Envelope>' http://humidifier.lan:$1/upnp/control/deviceevent1 | |
THIS DOESN'T: | |
------------------ | |
def body = """ | |
<?xml version="1.0" encoding="utf-8"?> | |
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> | |
<s:Body> | |
<u:SetAttributes xmlns:u="urn:Belkin:service:deviceevent:1"> | |
<attributeList><attribute><name>FanMode</name><value>1</value></attribute><attribute><name>DesiredHumidity</name><value>NULL</value></attribute><attribute><name>CurrentHumidity</name><value>NULL</value></attribute><attribute><name>WaterAdvise</name><value>NULL</value></attribute><attribute><name>NoWater</name><value>NULL</value></attribute><attribute><name>FilterLife</name><value>NULL</value></attribute><attribute><name>ExpiredFilterTime</name><value>NULL</value></attribute></attributeList> | |
</u:SetAttributes> | |
</s:Body> | |
</s:Envelope> | |
""" | |
postRequest('/upnp/control/deviceevent1', 'urn:Belkin:service:deviceevent:1#SetAttributes', body) | |
private postRequest(path, SOAPaction, body) { | |
// Send a post request | |
def result = new physicalgraph.device.HubAction([ | |
'method': 'POST', | |
'path': path, | |
'body': body, | |
'headers': [ | |
'HOST': getHostAddress(), | |
'Content-type': 'text/xml; charset=utf-8', | |
'SOAPAction': "\"${SOAPaction}\"" | |
] | |
], device.deviceNetworkId) | |
log.debug "RESULT: ${result}" | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment