4

I'm using and trying the new Echo Dot generation (3rd Gen) to control a ESP8266 following some tutorials. For now I just want to change the state of a relay using the SetBinaryState action. But after discovering the device, if I try to turn it on, I get the "Device doesn't support that" response.

The tutorials I've found are for the previous generations, and the packets seem to be different, as I had to fix something in the discovery process. But I can't figure out where's the problem when setting the state as I haven't seen any documentation related to this. This is the setup.xml

"<serviceList>"
    "<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>"
"</serviceList>"

And these are the logs that I'm getting:

Received packet of size 94
From 192.168.1.3, port 50000
Request:
M-SEARCH * HTTP/1.1
Host: 239.255.255.250:1900
Man: "ssdp:discover"
MX: 3
ST: ssdp:all


Responding to search request ...

Sending response to 192.168.1.3
Port : 50000
Response sent!

Received packet of size 101
From 192.168.1.3, port 50000
Request:
M-SEARCH * HTTP/1.1
Host: 239.255.255.250:1900
Man: "ssdp:discover"
MX: 3
ST: upnp:rootdevice


Responding to search request ...

Sending response to 192.168.1.3
Port : 50000
Response sent!

Responding to setup.xml ...
Sending :<?xml version="1.0"?><root><device><deviceType>urn:Belkin:device:controllee:1</deviceType><friendlyName>Living room light</friendlyName><manufacturer>Belkin International Inc.</manufacturer><modelName>Emulated Socket</modelName><modelNumber>3.1415</modelNumber><UDN>uuid:Socket-1_0-38323636-4558-4dda-9188-cda0e616a12b</UDN><serialNumber>221517K0101769</serialNumber><binaryState>0</binaryState><serviceList><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></serviceList></device></root>

Responding to  /upnp/control/basicevent1...
Request: <?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"><BinaryState>1</BinaryState></u:GetBinaryState></s:Body></s:Envelope>

Responding to  /upnp/control/basicevent1...
Request: <?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"><BinaryState>1</BinaryState></u:GetBinaryState></s:Body></s:Envelope>

And then tons of these packets:

Received packet of size 278
From 192.168.1.1, port 1900
Request:
NOTIFY * HTTP/1.1 
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=3000
Location: http://192.168.1.1:5431/igdevicedesc.xml
SERVER: Router UPnP/1.0 miniupnpd
NT: uuid:f5c1d177-62e5-45d1-a6e7-9446962b761e
USN: uuid:f5c1d177-62e5-45d1-a6e7-9446962b76

One thing I've noticed is that the eventservice.xml never gets called, but I'm not sure if that's correct.

2

After fiddling around I figure out that it looks like you have to send the device state after every SetBinaryState request.

So, if the ESP node receives a SetBinaryState command, it will have to answer with a GetBinaryState.

void Light::_handleCommands()
{
  Serial.println("Responding to /upnp/control/basicevent...1");      

  String request = server->arg(0); 

  if (request.indexOf("SetBinaryState") >= 0) 
  {
    if (request.indexOf("<BinaryState>1</BinaryState>") >= 0) 
    {
        Serial.println(" - Got Turn on request");
        lightStatus= turnOnLight();

        sendLightStatus();
    }

    if (request.indexOf("<BinaryState>0</BinaryState>") >= 0) 
    {
        Serial.println(" - Got Turn off request");
        lightStatus= turnOffLight();

        sendLightStatus();
    }
  }

  if (request.indexOf("GetBinaryState") >= 0) 
  {
    Serial.println(" - Got light state request");

    sendLightStatus();
  }

  server->send(200, "text/plain", "");
}

On top of that, it looks that the response has to 'make sense', ie. if a Turn On request is received, it has to return '1' in the GetBinaryState. Else Alexa will say that the device is not responding or it's malfunctioning.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.