OpenHAB2 not receiving notification from WeMo correctly

No, no changes… i yesterday changed from CR+LF in LF… no changes :frowning:

Please try it, as I want to see what the trace log shows then.

Please, check my last log (nr. 5) i uploaded on my GoogleDrive: I send 0, and 1, with CR+LF added, as you request.

Something is strange:
When 0 send, there is line:

2017-08-31 23:11:15.061 [DEBUG] [ome.binding.wemo.handler.WemoHandler] - Received pair 'BinaryState':'false' (service 'basicevent1') for thing 'wemo:socket:Socket-1_0-221517K0101707'

but, this line missing when 1 is send???

Cannot open your last logs

Sorry… it was be opened on my computer… try now

Still only garbage :frowning:

Not shure if it might solve the issue, but within WeMo binding, I would use the following to bild the urlParameters:

    String urlParameters = "<?xml version=\"1.0\"?>"
           + "<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">"
           + "<e:property>"
           + "<BinaryState>" + binState + "</BinaryState>"
           + "</e:property>"
           + "</e:propertyset>";

It’s looks like you are right, maybe something is wrong in JUPnP, not in WeMo binding :frowning:
Maybe JUPnP not sending good parameters to the wemo binding… who knows why…

As it is working for real WeMo devices and other UPnP enabled ones, I am afraid, it is something within your code :frowning:

Oh, i forget to ask you, it is tested and working for real device? Aaaahhh… thanks for that info! Now, i know for shure, the problem is in my code… but i don’t know where :frowning:

Now, i found in log:

2017-08-31 23:41:22.406 [TRACE] [pnp.transport.spi.GENAEventProcessor] - ===================================== GENA BODY BEGIN ============================================
2017-08-31 23:41:22.407 [TRACE] [pnp.transport.spi.GENAEventProcessor] - <?xml version="1.0"?><e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0"><e:property><BinaryState>1</BinaryState></e:property></e:propertyset>
2017-08-31 23:41:22.408 [TRACE] [pnp.transport.spi.GENAEventProcessor] - -===================================== GENA BODY END ============================================
2017-08-31 23:41:22.411 [TRACE] [pnp.transport.spi.GENAEventProcessor] - Reading state variable value: BinaryState
2017-08-31 23:41:22.413 [TRACE] [g.jupnp.protocol.sync.ReceivingEvent] - Calling active subscription with event state variable values
2017-08-31 23:41:22.413 [TRACE] [org.jupnp.transport.spi.UpnpStream  ] - Protocol returned response: (OutgoingEventResponseMessage) 200 OK
2017-08-31 23:41:22.414 [TRACE] [org.jupnp.transport.spi.UpnpStream  ] - Preparing HTTP response message: (OutgoingEventResponseMessage) 200 OK
2017-08-31 23:41:22.414 [DEBUG] [ome.binding.wemo.handler.WemoHandler] - Received pair 'BinaryState':'true' (service 'basicevent1') for thing 'wemo:socket:Socket-1_0-221517K0101707'
2017-08-31 23:41:22.414 [TRACE] [org.jupnp.transport.spi.UpnpStream  ] - Sending HTTP response status: 200
2017-08-31 23:41:22.416 [DEBUG] [org.eclipse.jetty.server.HttpChannel] - HttpChannelOverHttp@1ddda00{r=1,c=false,a=ASYNC_WOKEN,uri=/upnpcallback/dev/Socket-1_0-221517K0101707/svc/Belkin/basicevent1/event/cb} handle enter
2017-08-31 23:41:22.417 [DEBUG] [clipse.jetty.server.HttpChannelState] - HttpChannelState@11d6337{s=ASYNC_WOKEN i=false a=COMPLETE} handling ASYNC_WOKEN
2017-08-31 23:41:22.419 [DEBUG] [np.transport.impl.async.AsyncServlet] - AsyncListener.onComplete(): id: 614, duration:   79, response: HTTP/1.1 200 
Date: Thu, 31 Aug 2017 21:41:22 GMT
Content-Type: text/xml


