Skip to content

Instantly share code, notes, and snippets.

@jscrane
Created November 15, 2016 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jscrane/f1d96c80c1f9d1a5689b58c07554f583 to your computer and use it in GitHub Desktop.
Save jscrane/f1d96c80c1f9d1a5689b58c07554f583 to your computer and use it in GitHub Desktop.
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