ESP8266 Relay control via Home Assistant and Alexa - Wemo Switch Emulation

Hi there,

I’ve successfully (I suppose not a major feat) flashed an ESP8266 with Arduino code to emulate a Wemo Switch which has successfully been detected by the Echo as a device and I am able to control a relay. What I’d like to do is also be able to control the relay through the front end of Home Assistant also.

I enabled the wemo: configuration option and also added the ip of the esp8266 as a static in the wemo config section but HA failed to detect the device.

Has anyone else had any success with the Echo<>ESP8266<>Home Assistant?


Ok so going 1 step further, I’ve managed to use the http_post in this particular case to the following URL

with the content below, which switches the relay depending on the binary state being a 1 or 0

request:"1.0" encoding="utf-8"?><s:Envelope xmlns:s="" s:encodingStyle=""><s:Body><u:SetBinaryState xmlns:u="urn:Belkin:service:basicevent:1"><BinaryState>1</BinaryState></u:SetBinaryState></s:Body></s:Envelope>

Is there any way to incorporate this into HA?

Source for the Arduino code is -

So I’ve figured it myself, I can call curl from a bash script within HASS

curl --data "request:"1.0" encoding="utf-8"?><s:Envelope xmlns:s="" s:encodingStyle=""><s:Body><u:SetBinaryState xmlns:u="urn:Belkin:service:basicevent:1"><BinaryState>0</BinaryState></u:SetBinaryState></s:Body></s:Envelope>"

So, I thought I’d share my findings.

Thanks for keeping this thread up to date. I think I’ll try exactly the same with my esp tonight.

Hi, thanks for the thread, I am a newbie to the Home Assistant, I can flash the ESP8266 with a emulate wemo script but I would am not sure how to get Home Assistant to recognize the new wemo emulated board. can you tell me exactly ( as in very basic ) how you did this please. Cheers Dave


If you’ve flashed the ESP with a WEMO emulating sketch, getting Alexa to re-discover devices should pick it up as long as it resides on the same network.

Hi thanks for the reply,
Getting Alexa to discover the esp8266 is not the problem, it’s getting HA to discover the emulated wemo that I am having a problem with. I would like to be able to control the board via both HA and Alexa not just Alexa. cheers Dave


Sorry, I misread your original message!!

Ok, so Home Assistant isn’t going to detect your esp8266/wemo emulated device. The only way I found to get around this was to do the following:

In configuration.yaml I did the following (which created a switch):

  - platform: command_line 
        command_on: "/path/to.homeassistant/.homeassistant/" 
        command_off: "/path/to.homeassistant/.homeassistant/"
        friendly_name: My ESP8266 Wemo

And your and off-sh have the following: (the BinaryState 0 and 1 is on and off respectively)

curl --data “request:“1.0” encoding=“utf-8”?><s:Envelope xmlns:s=“” s:encodingStyle=“”><s:Body><u:SetBinaryState xmlns:u=“urn:Belkin:service:basicevent:1”>0</u:SetBinaryState></s:Body></s:Envelope>” http://IPADDRESSOFYOUR8266/upnp/control/basicevent1

curl --data “request:“1.0” encoding=“utf-8”?><s:Envelope xmlns:s=“” s:encodingStyle=“”><s:Body><u:SetBinaryState xmlns:u=“urn:Belkin:service:basicevent:1”>1</u:SetBinaryState></s:Body></s:Envelope>” http://IPADDRESSOFYOUR8266/upnp/control/basicevent1

Once this is all done, you can include the switch in automations etc as you would an actual device.

Hope this helps.

Regards, Michael

I have encountered this problem as well. Do we know why Echo devices can discover emulated WEMO switches but Home Assistant cannot? Is this an issue that can be fixed rather than worked around.

It would probably easier to just have the ESP8266 also communicate over MQTT, but then you could drop the emulated hue thing and just have Echo fire off through HA the MQTT messages.

I think there are two things stopping this working for me.

Firstly, my emulated WEMO only responded to the ssdp message “ST: urn:Belkin:device:**”, Home Assistant only sends “ST: upnp:rootdevice” which all devices should respond to. Adding an appropriate response to the “ST: upnp:rootdevice” (and “ST: ssdp:all”) makes the emulation more compliant.

Second the pywemo library that Home Assistant requires title case on the uuid however the Echo requires lower case on the device type for example in my case I used
<deviceType>urn:Belkin:device:lightswitch:1</deviceType> which is recognised by the echo but uuids starting <UDN>uuid:Lightswitch:…</UDN> are recognised by pywemo and I had used the same case as in the device type which wasn’t.