2017-08-31 23:41:22.420 [TRACE] [org.jupnp.transport.spi.UpnpStream  ] - Completed asynchronous processing of HTTP request: Request[NOTIFY /upnpcallback/dev/Socket-1_0-221517K0101707/svc/Belkin/basicevent1/event/cb]@20298e
2017-08-31 23:41:22.416 [DEBUG] [ome.binding.wemo.handler.WemoHandler] - State 'ON' for device 'wemo:socket:Socket-1_0-221517K0101707' received
2017-08-31 23:41:22.422 [DEBUG] [.eclipse.jetty.server.HttpConnection] - org.eclipse.jetty.server.HttpConnection$SendCallback@687284[PROCESSING][i=null,cb=Blocker@19c2423{null}] generate: FLUSH (null,[p=0,l=188,c=32768,r=188],false)@COMMITTED
2017-08-31 23:41:22.422 [DEBUG] [.eclipse.jetty.server.HttpConnection] - org.eclipse.jetty.server.HttpConnection$SendCallback@f1878e[PROCESSING][i=ResponseInfo{HTTP/1.1 200 null,-1,false},cb=org.eclipse.jetty.server.HttpChannel$CommitCallback@178102c] generate: NEED_HEADER (null,[p=0,l=0,c=0,r=0],true)@START
2017-08-31 23:41:22.423 [DEBUG] [org.eclipse.jetty.io.WriteFlusher   ] - write: WriteFlusher@1e818f7{IDLE} [HeapByteBuffer@18677ec[p=0,l=6,c=1024,r=6]={<<<\r\nBC\r\n>>>\n\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00},HeapByteBuffer@b6f3d2[p=0,l=188,c=32768,r=188]={<<<event: message\nda...usInfoEvent"}\n\n>>>"}\n\n}\n\n.47-.76.34...\xFf\xF4%\xEfrr\xE3\x86^\x11L\x8cNP\x9e}]
2017-08-31 23:41:22.423 [DEBUG] [.eclipse.jetty.server.HttpConnection] - org.eclipse.jetty.server.HttpConnection$SendCallback@f1878e[PROCESSING][i=ResponseInfo{HTTP/1.1 200 null,-1,false},cb=org.eclipse.jetty.server.HttpChannel$CommitCallback@178102c] generate: FLUSH ([p=0,l=132,c=8192,r=132],[p=0,l=0,c=0,r=0],true)@COMPLETING
2017-08-31 23:41:22.425 [DEBUG] [org.eclipse.jetty.io.WriteFlusher   ] - write: WriteFlusher@600576{IDLE} [HeapByteBuffer@35ca89[p=0,l=132,c=8192,r=132]={<<<HTTP/1.1 200 OK\r\n....v20160908)\r\n\r\n>>> text/xml; charse...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}]
201

So, state is regularly read (true and false) but something went wrong in processing readed state… I don’t know how stuff work in openHAB, so can’t solve this problem myself for now… but who know… i’m enough crazy, maybe a will solve that one day :wink:
For now, I’m not giving up! :slight_smile:

Hey, what about setup.xml and eventservice.xml? Maybe i wrote something wrong there? look this part of code which generate eventservice.xml:

  body += "    <stateVariable sendEvents=\"yes\">\r\n";
  body += "      <name>BinaryState</name>\r\n";
  body += "       <dataType>Boolean</dataType>\r\n";
  body += "       <defaultValue>0</defaultValue>\r\n";
  body += "     </stateVariable>\r\n";

Maybe, this no need to be Boolean type???

Yeaaahhhh!!!
That solved my problem!
I spent 20 days for one variable! And i waste your time all day!!! :frowning: Sorry for that, but without you and your sugsestion (how can i track logs, for example) and which class is responsible for receiving and which for executing received data (this give me a clue about dataflow, and give me an idea about changing variable type), i probably never have solve problem!!!

Those words have led me to a solution!

THANK YOU SO MUCH, AND SORRY FOR WASTING YOUR TIME!!!

Glad you solved it and I could be of help.

I have not the same problem but (I think a similar one).
I build an Arduino ESP8266 to emulate a wemo switch with this this library. Now I can switch it on and off with alexa (no openhab skill activated) but can not find it with your WeMo binding.
As I understand it, it uses UPNP too.

As I am not a developer, I don’t know how I could fix this :see_no_evil:

OK, i know for this problem, i have same. Well, i don’t know why, but for Alexa, and for WeMo binding in openHAB must be diferent UPnP response. For example, in my program (for ESP8266, in Arduino IDE) there is two line if you wish to Alexa can found your device:

Udp.write("ST: urn:Belkin:device:**\r\n");  // For Alexa
Udp.write("::urn:Belkin:device:**\r\n");    //  For Alexa

And, this two linest must be:

Udp.write("ST: urn:Belkin:device:controllee:1\r\n");
Udp.write("::urn:Belkin:device:**\r\n"); 

if you wish to Wemo binding can discover your device. I use Wemo binding in openHAB, and expose WeMo switch from openHAB, then Alexa see my switch via openHAB :slight_smile:

But, i don’t use this library, i use example fauxmo from makermusings and witnessmenow/esp8266-alexa-wemo-emulator, on github.

Thanks for the fast reply :slight_smile:
In which file can I find those to lines in the library by witnessmenow?

Sorry for wait… i am not home at the moment, i will post you code as sun as i come back.

As i promised, here is the code i used for my ESP8266, that works well with Alexa and openHAB, but not at same time. This code is for openHAB. For Alexa, you must comment 2 lines with remark “for openHAB” and uncoment 2 lines marked “for Alexa”. As i say before, better solution is to make ESP8266 to work with openHAB, and in openHAB make WeMo exposed to other device (then Alexa can see your WeMo made of ESP8266). Don’t forget to enter your network name and password in the code before compile!
This code is for Arduino IDE, from torinnguyen and aneisch, but i modified some lines for me, so the switch now can send response to question about state (GetStateResponse). I try, in the future, to implement capability for sending NOTIFY messages, so openHAB can know instantly when switch change state (for example, you manually turn ON or OFF the switch). As you can see in my correspondence with hmerk, I had a problem in sending NOTIFY routine, but this is now solwed and i currently know exactly what i have to do, i just need some time :slight_smile:

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <WiFiUDP.h>

const char* ssid = "xxx";                       // your network SSID (name)
const char* pass = "xxx";                     // your network password

const char* friendlyName = "Socket 1";                        // Alexa will use this name to identify your device
const char* serialNumber = "221517K0101788";                  // anything will do
const char* uuid = "904bfa3c-1de2-11v2-8728-fd8eebaf492d";    // anything will do

// Multicast declarations
IPAddress ipMulti(239, 255, 255, 250);
const unsigned int portMulti = 1900;
const unsigned int webserverPort = 9876;

// Witty Cloud Board specifc pins
const int LED_PIN = 4;


//-----------------------------------------------------------------------
//-----------------------------------------------------------------------

//int status = WL_IDLE_STATUS;

WiFiUDP Udp;
byte packetBuffer[1024]; //buffer to hold incoming and outgoing packets

ESP8266WebServer server(webserverPort);


//-----------------------------------------------------------------------
// UDP Multicast Server
//-----------------------------------------------------------------------

char* getDateString()
{
  //Doesn't matter which date & time, will work
  //Optional: replace with NTP Client implementation
  return "Wed, 29 Jun 2017 00:13:46 GMT";
}

void responseToSearchUdp(IPAddress& senderIP, unsigned int senderPort) 
{
  Serial.println("responseToSearchUdp");

  //This is absolutely neccessary as Udp.write cannot handle IPAddress or numbers correctly like Serial.print
  IPAddress myIP = WiFi.localIP();
  char ipChar[20];
  snprintf(ipChar, 20, "%d.%d.%d.%d", myIP[0], myIP[1], myIP[2], myIP[3]);
  char portChar[7];
  snprintf(portChar, 7, ":%d", webserverPort);

  char sipChar[20];
  snprintf(sipChar, 20, "%d.%d.%d.%d", senderIP[0], senderIP[1], senderIP[2], senderIP[3]);
  char sportChar[7];
  snprintf(sportChar, 7, ":%d", senderPort);
  
  Udp.beginPacket(senderIP, senderPort);
  Udp.write("HTTP/1.1 200 OK\r\n");
  Udp.write("CACHE-CONTROL: max-age=86400\r\n");
  Udp.write("DATE: ");
  Udp.write(getDateString());
  Udp.write("\r\n");
  Udp.write("EXT:\r\n");
  Udp.write("LOCATION: ");
  Udp.write("http://");
  Udp.write(ipChar);
  Udp.write(portChar);
  Udp.write("/setup.xml\r\n");
  Udp.write("OPT: \"http://schemas.upnp.org/upnp/1/0/\"); ns=01\r\n");
  Udp.write("01-NLS: ");
  Udp.write(uuid);
  Udp.write("\r\n");
  Udp.write("SERVER: Unspecified, UPnP/1.0, Unspecified\r\n");
  Udp.write("X-User-Agent: redsonic\r\n");
  Udp.write("ST: urn:Belkin:device:controllee:1\r\n");  // This is for openHAB
//  Udp.write("ST: urn:Belkin:device:**\r\n");          // This is for Alexa
  Udp.write("USN: uuid:Socket-1_0-");
  Udp.write(serialNumber);
  Udp.write("::urn:Belkin:device:controllee:1\r\n");  // This is for openHAB
//  Udp.write("::urn:Belkin:device:**\r\n");          // This is for Alexa
  Udp.write("\r\n");
  Udp.endPacket();

  Serial.print("Lokacija=");
  Serial.print("http://");
  Serial.print(ipChar);
  Serial.print(portChar);
  Serial.println("/setup.xml");
  Serial.print("IP adresa prozivaoca: ");
  Serial.print(sipChar);
  Serial.println(sportChar);
  Serial.println("");
}

void UdpMulticastServerLoop()
{
  int numBytes = Udp.parsePacket();
  if (numBytes <= 0)
    return;

  IPAddress senderIP = Udp.remoteIP();
  unsigned int senderPort = Udp.remotePort();
  
  // read the packet into the buffer
  Udp.read(packetBuffer, numBytes); 

  // print out the received packet
  // ovo iskljuciti posle debagovanja

  // check if this is a M-SEARCH for WeMo device
  String request = String((char *)packetBuffer);
  int mSearchIndex = request.indexOf("M-SEARCH");
  int mBelkinIndex = request.indexOf("urn:Belkin:device:");   //optional
  int mAllIndex    = request.indexOf("ssdp:all");             //optional

  if (mSearchIndex < 0 && mBelkinIndex < 0 && mAllIndex <0)
    return;

  // send a reply, to the IP address and port that sent us the packet we received
  Serial.println("Prozivka:::::::::::");
  Serial.write(packetBuffer, numBytes);
  Serial.println("!!!!!!!!!!!!!!Odgovoricemo na prozivku!!!!!!!!!!");
  Serial.println("");
  responseToSearchUdp(senderIP, senderPort);
}


//-----------------------------------------------------------------------
// HTTP Server
//-----------------------------------------------------------------------

void handleRoot() 
{
  Serial.println("handleRoot");
  Serial.println("");
  server.send(200, "text/plain", "Tell Alexa to discover devices");
}


void handleSetupXml()
{
  Serial.println("handleSetupXml");
    
  String body = "<?xml version=\"1.0\"?>\r\n";
  body += "<root xmlns=\"urn:Belkin:device-1-0\">\r\n";
//  body +=  <root xmlns=\"urn:schemas-upnp-org:device-1-0\">\r\n";
  body += "  <device>\r\n";
  body += "    <deviceType>urn:Belkin:device:controllee:1</deviceType>\r\n";
//  body += "    <deviceType>urn:Belkin:device:socket:1</deviceType>\r\n";
//  body += "    <deviceType>urn:Belkin:device:lightswitch:1</deviceType>\r\n";
  body += "    <friendlyName>";
  body += friendlyName;
  body += "</friendlyName>\r\n";
  body += "    <manufacturer>Belkin International Inc.</manufacturer>\r\n";
  body += "    <modelName>Socket</modelName>\r\n";
  body += "    <modelNumber>3.1415</modelNumber>\r\n";
  body += "    <serialNumber>";
  body += serialNumber;
  body += "</serialNumber>\r\n";
  body += "    <UPC>123456789</UPC>\r\n"; 
  body += "    <UDN>uuid:Socket-1_0-";
  body += serialNumber;
  body += "</UDN>\r\n";
  //body += "     <serviceList>\r\n";
  //body += "        <service>\r\n";
  //body += "           <serviceType>urn:Belkin:service:basicevent:1</serviceType>\r\n";
  //body += "           <serviceId>urn:Belkin:serviceId:basicevent1</serviceId>\r\n";
  //body += "           <controlURL>/upnp/control/basicevent1</controlURL>\r\n";
  //body += "           <eventSubURL>/upnp/event/basicevent1</eventSubURL>\r\n";
  //body += "           <SCPDURL>/eventservice.xml</SCPDURL>\r\n";
  //body += "        </service>\r\n";
  //body += "     </serviceList>\r\n";
  body += "     <presentationURL>/pluginpres.html</presentationURL>\r\n";
  body += "  </device>\r\n";
  body += "</root>";

  String header = "HTTP/1.1 200 OK\r\n";
  header += "Content-Type: text/xml\r\n";
  header += "Content-Length: ";
  header += body.length();
  header += "\r\n";
  header += "Date: ";
  header += getDateString();
  header += "\r\n";
  header += "X-User-Agent: redsonic\r\n";
  header += "SERVER: Unspecified, UPnP/1.0, Unspecified\r\n";
  header += "connection: close\r\n";
  header += "LAST-MODIFIED: Tue, 08 Jul 2017 19:20:00 GMT\r\n";
  header += "\r\n";
  header += body;

  Serial.println(header);
  Serial.println("");
  server.sendContent(header);
}


void handleEventServiceXml()
{
  Serial.println("handleEventServiceXml");
    
  String body = "<?xml version=\"1.0\"?>\r\n";
  body += "<scpd xmlns=\"urn:Belkin:service-1-0\">\r\n";
  body += "  <specVersion>\r\n";
  body += "    <major>1</major>\r\n";
  body += "    <minor>0</minor>\r\n";
  body += "  </specVersion>\r\n";
  body += "  <actionList>\r\n";
  body += "    <action>\r\n";
  body += "      <name>SetBinaryState</name>\r\n";
  body += "      <argumentList>\r\n";
  body += "        <argument>\r\n";
  body += "          <retval />\r\n";
  body += "          <name>BinaryState</name>\r\n";
  body += "          <relatedStateVariable>BinaryState</relatedStateVariable>\r\n";
  body += "          <direction>in</direction>\r\n";
  body += "        </argument>\r\n";
  body += "      </argumentList>\r\n";
  body += "    </action>\r\n";
  
  body += "    <action>\r\n";
  body += "      <name>GetBinaryState</name>\r\n";
  body += "      <argumentList>\r\n";
  body += "        <argument>\r\n";
  body += "          <retval />\r\n";
  body += "          <name>BinaryState</name>\r\n";
  body += "          <relatedStateVariable>BinaryState</relatedStateVariable>\r\n";
  body += "          <direction>out</direction>\r\n";
  body += "        </argument>\r\n";
  body += "      </argumentList>\r\n";
  body += "    </action>\r\n";
  body += "  </actionList>\r\n";
  body += "  <serviceStateTable>\r\n";
  body += "    <stateVariable sendEvents=\"yes\">\r\n";
  body += "      <name>BinaryState</name>\r\n";
  body += "       <dataType>Boolean</dataType>\r\n";
  body += "       <defaultValue>0</defaultValue>\r\n";
  body += "     </stateVariable>\r\n";
  body += "  </serviceStateTable>\r\n";
  body += "</scpd>";

  String header = "HTTP/1.1 200 OK\r\n";
  header += "Content-Type: text/xml\r\n";
  header += "Content-Length: ";
  header += body.length();
  header += "\r\n";
  header += "Date: ";
  header += getDateString();
  header += "\r\n";
  header += "X-User-Agent: redsonic\r\n";
  header += "SERVER: Unspecified, UPnP/1.0, Unspecified\r\n";
  header += "connection: close\r\n";
  header += "LAST-MODIFIED: Tue, 08 Jul 2017 19:20:00 GMT\r\n";
  header += "\r\n";
  header += body;

  Serial.println(header);
  Serial.println("");
  server.sendContent(header);
}



void handleUpnpControl()
{
  Serial.println("handleUpnpControl");

  //Extract raw body
  //Because there is a '=' before "1.0", it will give the following:
  //"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>1</BinaryState></u:SetBinaryState></s:Body></s:Envelope>
  String body = server.arg(0);

  //Check valid request
  boolean isOn = body.indexOf("<BinaryState>1</BinaryState>") >= 0;
  boolean isOff = body.indexOf("<BinaryState>0</BinaryState>") >= 0;
  boolean isValid = isOn || isOff;
  boolean isStatus = false;

  Serial.println("Primljeno:");
  Serial.println(body);

  if (!isValid) {
    // Proveriti da li je tražen status. Ako nije ni to, onda i dalje ostaje Not Valid
    isStatus = body.indexOf("GetBinaryState") >= 0;
    int ind = body.indexOf("GetBinaryState");
    Serial.print("Rec GetBinaryState ima index ");
    Serial.println(ind);
    if (isStatus) isValid = true;
  }
  if (!isValid) {
    String message;
    message = "URI: ";
    message += server.uri();
    message += "\nMethod: ";
    message += (server.method() == HTTP_GET) ? "GET" : "POST";
    message += "\nArguments: ";
    message += server.args();
    message += "\n";
    for (uint8_t i=0; i<server.args(); i++) {
      message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
      }
    Serial.println("Bad HTTP request! Body:");
    Serial.println(body);
    Serial.println("Header:");
    Serial.println(message);
    Serial.println("------------ RETURNING ------------");
    Serial.println("");
    saljiStatus();
    //server.send(400, "text/plain", "Bad UPnP request");
    return;
  }

  //On/Off Logic
  if (isOn) {
      digitalWrite(LED_PIN, 0);
      Serial.println("Zahtevano: Turn ON");
      server.send(200, "text/plain", "Turning ON device");
  }
  if (isOff) {
      digitalWrite(LED_PIN, 1);
      Serial.println("Zahtevano: Turn OFF");
      server.send(200, "text/plain", "Turning OFF device");
  }
  if (isStatus) {
    saljiStatus();
  }
    Serial.println("------------ RETURNING ------------");
    Serial.println("");
}

void handleNotFound()
{
  Serial.println("handleNotFound()");
  Serial.println(server.uri());
  
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i=0; i<server.args(); i++) {
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
  Serial.println(message);
  Serial.println("");
}

