4

Looking for some API docs on querying & control of Belkin Wemo switches/plugs.

I have discovery working but can't seem to find any concise documentations describing how to do much else.

I can see discovery events & process the xml details:

HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Sat, 21 Sep 2019 05:11:35 GMT
EXT:
LOCATION: http://[IP]:49153/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: [ID]
SERVER: Unspecified, UPnP/1.0, Unspecified
X-User-Agent: redsonic
ST: urn:Belkin:service:basicevent:1
USN: uuid:Lightswitch-1_0-[ID]::urn:Belkin:service:basicevent:1

What do I do with these? :

<?xml version="1.0" encoding="UTF-8"?>
<serviceList>
    <service>
        <serviceType>urn:Belkin:service:WiFiSetup:1</serviceType>
        <serviceId>urn:Belkin:serviceId:WiFiSetup1</serviceId>
        <controlURL>/upnp/control/WiFiSetup1</controlURL>
        <eventSubURL>/upnp/event/WiFiSetup1</eventSubURL>
        <SCPDURL>/setupservice.xml</SCPDURL>
    </service>
    <service>
        <serviceType>urn:Belkin:service:timesync:1</serviceType>
        <serviceId>urn:Belkin:serviceId:timesync1</serviceId>
        <controlURL>/upnp/control/timesync1</controlURL>
        <eventSubURL>/upnp/event/timesync1</eventSubURL>
        <SCPDURL>/timesyncservice.xml</SCPDURL>
    </service>
    <service>
        <serviceType>urn:Belkin:service:basicevent:1</serviceType>
        <serviceId>urn:Belkin:serviceId:basicevent1</serviceId>
        <controlURL>/upnp/control/basicevent1</controlURL>
        <eventSubURL>/upnp/event/basicevent1</eventSubURL>
        <SCPDURL>/eventservice.xml</SCPDURL>
    </service>
    <service>
        <serviceType>urn:Belkin:service:firmwareupdate:1</serviceType>
        <serviceId>urn:Belkin:serviceId:firmwareupdate1</serviceId>
        <controlURL>/upnp/control/firmwareupdate1</controlURL>
        <eventSubURL>/upnp/event/firmwareupdate1</eventSubURL>
        <SCPDURL>/firmwareupdate.xml</SCPDURL>
    </service>
    <service>
        <serviceType>urn:Belkin:service:rules:1</serviceType>
        <serviceId>urn:Belkin:serviceId:rules1</serviceId>
        <controlURL>/upnp/control/rules1</controlURL>
        <eventSubURL>/upnp/event/rules1</eventSubURL>
        <SCPDURL>/rulesservice.xml</SCPDURL>
    </service>
    <service>
        <serviceType>urn:Belkin:service:metainfo:1</serviceType>
        <serviceId>urn:Belkin:serviceId:metainfo1</serviceId>
        <controlURL>/upnp/control/metainfo1</controlURL>
        <eventSubURL>/upnp/event/metainfo1</eventSubURL>
        <SCPDURL>/metainfoservice.xml</SCPDURL>
    </service>
    <service>
        <serviceType>urn:Belkin:service:remoteaccess:1</serviceType>
        <serviceId>urn:Belkin:serviceId:remoteaccess1</serviceId>
        <controlURL>/upnp/control/remoteaccess1</controlURL>
        <eventSubURL>/upnp/event/remoteaccess1</eventSubURL>
        <SCPDURL>/remoteaccess.xml</SCPDURL>
    </service>
    <service>
        <serviceType>urn:Belkin:service:deviceinfo:1</serviceType>
        <serviceId>urn:Belkin:serviceId:deviceinfo1</serviceId>
        <controlURL>/upnp/control/deviceinfo1</controlURL>
        <eventSubURL>/upnp/event/deviceinfo1</eventSubURL>
        <SCPDURL>/deviceinfoservice.xml</SCPDURL>
    </service>
    <service>
        <serviceType>urn:Belkin:service:smartsetup:1</serviceType>
        <serviceId>urn:Belkin:serviceId:smartsetup1</serviceId>
        <controlURL>/upnp/control/smartsetup1</controlURL>
        <eventSubURL>/upnp/event/smartsetup1</eventSubURL>
        <SCPDURL>/smartsetup.xml</SCPDURL>
    </service>
    <service>
        <serviceType>urn:Belkin:service:manufacture:1</serviceType>
        <serviceId>urn:Belkin:serviceId:manufacture1</serviceId>
        <controlURL>/upnp/control/manufacture1</controlURL>
        <eventSubURL>/upnp/event/manufacture1</eventSubURL>
        <SCPDURL>/manufacture.xml</SCPDURL>
    </service>
</serviceList>
Status3543
  • 153
  • 1
  • 6

2 Answers2

3

I have a collection of blog posts talking about reverse engineering the WeMo protocol here: https://www.hardill.me.uk/wordpress/tag/wemo/

My work was initially with the WeMo lighting products but I also get sockets working as well. There is NodeJS module I wrote to use as the code of my Node-RED node that even covers subscribing to event notifications from the smarter power monitoring socket.

WeMo devices all use SOAP for control and are self describing because they serve up the entrypoint into the schema in the discovery response. From this you can walk all the endpoints and get a description of what the inputs to those endpoints need to be.

hardillb
  • 12,813
  • 1
  • 21
  • 34
1

Credit to @hardillb for pointing me in the right direction. Here's a basic message structure for control:

POST /upnp/control/basicevent1
SOAPACTION: "urn:Belkin:service:basicevent:1#SetBinaryState"
Content-Type: text/xml; charset="utf-8"
Accept: */*
User-Agent: PostmanRuntime/7.15.2
Cache-Control: no-cache
Host: [DEVICE_IP]:49153
Accept-Encoding: gzip, deflate
Content-Length: 306
Connection: keep-alive

<?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>0</BinaryState>
        </u:SetBinaryState>
    </s:Body>
</s:Envelope>

HTTP/1.1 200
status: 200
CONTENT-LENGTH: 289
CONTENT-TYPE: text/xml; charset="utf-8"
DATE: Tue, 24 Sep 2019 13:47:09 GMT
EXT:
SERVER: Unspecified, UPnP/1.0, Unspecified
X-User-Agent: redsonic

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <s:Body>
        <u:SetBinaryStateResponse xmlns:u="urn:Belkin:service:basicevent:1">
            <BinaryState>0</BinaryState>
            <CountdownEndTime>0</CountdownEndTime>
            <deviceCurrentTime>1569333003</deviceCurrentTime>
        </u:SetBinaryStateResponse>
    </s:Body>
</s:Envelope>
Status3543
  • 153
  • 1
  • 6