Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WeMo Emu Issues #10194

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions tasmota/xdrv_21_wemo_multi.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
xdrv_21_wemo_multi.ino - multiple wemo support for Tasmota

Copyright (C) 2020 Magic73, Heiko Krupp and Theo Arends
Copyright (C) 2020 Magic73, Heiko Krupp, Peter Stevenson and Theo Arends

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -235,8 +235,12 @@ private:

String WemoSerialnumber(void) {
char serial[18];

snprintf_P(serial, sizeof(serial), PSTR("201612K%08X-%d"), ESP_getChipId(), _deviceId);
if (_deviceId == 1)
{
snprintf_P(serial, sizeof(serial), PSTR("201612K%08X"), ESP_getChipId());
} else {
snprintf_P(serial, sizeof(serial), PSTR("201612K%08X-%d"), ESP_getChipId(), _deviceId);
}
Copy link
Owner

@arendst arendst Dec 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if you change this to

snprintf_P(serial, sizeof(serial), PSTR("201612K%08X%02X"), ESP_getChipId(), _deviceId);

so removing the dash and make it hex.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried it. This change works fine for me. The if/else is not necessary in both cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you can add the device 1 to routines in Alexa app ok?

Still expect there to be issue with dupe devices after upgrade from pre-9.2.0 as the serial/uuid changed.

Copy link

@OFreddy OFreddy Dec 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, everithing works fine, now. I had problems adding the devices to a group or routine as not all of them where added to that group. I made several test and when adding a device to that group another device (I expect the one first discovered) was added. Now I can add every new device to every group as I want to. Before I can't add the devices "Terrasse", "Haustuer" and "Garten" to the same group. Now it works.

Screenshot_20201220-131746_Amazon Alexa

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx so the latest fix solved both issues.

Closing this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested with these two changes to remove the if/else, and yes does fix the routine/group issue, but I do still end up with duplicate device upgrading when the device existed in Alexa before. Both devices still work ok however.

return String(serial);
}

Expand Down Expand Up @@ -390,7 +394,14 @@ private:
#else
String setup_xml = FPSTR(WEMO_SETUP_XML);
#endif
setup_xml.replace("{x1", SettingsText(SET_FRIENDLYNAME1 + (_deviceId - 1)));
if (_deviceId == 1)
{
setup_xml.replace("{x1", SettingsText(SET_FRIENDLYNAME1));
}
else
{
setup_xml.replace("{x1", SettingsText(SET_FRIENDLYNAME1 + (_deviceId - 1)));
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed as in case of a single device _deviceId is 1 resulting in exactly the same Friendlyname as in your fix.

This adds to code size.

setup_xml.replace("{x2", WemoUuid());
setup_xml.replace("{x3", WemoSerialnumber());
InternalWSSend(200, CT_XML, setup_xml);
Expand Down Expand Up @@ -459,4 +470,4 @@ bool Xdrv21(uint8_t function)
return result;
}

#endif // USE_WEBSERVER && USE_EMULATION && USE_EMULATION_WEMO
#endif // USE_WEBSERVER && USE_EMULATION && USE_EMULATION_WEMO