void saljiStatus()
{
    delay(200);
    Serial.println("Slanje statusa");
    String odg;
//    odg  = "\"1.0\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">";
//    odg  = "\"1.0\"?>
    odg = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
    odg += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n";
    odg += "  <s:Body>\r\n";
    odg += "    <u:GetBinaryStateResponse xmlns:u=\"urn:Belkin:service:basicevent:1\">\r\n";
    odg += "      <BinaryState>";
    //if (LED_PIN == 1) odg += "0"; else odg += "1";  // Ovde je greska, ne može ovako!!!
    if (digitalRead(LED_PIN) == 1) odg += "0"; else odg += "1";  // Ne znam da li moze ovako. Izgleda da radi!!!!
    odg += "</BinaryState>\r\n";
    odg += "    </u:GetBinaryStateResponse>\r\n";
    odg += "  </s:Body>\r\n";
    odg += "</s:Envelope>\r\n";

    String header = "HTTP/1.1 200 OK\r\n";
    header += "CONTENT-LENGTH: ";
    header += odg.length();
    header += "\r\n";
    header += "CONTENT-TYPE: text/xml; charset=\"utf-8\"\r\n";
    header += "DATE: ";
    header += getDateString();
    header += "\r\n";
    header += "EXT:";
    header += "SERVER: Unspecified, UPnP/1.0, Unspecified\r\n";
    header += "X-User-Agent: redsonic\r\n";
    header += "\r\n";
    header += odg;

    delay(1200);
    server.sendContent(header);
    //server.send(201, "text/plain", odg);

    String message;
    message = "URI: ";
    message += server.uri();
    message += "\nMethod: ";
    message += (server.method() == HTTP_GET) ? "GET" : "POST";
    message += "\nArguments: ";
    message += server.args();
    message += "\n";
    for (uint8_t i=0; i<server.args(); i++) {
      message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
      }
    Serial.println("Zahtev:");
    Serial.println(message);    
    Serial.println("Odgovor:");
    Serial.println(header);
  }




//-----------------------------------------------------------------------
//-----------------------------------------------------------------------

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  Serial.println();

  // Initialize LED pin
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, 0);
  
  // setting up Station AP
  WiFi.begin(ssid, pass);

  // Wait for connect to AP
  Serial.print("[Connecting to ");
  Serial.print(ssid);
  Serial.print("]...");
  int tries=0;
  while (WiFi.status() != WL_CONNECTED) {
    delay(200);
    Serial.print(".");
    tries++;
    if (tries > 50)
      break;
  }
  
  // print your WiFi info
  IPAddress ip = WiFi.localIP();
  Serial.println();
  Serial.print("Connected to ");
  Serial.print(WiFi.SSID());
  Serial.print(" with IP: ");
  Serial.println(ip);
  
  //UDP Server
  Udp.beginMulticast(WiFi.localIP(),  ipMulti, portMulti);
  Serial.print("Udp multicast server started at ");
  Serial.print(ipMulti);
  Serial.print(":");
  Serial.println(portMulti);
  
  //Web Server
  server.on("/", handleRoot);
  server.on("/setup.xml", handleSetupXml);
  server.on("/eventservice.xml", handleEventServiceXml);
  server.on("/upnp/control/basicevent1", handleUpnpControl);
  server.on("/upnp/event/basicevent1",   handleUpnpControl);
  server.onNotFound(handleNotFound);
  server.begin();
  Serial.print("HTTP server started on port ");
  Serial.println(webserverPort);
}

void loop()
{
  UdpMulticastServerLoop();   //UDP multicast receiver
  server.handleClient();      //Webserver
}

Sorry, i forget to answer on your question:
I found this lines in file WemoSwitch.cpp (in the library by witnessmenow) line nubers 222 and 223.

Thank you very much I will try it as soon as possible :slight_smile: