-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Wemo EMU - Multi device support #9208
Conversation
Now event the Wemo emulation can be used for multi-device hardware like Sonoff CH4-PRO. Alexa will recognize them as "switch", so you are free to say to Alexa "Alexa, turn on all the lights" without worrying about activating the switches too (as it happens if you are using HUE emulation)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job. I added some comments and questions.
LogUpnpWithClient(PSTR(D_WEMO_BASIC_EVENT)); | ||
|
||
char event[500]; | ||
strlcpy(event, _webServer->arg(0).c_str(), sizeof(event)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code was there already but I realize it could be cleaner. First take the length of the buffer and allocate on stack only what's needed. Anyways the UDP packets are capped to UDP_BUFFER_SIZE
(120)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to apply any kind of optimization!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of the following:
size_t event_len = _webServer->arg(0).length() + 1;
char event[event_len];
strlcpy(event, _webServer->arg(0).c_str(), event_len);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok!!
Tested with six relais. Works 😀 One thing that concerns me. Using WeMo emulation |
This is my first time with Arduino platform. why in this scenario, is so important to have 16Kb or 24Kb of free memory? WEMO protocol doesn't support multidevice (the developers were short-sighted in thinking about the protocol. even leaving everything like this would have taken very little.). |
Anyway, while I'm writing
however, while writing this answer, an idea occurred to me. |
I review the code... how did I not notice? I think that could work with only one webserver :) fingers crossed |
That would be great! |
No, it doesn't work. but it's an Alexa issue. On discovering packet, I sent this setup.xml:
but then Alexa, instead of use the url that I put in that XML (/1/upnp/control/basicevent1), use the default one: 09:51:08 HTP: Not found (/upnp/control/basicevent1) but obviously it doesn't work, since in order to use one webserver, I have to listen on different url (one for eache device) :( |
@Magic73 I am speaking of free RAM. Not flash. It does matter since my build is not the standard Tasmota build. I have reduced the included sensors / functions. Using the enhanced WeMo EMU |
If using less RAM it would be a nice addition. If someone manages to use only one webserver to get this working I would probably merge. |
Why don't merge it? It will use more ram only if you have a device with more than 1 switch, and it's a good alternative to Philips Hue emu. At the moment, you don't use WeMu on a device with multi switch, since only the first one is handled.
Again, if the device has just one switch.. nothing changed from how WeMu works now. And if your device has more than one switch, you don't use WeMu right now. Sorry, but you are wrong. Anyway, no one can handle it with a single webserver, due to how Alexa works. |
(sorry for closing/opening, I did a mistake while pressing the reply button) |
I'd love to have this feature, maybe enable it with a SetOption (optionally)? |
You can use it. If you only have one switch, it works exactly like the previous one. the code is the same. For each additional switch, a dedicated web server is created. I'm using it for my sprinkler system, and it works flawlessly. |
Hello, I'm currently using the official build, so until now I can't use it, that's why I posted. :) I'm not really skilled enough to fully understand your PR but did you try using subdomains instead of urls so you can use a single web server? Thanks for reply. |
The reason why it doesn't work with one single webserver is because Alexa seems to ignore parts of the configuration: |
Did you try sending full paths instead of relative ones? But I'm sure you did if it's possible here.... The reason I'm bothering you: Maybe you can work out another solution with this, just ignore the replys and focus on executing the on and off commands. The subdomain question was thought like this: One web server running "0.tasmota.device" and "1.tasmota.device" for the emulation. This should make you able to send relative paths from each subdomain and Alexa can use the "default" answer and still send it to "two" devices. You'd have to send two responses when Alexa is discovering devices, one for each device, from each subdomain, but you should be able to run this with one web server. Again, I don't know if this is possible. If Alexa i.e. uses the IP for the call this won't help. |
Alexa send an UDP message to start discovering devices. WeMu reply to this UDP with that XML. |
I've got your point and this is exactly why I'd like this feature in an official build. |
If you want to give it a try, here the binary: Notice: |
Thanks again! What version are these? |
Tasmota 8.4.0.3 (with the default component, already present in tasmota.bin) |
I'd love to have this feature too. @arendst |
He could without any side effect. The multi-web server would be activated only when you use more than one switch. |
Working on merging now ... |
Add support for multiple WeMo devices by Magic73 (#9208)
Merged |
Description:
Now the Wemo emulation can be used for multi-device hardware like Sonoff CH4-PRO.
Alexa will recognize them as "switch", so you are free to say to Alexa "Alexa, turn on all the lights" without worrying about activating the switches too (as it happens if you are using HUE emulation)
Checklist:
NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass