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

Conversation

peterchs
Copy link
Contributor

Description:

Wemo emulation issues were found after 9.2.0 upgrade:

  1. On alexa discovery wemo devices were duplicated
  2. Devices could not be added to Alexa routines

Testing showed these issues were due to changes to the UUID/Serial Number presented to Alexa discovery requests, where the device id was appended/included altering the format/content of these identifiers. This fix ensures that for device/switch 1 the original single wemo discovery xml is returned. For switch 2+ the current response will still be returned, so multiple device support is maintained.

Related issue (if applicable): fixes #10165

Checklist:

  • The pull request is done against the latest dev branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • The code change is tested and works on Tasmota core ESP8266 V.2.7.4.9
  • The code change is tested and works on Tasmota core ESP32 V.1.0.5-rc4
  • I accept the CLA.

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

Pulling latest from upstream
Fixes two issues with wemo emulation introduced by the multiple device changes:
- Duplicate devices on upgrade (uuid/serial number for device/switch 1 changed)
- Device could not be added to routines, Alexa discovery has issue with the UUID/serial number when device id is included
@arendst
Copy link
Owner

arendst commented Dec 20, 2020

Doesn't your solution also mean that if you removed the wemo emulated device from your setup and then add it again with the new uuid it would solve this issue too?

@peterchs
Copy link
Contributor Author

peterchs commented Dec 20, 2020

Yes correct that would fix the duplicate issue but does not fix the problems with inability to add those devices to routines.

There is something about the multi change to the serial number to add the device to the end of it that Alexa doesn’t like. This PR avoids doing that for device 1 effectively reverting the multi behaviour.

I would say that device 2+ will still have the same problem with this PR but exactly what serial number change would not break routines is not clear.

I lack the devices / time to work that out and this PR is a tactical fix to correct the single device behaviour while still supporting multi WeMo emu.

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.

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.

arendst added a commit that referenced this pull request Dec 20, 2020
Fix Wemo single device backward compatibility (#10165, #10194)
@arendst arendst closed this Dec 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9.1.0.2 Wemo and Alexa group problem
3 participants