From 0ac8c73938cff33f0166d86867e33b190f23ded8 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 2 Sep 2018 14:26:00 +0200 Subject: [PATCH] Fix Wemo emulation Fix Wemo emulation to select the first relay when more than one relay is present (#3657) --- sonoff/_changelog.ino | 1 + sonoff/xplg_wemohue.ino | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index d8a14e367..d2781b4d4 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -2,6 +2,7 @@ * Fix possible ambiguity on command parameters if StateText contains numbers only (#3656) * Fix possible exception due to buffer overflow (#3659) * Add Wifi channel number to state message (#3664) + * Fix Wemo emulation to select the first relay when more than one relay is present (#3657) * * 6.2.0 20180901 * Allow user override of define MAX_RULE_VARS and MAX_RULE_TIMERS (#3561) diff --git a/sonoff/xplg_wemohue.ino b/sonoff/xplg_wemohue.ino index 9a7cdeec7..9a5fb9467 100644 --- a/sonoff/xplg_wemohue.ino +++ b/sonoff/xplg_wemohue.ino @@ -386,12 +386,18 @@ void HandleUpnpEvent() String state_xml = FPSTR(WEMO_RESPONSE_STATE_SOAP); //differentiate get and set state if (request.indexOf(F("SetBinaryState")) > 0) { + uint8_t power = POWER_TOGGLE; if (request.indexOf(F("State>1 0) { - ExecuteCommandPower(devices_present, POWER_ON, SRC_WEMO); + power = POWER_ON } else if (request.indexOf(F("State>0 0) { - ExecuteCommandPower(devices_present, POWER_OFF, SRC_WEMO); + power = POWER_OFF; } + if (power != POWER_TOGGLE) { + uint8_t device = (light_type) ? devices_present : 1; // Select either a configured light or relay1 + ExecuteCommandPower(device, power, SRC_WEMO); + } + } else if(request.indexOf(F("GetBinaryState")) > 0){ state_xml.replace(F("Set"), F("Get"));