mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 12:46:34 +00:00
Merge branch 'feature/Fix_WeMo_Emulation' into development
This commit is contained in:
commit
2b0deb5096
@ -242,18 +242,18 @@ void PollUdp()
|
|||||||
|
|
||||||
const char WEMO_EVENTSERVICE_XML[] PROGMEM =
|
const char WEMO_EVENTSERVICE_XML[] PROGMEM =
|
||||||
"<?scpd xmlns=\"urn:Belkin:service-1-0\"?>"
|
"<?scpd xmlns=\"urn:Belkin:service-1-0\"?>"
|
||||||
"<actionList>"
|
"<actionList>"
|
||||||
"<action>"
|
"<action>"
|
||||||
"<name>SetBinaryState</name>"
|
"<name>SetBinaryState</name>"
|
||||||
"<argumentList>"
|
"<argumentList>"
|
||||||
"<argument>"
|
"<argument>"
|
||||||
"<retval/>"
|
"<retval/>"
|
||||||
"<name>BinaryState</name>"
|
"<name>BinaryState</name>"
|
||||||
"<relatedStateVariable>BinaryState</relatedStateVariable>"
|
"<relatedStateVariable>BinaryState</relatedStateVariable>"
|
||||||
"<direction>in</direction>"
|
"<direction>in</direction>"
|
||||||
"</argument>"
|
"</argument>"
|
||||||
"</argumentList>"
|
"</argumentList>"
|
||||||
"<serviceStateTable>"
|
"<serviceStateTable>"
|
||||||
"<stateVariable sendEvents=\"yes\">"
|
"<stateVariable sendEvents=\"yes\">"
|
||||||
"<name>BinaryState</name>"
|
"<name>BinaryState</name>"
|
||||||
"<dataType>Boolean</dataType>"
|
"<dataType>Boolean</dataType>"
|
||||||
@ -263,14 +263,34 @@ const char WEMO_EVENTSERVICE_XML[] PROGMEM =
|
|||||||
"<name>level</name>"
|
"<name>level</name>"
|
||||||
"<dataType>string</dataType>"
|
"<dataType>string</dataType>"
|
||||||
"<defaultValue>0</defaultValue>"
|
"<defaultValue>0</defaultValue>"
|
||||||
"</stateVariable>"
|
"</stateVariable>"
|
||||||
"</serviceStateTable>"
|
"</serviceStateTable>"
|
||||||
|
"</action>"
|
||||||
|
"<action>"
|
||||||
|
"<name>GetBinaryState</name>"
|
||||||
|
"<argumentList>"
|
||||||
|
"<argument>"
|
||||||
|
"<retval/>"
|
||||||
|
"<name>BinaryState</name>"
|
||||||
|
"<relatedStateVariable>BinaryState</relatedStateVariable>"
|
||||||
|
"<direction>out</direction>"
|
||||||
|
"</argument>"
|
||||||
|
"</argumentList>"
|
||||||
"</action>"
|
"</action>"
|
||||||
"</scpd>\r\n"
|
"</scpd>\r\n"
|
||||||
"\r\n";
|
"\r\n";
|
||||||
|
const char WEMO_RESPONSE_STATE_XML[] PROGMEM =
|
||||||
|
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
|
||||||
|
"<s:Body>"
|
||||||
|
"<u:{x1BinaryStateResponse xmlns:u=\"urn:Belkin:service:basicevent:1\">"
|
||||||
|
"<BinaryState>{x2</BinaryState>"
|
||||||
|
"</u:{x1BinaryStateResponse>"
|
||||||
|
"</s:Body>"
|
||||||
|
"</s:Envelope>\r\n"
|
||||||
|
"\r\n";
|
||||||
const char WEMO_SETUP_XML[] PROGMEM =
|
const char WEMO_SETUP_XML[] PROGMEM =
|
||||||
"<?xml version=\"1.0\"?>"
|
"<?xml version=\"1.0\"?>"
|
||||||
"<root>"
|
"<root xmlns=\"urn:Belkin:device-1-0\">"
|
||||||
"<device>"
|
"<device>"
|
||||||
"<deviceType>urn:Belkin:device:controllee:1</deviceType>"
|
"<deviceType>urn:Belkin:device:controllee:1</deviceType>"
|
||||||
"<friendlyName>{x1</friendlyName>"
|
"<friendlyName>{x1</friendlyName>"
|
||||||
@ -299,15 +319,32 @@ void HandleUpnpEvent()
|
|||||||
{
|
{
|
||||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_WEMO_BASIC_EVENT));
|
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_WEMO_BASIC_EVENT));
|
||||||
String request = WebServer->arg(0);
|
String request = WebServer->arg(0);
|
||||||
if (request.indexOf(F("State>1</Binary")) > 0) {
|
String state_xml = FPSTR(WEMO_RESPONSE_STATE_XML);
|
||||||
// ExecuteCommandPower(1, 1);
|
//differentiate get and set state
|
||||||
ExecuteCommandPower(devices_present, 1);
|
if (request.indexOf(F("SetBinaryState")) > 0) {
|
||||||
|
if (request.indexOf(F("State>1</Binary")) > 0) {
|
||||||
|
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_WEMO_BASIC_EVENT " SET STATE 1"));
|
||||||
|
ExecuteCommandPower(devices_present, 1);
|
||||||
|
state_xml.replace("{x1", "Set");
|
||||||
|
state_xml.replace("{x2", "1");
|
||||||
|
}
|
||||||
|
else if (request.indexOf(F("State>0</Binary")) > 0) {
|
||||||
|
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_WEMO_BASIC_EVENT " SET STATE 0"));
|
||||||
|
ExecuteCommandPower(devices_present, 0);
|
||||||
|
|
||||||
|
state_xml.replace("{x1", "Set");
|
||||||
|
state_xml.replace("{x2", "0");
|
||||||
|
}
|
||||||
|
WebServer->send(200, FPSTR(HDR_CTYPE_XML), state_xml.c_str());
|
||||||
}
|
}
|
||||||
if (request.indexOf(F("State>0</Binary")) > 0) {
|
else if(request.indexOf(F("GetBinaryState")) > 0){
|
||||||
// ExecuteCommandPower(1, 0);
|
char svalue[80];
|
||||||
ExecuteCommandPower(devices_present, 0);
|
snprintf_P(svalue, sizeof(svalue), PSTR("%d"), bitRead(power, 1 -1));
|
||||||
|
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_WEMO_BASIC_EVENT " GET STATE"));
|
||||||
|
state_xml.replace("{x1", "Get");
|
||||||
|
state_xml.replace("{x2", svalue);
|
||||||
|
WebServer->send(200, FPSTR(HDR_CTYPE_XML), state_xml.c_str());
|
||||||
}
|
}
|
||||||
WebServer->send(200, FPSTR(HDR_CTYPE_PLAIN), "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleUpnpService()
|
void HandleUpnpService()
|
||||||
@ -720,4 +757,3 @@ void HandleHueApi(String *path)
|
|||||||
}
|
}
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
#endif // USE_EMULATION
|
#endif // USE_EMULATION
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user