Created
November 15, 2016 18:38
-
-
Save jscrane/f1d96c80c1f9d1a5689b58c07554f583 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
wemo_get() | |
{ | |
local host=$1 | |
cat << EOF | | |
<?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:GetBinaryState xmlns:u="urn:Belkin:service:basicevent:1"/> | |
</s:Body> | |
</s:Envelope> | |
EOF | |
curl -A '' -X POST \ | |
-H 'Content-type: text/xml; charset="utf-8"' \ | |
-H 'SOAPACTION: "urn:Belkin:service:basicevent:1#GetBinaryState"' \ | |
-s http://$host:49153/upnp/control/basicevent1 \ | |
-d@- 2>&1 | sed -n 's/<BinaryState>\(.\)<\/BinaryState>/\1/p' | |
} | |
wemo_set() | |
{ | |
local host=$1 | |
local value=$2 | |
cat << EOF | | |
<?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:SetBinaryState xmlns:u="urn:Belkin:service:basicevent:1"> | |
<BinaryState>$value</BinaryState> | |
</u:SetBinaryState> | |
</s:Body> | |
</s:Envelope> | |
EOF | |
curl -A '' -X POST \ | |
-H 'Content-type: text/xml; charset="utf-8"' \ | |
-H 'SOAPACTION: "urn:Belkin:service:basicevent:1#SetBinaryState"' \ | |
-s http://$host:49153/upnp/control/basicevent1 \ | |
-o /dev/null \ | |
-d@- | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment