n8henrie / fauxmo

Emulated Belkin WeMo devices that work with the Amazon Echo
https://n8henrie.com/2016/02/fauxmo-home-automation-with-the-amazon-echo-raspberry-pi-and-homeassistant/
Other
374 stars 78 forks source link

Echo not recognizing devices #38

Closed estauseb closed 6 years ago

estauseb commented 6 years ago

My Issue

The Fauxmo devices don't respond to the echo.

WHYT

I followed the instructions on the docs ( http://fauxmo.readthedocs.io/en/latest/md/protocol_notes.html ). The Echo is sending SSDP SEARCH but the fauxmo devices are not responding.

  1 0.000000000   10.217.0.9 → 239.255.255.250 SSDP 136 M-SEARCH * HTTP/1.1
  2 0.000241300   10.217.0.9 → 239.255.255.250 SSDP 143 M-SEARCH * HTTP/1.1
  3 0.921713869   10.217.0.9 → 239.255.255.250 SSDP 136 M-SEARCH * HTTP/1.1
  4 1.020941347   10.217.0.9 → 239.255.255.250 SSDP 143 M-SEARCH * HTTP/1.1
  5 1.433808518   10.217.0.9 → 239.255.255.250 SSDP 136 M-SEARCH * HTTP/1.1
  6 1.434059663   10.217.0.9 → 239.255.255.250 SSDP 143 M-SEARCH * HTTP/1.1
  7 1.947812897   10.217.0.9 → 239.255.255.250 SSDP 136 M-SEARCH * HTTP/1.1
  8 1.947981906   10.217.0.9 → 239.255.255.250 SSDP 143 M-SEARCH * HTTP/1.1

If i run the fauxmo script with -vvv i can see that the messages are received but there is no answer.

"$(pyenv root)"/versions/3.6.1/bin/fauxmo -c /home/pi/echo-pi/config.json -vvv >> tmp
2017-11-29 18:43:28 fauxmo:37       INFO     Fauxmo v0.4.4
2017-11-29 18:43:28 fauxmo:38       DEBUG    3.6.1 (default, Nov  8 2017, 09:55:19)
[GCC 6.3.0 20170516]
2017-11-29 18:43:28 fauxmo:24       DEBUG    Attempting to get IP address automatically
2017-11-29 18:43:28 fauxmo:37       DEBUG    Using IP address: 10.217.0.10
2017-11-29 18:43:29 fauxmo:102      DEBUG    plugin_vars: {}
2017-11-29 18:43:29 fauxmo:105      DEBUG    device config: {'port': 12340, 'on_cmd': 'http://10.217.0.10:3000/myserver/fakeswitches/01/on', 'off_cmd': 'http://10.217.0.10:3000/myserver/fakeswitches/01/off', 'method': 'GET', 'name': 'fake switch one'}
2017-11-29 18:43:29 asyncio:1067     INFO     <Server sockets=[<socket.socket fd=7, family=AddressFamily.AF_INET, type=2049, proto=6, laddr=('10.217.0.10', 12340)>]> is serving
2017-11-29 18:43:29 fauxmo:123      DEBUG    Started fauxmo device: {'name': 'fake switch one', 'plugin': <fauxmo.plugins.simplehttpplugin.SimpleHTTPPlugin object at 0x760968f0>}
2017-11-29 18:43:29 fauxmo:105      DEBUG    device config: {'port': 12341, 'on_cmd': 'http://10.217.0.10:54321/devices/garage%20light', 'off_cmd': 'http://10.217.0.10:54321/devices/garage%20light', 'on_data': {'isOn': 1}, 'off_data': {'isOn': 0}, 'user': 'this', 'password': 'that', 'method': 'PUT', 'name': 'fake Indigo switch'}
2017-11-29 18:43:29 asyncio:1067     INFO     <Server sockets=[<socket.socket fd=8, family=AddressFamily.AF_INET, type=2049, proto=6, laddr=('10.217.0.10', 12341)>]> is serving
2017-11-29 18:43:29 fauxmo:123      DEBUG    Started fauxmo device: {'name': 'fake Indigo switch', 'plugin': <fauxmo.plugins.simplehttpplugin.SimpleHTTPPlugin object at 0x7600a3d0>}
2017-11-29 18:43:29 fauxmo:105      DEBUG    device config: {'name': 'fake home assistant switch by REST API', 'port': 12342, 'on_cmd': 'http://10.217.0.10:8123/api/services/switch/turn_on', 'off_cmd': 'http://10.217.0.10:8123/api/services/switch/turn_off', 'method': 'POST', 'headers': {'x-ha-access': 'your_hass_password'}, 'on_data': {'entity_id': 'switch.fake_hass_switch'}, 'off_data': {'entity_id': 'switch.fake_hass_switch'}}
2017-11-29 18:43:29 asyncio:1067     INFO     <Server sockets=[<socket.socket fd=9, family=AddressFamily.AF_INET, type=2049, proto=6, laddr=('10.217.0.10', 12342)>]> is serving
2017-11-29 18:43:29 fauxmo:123      DEBUG    Started fauxmo device: {'name': 'fake home assistant switch by REST API', 'plugin': <fauxmo.plugins.simplehttpplugin.SimpleHTTPPlugin object at 0x75f12930>}
2017-11-29 18:43:29 fauxmo:125      INFO     Starting UDP server
2017-11-29 18:43:29 asyncio:947      DEBUG    Datagram endpoint remote_addr=None created: (<_SelectorDatagramTransport fd=10 read=idle write=<idle, bufsize=0>>, <fauxmo.protocols.SSDPServer object at 0x76096610>)
2017-11-29 18:43:35 asyncio:1379     INFO     poll took 6058.880 ms: 1 events
2017-11-29 18:43:35 fauxmo:170      DEBUG    Received data below from ('10.217.0.9', 50000):
2017-11-29 18:43:35 fauxmo:171      DEBUG    b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: ssdp:all\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n'
2017-11-29 18:43:35 asyncio:1379     DEBUG    poll took 0.105 ms: 1 events
2017-11-29 18:43:35 fauxmo:170      DEBUG    Received data below from ('10.217.0.9', 50000):
2017-11-29 18:43:35 fauxmo:171      DEBUG    b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: upnp:rootdevice\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n'
2017-11-29 18:43:36 asyncio:1379     INFO     poll took 1526.918 ms: 1 events
2017-11-29 18:43:36 fauxmo:170      DEBUG    Received data below from ('10.217.0.9', 50000):
2017-11-29 18:43:36 fauxmo:171      DEBUG    b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: upnp:rootdevice\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n'
2017-11-29 18:43:36 asyncio:1379     DEBUG    poll took 0.107 ms: 1 events

Please make sure you've taken these steps before submitting a new issue:

CONFIG.JSON


    "FAUXMO": {
        "ip_address": "auto"
    },
    "PLUGINS": {
        "SimpleHTTPPlugin": {
            "DEVICES": [
                {
                    "port": 12340,
                    "on_cmd": "http://10.217.0.10:3000/myserver/fakeswitches/01/on",
                    "off_cmd": "http://10.217.0.10:3000/myserver/fakeswitches/01/off",
                    "method": "GET",
                    "name": "fake switch one"
                },
                {
                    "port": 12341,
                    "on_cmd": "http://10.217.0.10:54321/devices/garage%20light",
                    "off_cmd": "http://10.217.0.10:54321/devices/garage%20light",
                    "on_data": {"isOn": 1},
                    "off_data": {"isOn": 0},
                    "user": "this",
                    "password": "that",
                    "method": "PUT",
                    "name": "fake Indigo switch"
                },
                {
                    "name": "fake home assistant switch by REST API",
                    "port": 12342,
                    "on_cmd": "http://10.217.0.10:8123/api/services/switch/turn_on",
                    "off_cmd": "http://10.217.0.10:8123/api/services/switch/turn_off",
                    "method": "POST",
                    "headers": {"x-ha-access": "your_hass_password"},
                    "on_data": {"entity_id": "switch.fake_hass_switch"},
                    "off_data": {"entity_id": "switch.fake_hass_switch"}
                }
            ]
        }
    }
}```
n8henrie commented 6 years ago

Thanks for a complete issue.

What is your Echo firmware version and what type of device is it?

I assume you've tried re-discovering a few times?

Also, please update to the latest fauxmo version (though I don't think it will fix this issue, since I don't see Belkin in any of your Echo requests).

estauseb commented 6 years ago

thanks for the quick response. It's an Echo (2nd generation) with the firmware version: 592452720. Yes i tried the discovery multiple times and with other git repositories using the fauxmo script.

demvil commented 6 years ago

I also have exactly the same problem with echo 2nd generation and firmware version: 592452720. I have the latest fauxmo v0.4.5 version.

n8henrie commented 6 years ago

Looks like that firmware is probably an issue. This will be a little tough for me to debug, as I don't have an Echo 2, and none of my echo devices are running that firmware.

I've pushed a potential fix to the issue_38 branch -- can anybody with this problem please give it a shot and see if it solves the issue? https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support

If not, please provide debug output and we can go from there.

Shout-out to @monarch73 for making me aware of this upcoming issue and a potential fix a few weeks ago.

demvil commented 6 years ago

i tryed it and it did not work. here is the output: `sudo "$(pyenv root)"/versions/3.6.1/bin/fauxmo -c ~/config.json -vvv 2017-12-01 10:58:42 fauxmo:37 INFO Fauxmo v0.4.5 2017-12-01 10:58:42 fauxmo:38 DEBUG 3.6.1 (default, Nov 30 2017, 11:44:59) [GCC 5.4.0 20160609] 2017-12-01 10:58:42 fauxmo:24 DEBUG Attempting to get IP address automatically 2017-12-01 10:58:42 fauxmo:37 DEBUG Using IP address: 192.168.178.2 2017-12-01 10:58:42 fauxmo:100 DEBUG plugin_vars: {} 2017-12-01 10:58:42 fauxmo:103 DEBUG device config: {'name': 'output', 'port': 49915, 'on_cmd': 'touch testfile.txt', 'off_cmd': 'rm testfile.txt', 'state_cmd': 'ls testfile.txt'} 2017-12-01 10:58:42 asyncio:1067 INFO <Server sockets=[<socket.socket fd=7, family=AddressFamily.AF_INET, type=2049, proto=6, laddr=('192.168.178.2', 49915)>]> is serving 2017-12-01 10:58:42 fauxmo:121 DEBUG Started fauxmo device: {'name': 'output', 'plugin': <fauxmo.plugins.commandlineplugin.CommandLinePlugin object at 0x7f0c97cfe630>} 2017-12-01 10:58:42 fauxmo:123 INFO Starting UDP server 2017-12-01 10:58:42 asyncio:947 DEBUG Datagram endpoint remote_addr=None created: (<_SelectorDatagramTransport fd=8 read=idle write=<idle, bufsize=0>>, <fauxmo.protocols.SSDPServer object at 0x7f0c97d3f278>) 2017-12-01 10:58:44 asyncio:1379 INFO poll took 2727.703 ms: 1 events 2017-12-01 10:58:44 fauxmo:224 DEBUG Received data below from ('192.168.178.180', 50000): 2017-12-01 10:58:44 fauxmo:225 DEBUG b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: upnp:rootdevice\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n' 2017-12-01 10:58:44 fauxmo:265 DEBUG Sending response to ('192.168.178.180', 50000): HTTP/1.1 200 OK CACHE-CONTROL: max-age=86400 DATE: Fri, 01 Dec 2017 09:58:44 GMT EXT: LOCATION: http://192.168.178.2:49915/setup.xml OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01 01-NLS: f795c3fa-0b25-4baf-a8a4-6733d284b978 SERVER: Fauxmo, UPnP/1.0, Unspecified ST: urn:Belkin:device: USN: uuid:Socket-1_0-43b3ae40-0ab7-3efb-8425-a09656068511::urn:Belkin:device:

2017-12-01 10:58:44 asyncio:1379 DEBUG poll took 12.268 ms: 1 events 2017-12-01 10:58:44 fauxmo:224 DEBUG Received data below from ('192.168.178.180', 50000): 2017-12-01 10:58:44 fauxmo:225 DEBUG b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: ssdp:all\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n' 2017-12-01 10:58:44 fauxmo:265 DEBUG Sending response to ('192.168.178.180', 50000): HTTP/1.1 200 OK CACHE-CONTROL: max-age=86400 DATE: Fri, 01 Dec 2017 09:58:44 GMT EXT: LOCATION: http://192.168.178.2:49915/setup.xml OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01 01-NLS: 58af155a-0a0b-438a-8f0a-2a6090be6b0a SERVER: Fauxmo, UPnP/1.0, Unspecified ST: urn:Belkin:device: USN: uuid:Socket-1_0-43b3ae40-0ab7-3efb-8425-a09656068511::urn:Belkin:device:

2017-12-01 10:58:45 asyncio:1379 DEBUG poll took 501.788 ms: 1 events 2017-12-01 10:58:45 fauxmo:224 DEBUG Received data below from ('192.168.178.180', 50000): 2017-12-01 10:58:45 fauxmo:225 DEBUG b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: upnp:rootdevice\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n' 2017-12-01 10:58:45 fauxmo:265 DEBUG Sending response to ('192.168.178.180', 50000): HTTP/1.1 200 OK CACHE-CONTROL: max-age=86400 DATE: Fri, 01 Dec 2017 09:58:45 GMT EXT: LOCATION: http://192.168.178.2:49915/setup.xml OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01 01-NLS: ec4fba71-f685-45cf-8a9b-a686dfae255f SERVER: Fauxmo, UPnP/1.0, Unspecified ST: urn:Belkin:device: USN: uuid:Socket-1_0-43b3ae40-0ab7-3efb-8425-a09656068511::urn:Belkin:device:

2017-12-01 10:58:45 asyncio:1379 DEBUG poll took 0.019 ms: 1 events 2017-12-01 10:58:45 fauxmo:224 DEBUG Received data below from ('192.168.178.180', 50000): 2017-12-01 10:58:45 fauxmo:225 DEBUG b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: ssdp:all\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n' 2017-12-01 10:58:45 fauxmo:265 DEBUG Sending response to ('192.168.178.180', 50000): HTTP/1.1 200 OK CACHE-CONTROL: max-age=86400 DATE: Fri, 01 Dec 2017 09:58:45 GMT EXT: LOCATION: http://192.168.178.2:49915/setup.xml OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01 01-NLS: 8e90575f-4b8b-49ec-bbd2-b4cd646ee83c SERVER: Fauxmo, UPnP/1.0, Unspecified ST: urn:Belkin:device: USN: uuid:Socket-1_0-43b3ae40-0ab7-3efb-8425-a09656068511::urn:Belkin:device:

2017-12-01 10:58:45 asyncio:1379 DEBUG poll took 483.998 ms: 1 events 2017-12-01 10:58:45 fauxmo:224 DEBUG Received data below from ('192.168.178.180', 50000): 2017-12-01 10:58:45 fauxmo:225 DEBUG b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: upnp:rootdevice\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n' 2017-12-01 10:58:45 fauxmo:265 DEBUG Sending response to ('192.168.178.180', 50000): HTTP/1.1 200 OK CACHE-CONTROL: max-age=86400 DATE: Fri, 01 Dec 2017 09:58:45 GMT EXT: LOCATION: http://192.168.178.2:49915/setup.xml OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01 01-NLS: 3f28ba4e-7a60-4e7c-80e8-dfa125054cf9 SERVER: Fauxmo, UPnP/1.0, Unspecified ST: urn:Belkin:device: USN: uuid:Socket-1_0-43b3ae40-0ab7-3efb-8425-a09656068511::urn:Belkin:device:

2017-12-01 10:58:45 asyncio:1379 DEBUG poll took 11.092 ms: 1 events 2017-12-01 10:58:45 fauxmo:224 DEBUG Received data below from ('192.168.178.180', 50000): 2017-12-01 10:58:45 fauxmo:225 DEBUG b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: ssdp:all\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n' 2017-12-01 10:58:45 fauxmo:265 DEBUG Sending response to ('192.168.178.180', 50000): HTTP/1.1 200 OK CACHE-CONTROL: max-age=86400 DATE: Fri, 01 Dec 2017 09:58:45 GMT EXT: LOCATION: http://192.168.178.2:49915/setup.xml OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01 01-NLS: 877e0b5d-d076-467f-9d66-e89f72782f74 SERVER: Fauxmo, UPnP/1.0, Unspecified ST: urn:Belkin:device: USN: uuid:Socket-1_0-43b3ae40-0ab7-3efb-8425-a09656068511::urn:Belkin:device:

2017-12-01 10:58:45 asyncio:1379 DEBUG poll took 31.662 ms: 1 events 2017-12-01 10:58:45 fauxmo:224 DEBUG Received data below from ('192.168.178.34', 50820): 2017-12-01 10:58:45 fauxmo:225 DEBUG b'M-SEARCH HTTP/1.1\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\nMX: 1\r\nST: urn:dial-multiscreen-org:service:dial:1\r\nUSER-AGENT: Google Chrome/62.0.3202.94 Windows\r\n\r\n' 2017-12-01 10:58:46 asyncio:1379 DEBUG poll took 311.905 ms: 1 events 2017-12-01 10:58:46 fauxmo:224 DEBUG Received data below from ('192.168.178.1', 41766): 2017-12-01 10:58:46 fauxmo:225 DEBUG b'M-SEARCH HTTP/1.1\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\nMX: 5\r\nST: urn:schemas-upnp-org:device:avm-aha:1\r\n\r\n' 2017-12-01 10:58:46 asyncio:1379 DEBUG poll took 154.827 ms: 1 events 2017-12-01 10:58:46 fauxmo:224 DEBUG Received data below from ('192.168.178.180', 50000): 2017-12-01 10:58:46 fauxmo:225 DEBUG b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: upnp:rootdevice\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n' 2017-12-01 10:58:46 fauxmo:265 DEBUG Sending response to ('192.168.178.180', 50000): HTTP/1.1 200 OK CACHE-CONTROL: max-age=86400 DATE: Fri, 01 Dec 2017 09:58:46 GMT EXT: LOCATION: http://192.168.178.2:49915/setup.xml OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01 01-NLS: d6b26f06-b7e8-4713-a0ce-26fcd2e55668 SERVER: Fauxmo, UPnP/1.0, Unspecified ST: urn:Belkin:device: USN: uuid:Socket-1_0-43b3ae40-0ab7-3efb-8425-a09656068511::urn:Belkin:device:

2017-12-01 10:58:46 asyncio:1379 DEBUG poll took 0.017 ms: 1 events 2017-12-01 10:58:46 fauxmo:224 DEBUG Received data below from ('192.168.178.180', 50000): 2017-12-01 10:58:46 fauxmo:225 DEBUG b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: ssdp:all\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n' 2017-12-01 10:58:46 fauxmo:265 DEBUG Sending response to ('192.168.178.180', 50000): HTTP/1.1 200 OK CACHE-CONTROL: max-age=86400 DATE: Fri, 01 Dec 2017 09:58:46 GMT EXT: LOCATION: http://192.168.178.2:49915/setup.xml OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01 01-NLS: 91996ff0-71a8-42a4-aae4-38c8115207f1 SERVER: Fauxmo, UPnP/1.0, Unspecified ST: urn:Belkin:device: USN: uuid:Socket-1_0-43b3ae40-0ab7-3efb-8425-a09656068511::urn:Belkin:device:

2017-12-01 10:58:46 asyncio:1379 DEBUG poll took 486.742 ms: 1 events 2017-12-01 10:58:46 fauxmo:224 DEBUG Received data below from ('192.168.178.180', 50000): 2017-12-01 10:58:46 fauxmo:225 DEBUG b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: upnp:rootdevice\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n' 2017-12-01 10:58:46 fauxmo:265 DEBUG Sending response to ('192.168.178.180', 50000): HTTP/1.1 200 OK CACHE-CONTROL: max-age=86400 DATE: Fri, 01 Dec 2017 09:58:46 GMT EXT: LOCATION: http://192.168.178.2:49915/setup.xml OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01 01-NLS: 0d0929e4-e570-4467-9e55-1104f71355af SERVER: Fauxmo, UPnP/1.0, Unspecified ST: urn:Belkin:device: USN: uuid:Socket-1_0-43b3ae40-0ab7-3efb-8425-a09656068511::urn:Belkin:device:

2017-12-01 10:58:46 asyncio:1379 DEBUG poll took 10.622 ms: 1 events 2017-12-01 10:58:46 fauxmo:224 DEBUG Received data below from ('192.168.178.180', 50000): 2017-12-01 10:58:46 fauxmo:225 DEBUG b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: ssdp:all\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n' 2017-12-01 10:58:46 fauxmo:265 DEBUG Sending response to ('192.168.178.180', 50000): HTTP/1.1 200 OK CACHE-CONTROL: max-age=86400 DATE: Fri, 01 Dec 2017 09:58:46 GMT EXT: LOCATION: http://192.168.178.2:49915/setup.xml OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01 01-NLS: d888ce95-e23d-432c-bd21-abebe7c022f1 SERVER: Fauxmo, UPnP/1.0, Unspecified ST: urn:Belkin:device: USN: uuid:Socket-1_0-43b3ae40-0ab7-3efb-8425-a09656068511::urn:Belkin:device:

2017-12-01 10:58:46 asyncio:1379 DEBUG poll took 31.564 ms: 1 events 2017-12-01 10:58:46 fauxmo:224 DEBUG Received data below from ('192.168.178.34', 50820): 2017-12-01 10:58:46 fauxmo:225 DEBUG b'M-SEARCH HTTP/1.1\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\nMX: 1\r\nST: urn:dial-multiscreen-org:service:dial:1\r\nUSER-AGENT: Google Chrome/62.0.3202.94 Windows\r\n\r\n' 2017-12-01 10:58:47 asyncio:1379 DEBUG poll took 999.642 ms: 1 events 2017-12-01 10:58:47 fauxmo:224 DEBUG Received data below from ('192.168.178.34', 50820): 2017-12-01 10:58:47 fauxmo:225 DEBUG b'M-SEARCH HTTP/1.1\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\nMX: 1\r\nST: urn:dial-multiscreen-org:service:dial:1\r\nUSER-AGENT: Google Chrome/62.0.3202.94 Windows\r\n\r\n' 2017-12-01 10:58:48 asyncio:1379 INFO poll took 1000.121 ms: 1 events 2017-12-01 10:58:48 fauxmo:224 DEBUG Received data below from ('192.168.178.34', 50820): 2017-12-01 10:58:48 fauxmo:225 DEBUG b'M-SEARCH * HTTP/1.1\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\nMX: 1\r\nST: urn:dial-multiscreen-org:service:dial:1\r\nUSER-AGENT: Google Chrome/62.0.3202.94 Windows\r\n\r\n' ^C2017-12-01 10:59:09 asyncio:1379 INFO poll took 20970.146 ms: 1 events 2017-12-01 10:59:09 fauxmo:143 DEBUG Shutdown starting... 2017-12-01 10:59:09 fauxmo:146 DEBUG Shutting down server 0... 2017-12-01 10:59:09 asyncio:489 DEBUG Close <_UnixSelectorEventLoop running=False closed=False debug=True>`

n8henrie commented 6 years ago

Can you confirm that 192.168.178.180 is the IP of your echo?

Monarch73 commented 6 years ago

@n8henrie I am trying to find any "offical" clues from amazon, that Echo2 still nativly supports wemo-switches. While doing so I found a statement from another echo2-user that alexa is actualy asking to activate the "wemo skill" when giving the command to detected new devices.

> "Did you enable the "smart home skill from the Alexa app" like Alexa is saying when you do the discover, is it the Wemo skill that needs enabling, its asking for a mac address and WIFI network name. Not sure if I need to do this ?"

I think the key to takle this issue is to get fauxmo to work on echo2 with the wemo-app and asking users to activate the wemo-skill

demvil commented 6 years ago

Yes .180 ist the echo.

To activate the wemo skill you need your WiFi ssid and the Mac address of one of the wemo devices. I tried the Mac of my server running fauxmo but with no success.

Monarch73 commented 6 years ago

@demvil Yes, they changed something in the detection protocol. I don't have an IPhone but the wemo-android-app seems to do its own detection and seems to be incompatible with fauxmo too. The wemo app is also unable to detect any fauxmo-devices.

That's why I am saying, key to resolve the issue is getting fauxmo to work with the wemo-app. I suppose that will resolve the issue for the wemo-skill auto-magically :-)

BetMadZac73 commented 6 years ago

Hiya, I have been using fauxmo for about 2 years with an Ecoo Dot and a Pi. I use it to control 433Mhz radio controlled sockets - so exactly like WeMo but much cheaper. So First point of order - Thank-you for developing and sharing this code, it's brilliant.

However recent Black Friday deals, I got the new Echo gen2, and hey guess what, the problems started as described by other users. I can confirm:-

When the original echo dot is online, any of the newer echo's will control the fauxmo devices as normal (on, off), but as soon as I take the original off-line the newer gen2 ones can not find the devices anymore. So the 'older echo dot' is acting as a bridge to send the commands.

Now - you might have noticed, its Christmas. usually I just throw some time switches on the plugs, but I got some more Energenie 433Mhz sockets , so I thought I will set up a fauxmo called "Christmas" and guess what, the new Gen2 echo can not find the device (even with the original dot online), but then when I ask the original dot to do the scan it finds it, registers it and the other echos can now turn Christmas on and off.

CONCLUSION the new Gen2 Echo's are using a different search/control for WeMo devices and so no longer compatible with fauxmo. But the good news is. If you can lay your hands on an older echo dot (I'd guess quite cheap second hand) as long as it is in the network then Alexa can 'find devices' running fauxmo, and all the echos (even the new ones) can control the fauxmo.

I was going to gift the old dot to my Mum, but now I'm going to keep it.

This is still the most elegant solution. I was about to do it the harder way by setting up a server on my Pi and exposing that to the world, so that I can write an Alexa Skill to send a post request to my server, enabling my raspberry Pi to respond to Alexa and also to then control devices. I intend to have a play anyway, because you can get the server to respond with text for Alexa to say, and I might have some fun with the kids using that as a bit of a trick. (i.e. Alexa, Ask Santa if I've been good? - and then send a bespoke message back, listing a number of misdemeanours, leaving them wondering how Alexa knows all this stuff)

n8henrie commented 6 years ago

My echo is now on 597462620 and my dot is on 597464620, discovery is now broken for me as well.

Those of you reporting issues with an Echo 2 -- does anyone have an actual Wemo device, and if so can you send me a pcap (i.e. Wireshark / tcpdump capture)?

In the meantime, users may consider HomeAssistant and its emulated_hue.

EDIT: Nope, I just forgot to turn off my firewall. Discovery still working perfectly.

n8henrie commented 6 years ago

@BetMadZac73 @Monarch73 @demvil I tried incorporating the setup xml from bitbucket.org/xoseperez/fauxmoesp into the issue_38 branch. Can you install that branch and see discovery works with your Echo 2?

BetMadZac73 commented 6 years ago

Installed the issue_38 Branch.

sudo pip install git+https://github.com/n8henrie/fauxmo.git@issue_38

restarted the Pi to ensure a clean environment, and unplugged the echo-dot (which is running same version as your dot btw).

started my test fauxmo and asked Alexa to discover devices, the terminal window was silent and Alex found nothing just the pooling loop started.

DEBUG:root:Listening for UPnP broadcasts DEBUG:root:got local address of 192.168.0.54 DEBUG:root:UPnP broadcast listener: new device registered DEBUG:root:FauxMo device 'test' ready on 192.168.0.54:52010 DEBUG:root:Entering fauxmo polling loop

plugged back in the dot - asked the dot to run discovery and then received the friendly DEBUG:root:Responding to search for test DEBUG:root:Responding to setup.xml for test

After this I was able to control my test fauxmo. (It's not you, it's them).

BTW - noticed that when you use the Alexa app (IOS) to control a switch, first it tries to discover the current state of the switch by contacting Belkin Intl - which of course fails and it tells you it failed, but then it will send subsequent on-off commands. I suspect this is what is happening when you speak to Alexa as well - the newer version is contacting Belkin.

I also tried to configure the WeMo app on IOS to find my fauxmo, but it did not like the MAC address (because of course it's not in the Belkin MAC address range).

I don't have any WeMo devices, so I can't test the real-side set-up, but as I mention I suspect what is happening here is that Belkin are asking Amazon to communicate via their servers, so that they (Belkin) can enrich their IOT offering, always knowing the state of a device etc... So far they have not moved the older Echo devices forwards so they are still communicating natively instead of going via Belkin Servers. I don't actually suppose they are trying to edge out the hobbyist - we are not hurting their market share, but it's a natural consequence of them wanting to develop their IOT offerings.

Personally I like to be able to control things locally and not relying on the Belkin servers to be responsive - but as Alexa needs the Amazon servers to be active in order to process the speech commands - when it comes down to it if the Internet is down - then you have to go manually control your devices.

However , if you can solve it (Find how Alexa is scanning and respond to it) maybe it is still workable, because Alexa has to run the scan locally it can't rely on the Belkin servers to scan the local network.

Monarch73 commented 6 years ago

@n8henrie I don't have an echo 2. But I have reports form other 2nd gen echo users that fauxmoesp does not work as well.

I think, as soon as it stops working for me too, I might go for buying a genuine wemo socket switch and analyse the network traffic.

Monarch73 commented 6 years ago

I just noticed, my echo has firmware version 597462620 too and fauxmoesp is working for me...

estauseb commented 6 years ago

I tried the issue_38 branch. This time you can see responses but the devices are still not discovered. Down below is the debug log.

pi@raspberrypi:~ $ "$(pyenv root)"/versions/3.6.1/bin/fauxmo -c config.json -vvv
2017-12-15 15:21:46 fauxmo:37       INFO     Fauxmo v0.4.5
2017-12-15 15:21:46 fauxmo:38       DEBUG    3.6.1 (default, Dec 15 2017, 14:46:57) 
[GCC 6.3.0 20170516]
2017-12-15 15:21:46 fauxmo:24       DEBUG    Attempting to get IP address automatically
2017-12-15 15:21:46 fauxmo:37       DEBUG    Using IP address: 10.217.0.10
2017-12-15 15:21:46 fauxmo:100      DEBUG    plugin_vars: {}
2017-12-15 15:21:46 fauxmo:103      DEBUG    device config: {'port': 12340, 'on_cmd': 'http://10.217.0.10/myserver/fakeswitches/01/on', 'off_cmd': 'http://10.217.0.10/myserver/fakeswitches/01/off', 'method': 'GET', 'name': 'fake switch one'}
2017-12-15 15:21:46 asyncio:1067     INFO     <Server sockets=[<socket.socket fd=7, family=AddressFamily.AF_INET, type=2049, proto=6, laddr=('10.217.0.10', 12340)>]> is serving
2017-12-15 15:21:46 fauxmo:121      DEBUG    Started fauxmo device: {'name': 'fake switch one', 'plugin': <fauxmo.plugins.simplehttpplugin.SimpleHTTPPlugin object at 0x76033150>}
2017-12-15 15:21:46 fauxmo:103      DEBUG    device config: {'port': 12341, 'on_cmd': 'http://localhost:54321/devices/garage%20light', 'off_cmd': 'http://localhost:54321/devices/garage%20light', 'on_data': {'isOn': 1}, 'off_data': {'isOn': 0}, 'user': 'this', 'password': 'that', 'method': 'PUT', 'name': 'fake Indigo switch'}
2017-12-15 15:21:46 asyncio:1067     INFO     <Server sockets=[<socket.socket fd=8, family=AddressFamily.AF_INET, type=2049, proto=6, laddr=('10.217.0.10', 12341)>]> is serving
2017-12-15 15:21:46 fauxmo:121      DEBUG    Started fauxmo device: {'name': 'fake Indigo switch', 'plugin': <fauxmo.plugins.simplehttpplugin.SimpleHTTPPlugin object at 0x75ece410>}
2017-12-15 15:21:46 fauxmo:103      DEBUG    device config: {'name': 'fake home assistant switch by REST API', 'port': 12342, 'on_cmd': 'http://192.168.1.104:8123/api/services/switch/turn_on', 'off_cmd': 'http://192.168.1.104:8123/api/services/switch/turn_off', 'method': 'POST', 'headers': {'x-ha-access': 'your_hass_password'}, 'on_data': {'entity_id': 'switch.fake_hass_switch'}, 'off_data': {'entity_id': 'switch.fake_hass_switch'}}
2017-12-15 15:21:46 asyncio:1067     INFO     <Server sockets=[<socket.socket fd=9, family=AddressFamily.AF_INET, type=2049, proto=6, laddr=('10.217.0.10', 12342)>]> is serving
2017-12-15 15:21:46 fauxmo:121      DEBUG    Started fauxmo device: {'name': 'fake home assistant switch by REST API', 'plugin': <fauxmo.plugins.simplehttpplugin.SimpleHTTPPlugin object at 0x75d2d470>}
2017-12-15 15:21:46 fauxmo:123      INFO     Starting UDP server
2017-12-15 15:21:46 asyncio:947      DEBUG    Datagram endpoint remote_addr=None created: (<_SelectorDatagramTransport fd=10 read=idle write=<idle, bufsize=0>>, <fauxmo.protocols.SSDPServer object at 0x75ebe3b0>)
2017-12-15 15:21:51 asyncio:1379     INFO     poll took 4510.852 ms: 1 events
2017-12-15 15:21:51 fauxmo:241      DEBUG    Received data below from ('10.217.0.9', 50000):
2017-12-15 15:21:51 fauxmo:242      DEBUG    b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: ssdp:all\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n'
2017-12-15 15:21:51 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:51 GMT
EXT:
LOCATION: http://10.217.0.10:12340/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 138ea84b-3de0-4702-bcdb-2a32976df704
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-2d4ac336-8683-3660-992a-d056b5382a8d::urn:Belkin:device:**

2017-12-15 15:21:51 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:51 GMT
EXT:
LOCATION: http://10.217.0.10:12341/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 823ee771-436d-428c-afee-c81668a0c20a
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-85a333cd-bad0-370b-b7d0-0d63a93d3c5c::urn:Belkin:device:**

2017-12-15 15:21:51 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:51 GMT
EXT:
LOCATION: http://10.217.0.10:12342/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 5843eb42-deab-4494-a8e4-51a343094011
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-461fc124-43ce-39cd-b84b-ef856086ad64::urn:Belkin:device:**

2017-12-15 15:21:51 asyncio:1379     DEBUG    poll took 0.131 ms: 1 events
2017-12-15 15:21:51 fauxmo:241      DEBUG    Received data below from ('10.217.0.9', 50000):
2017-12-15 15:21:51 fauxmo:242      DEBUG    b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: upnp:rootdevice\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n'
2017-12-15 15:21:51 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:51 GMT
EXT:
LOCATION: http://10.217.0.10:12340/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 0eed7118-2f90-47a0-a81b-e6a816e53b14
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-2d4ac336-8683-3660-992a-d056b5382a8d::urn:Belkin:device:**

2017-12-15 15:21:51 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:51 GMT
EXT:
LOCATION: http://10.217.0.10:12342/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 50dec72e-fdb1-42fa-97d0-931511b79ffc
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-461fc124-43ce-39cd-b84b-ef856086ad64::urn:Belkin:device:**

2017-12-15 15:21:51 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:51 GMT
EXT:
LOCATION: http://10.217.0.10:12341/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 540d027f-55cb-4b00-ae7b-0edadc06e15c
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-85a333cd-bad0-370b-b7d0-0d63a93d3c5c::urn:Belkin:device:**

2017-12-15 15:21:51 asyncio:1379     DEBUG    poll took 486.669 ms: 1 events
2017-12-15 15:21:51 fauxmo:241      DEBUG    Received data below from ('10.217.0.9', 50000):
2017-12-15 15:21:51 fauxmo:242      DEBUG    b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: ssdp:all\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n'
2017-12-15 15:21:51 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:51 GMT
EXT:
LOCATION: http://10.217.0.10:12340/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 2da491fc-01e7-4ed4-8d9f-43d2df19ce57
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-2d4ac336-8683-3660-992a-d056b5382a8d::urn:Belkin:device:**

2017-12-15 15:21:51 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:51 GMT
EXT:
LOCATION: http://10.217.0.10:12341/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 8ee6553d-73fa-464e-91fd-66e8dcd9615a
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-85a333cd-bad0-370b-b7d0-0d63a93d3c5c::urn:Belkin:device:**

2017-12-15 15:21:51 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:51 GMT
EXT:
LOCATION: http://10.217.0.10:12342/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 443e5ce7-9c1a-4f9c-b2a0-19da9b18f274
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-461fc124-43ce-39cd-b84b-ef856086ad64::urn:Belkin:device:**

2017-12-15 15:21:52 asyncio:1379     DEBUG    poll took 911.315 ms: 1 events
2017-12-15 15:21:52 fauxmo:241      DEBUG    Received data below from ('10.217.0.9', 50000):
2017-12-15 15:21:52 fauxmo:242      DEBUG    b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: ssdp:all\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n'
2017-12-15 15:21:52 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:52 GMT
EXT:
LOCATION: http://10.217.0.10:12342/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 6a4e4253-4e6a-4095-9d1a-3abaad2ff515
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-461fc124-43ce-39cd-b84b-ef856086ad64::urn:Belkin:device:**

2017-12-15 15:21:52 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:52 GMT
EXT:
LOCATION: http://10.217.0.10:12340/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 343c41fe-1892-429e-b1c4-34101e2266fa
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-2d4ac336-8683-3660-992a-d056b5382a8d::urn:Belkin:device:**

2017-12-15 15:21:52 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:52 GMT
EXT:
LOCATION: http://10.217.0.10:12341/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 0971db05-ebb6-4ff9-91d1-b59e20787c8d
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-85a333cd-bad0-370b-b7d0-0d63a93d3c5c::urn:Belkin:device:**

2017-12-15 15:21:52 asyncio:1379     DEBUG    poll took 0.119 ms: 1 events
2017-12-15 15:21:52 fauxmo:241      DEBUG    Received data below from ('10.217.0.9', 50000):
2017-12-15 15:21:52 fauxmo:242      DEBUG    b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: upnp:rootdevice\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n'
2017-12-15 15:21:52 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:52 GMT
EXT:
LOCATION: http://10.217.0.10:12341/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 62ee2aae-bdd2-4282-8ab4-0ba1bcf11aae
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-85a333cd-bad0-370b-b7d0-0d63a93d3c5c::urn:Belkin:device:**

2017-12-15 15:21:52 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:52 GMT
EXT:
LOCATION: http://10.217.0.10:12340/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: e8b300b3-6a3d-44de-8a0b-3e7dbfaa51cb
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-2d4ac336-8683-3660-992a-d056b5382a8d::urn:Belkin:device:**

2017-12-15 15:21:52 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:52 GMT
EXT:
LOCATION: http://10.217.0.10:12342/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 23fd7501-bd48-42cb-adf0-7ad4ce78a155
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-461fc124-43ce-39cd-b84b-ef856086ad64::urn:Belkin:device:**

2017-12-15 15:21:53 asyncio:1379     DEBUG    poll took 495.535 ms: 1 events
2017-12-15 15:21:53 fauxmo:241      DEBUG    Received data below from ('10.217.0.9', 50000):
2017-12-15 15:21:53 fauxmo:242      DEBUG    b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: ssdp:all\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n'
2017-12-15 15:21:53 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:53 GMT
EXT:
LOCATION: http://10.217.0.10:12340/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: e19e9fc0-819a-48eb-bd69-56476335454a
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-2d4ac336-8683-3660-992a-d056b5382a8d::urn:Belkin:device:**

2017-12-15 15:21:53 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:53 GMT
EXT:
LOCATION: http://10.217.0.10:12342/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: c431bf12-da54-4d39-a057-07bb1ccfa7f6
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-461fc124-43ce-39cd-b84b-ef856086ad64::urn:Belkin:device:**

2017-12-15 15:21:53 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:53 GMT
EXT:
LOCATION: http://10.217.0.10:12341/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 19924cb2-ca5c-454c-949d-a66fa267a69b
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-85a333cd-bad0-370b-b7d0-0d63a93d3c5c::urn:Belkin:device:**

2017-12-15 15:21:53 asyncio:1379     DEBUG    poll took 0.119 ms: 1 events
2017-12-15 15:21:53 fauxmo:241      DEBUG    Received data below from ('10.217.0.9', 50000):
2017-12-15 15:21:53 fauxmo:242      DEBUG    b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: upnp:rootdevice\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n'
2017-12-15 15:21:53 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:53 GMT
EXT:
LOCATION: http://10.217.0.10:12341/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: fca7a381-3dc0-4d56-aa65-bdd4f677a283
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-85a333cd-bad0-370b-b7d0-0d63a93d3c5c::urn:Belkin:device:**

2017-12-15 15:21:53 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:53 GMT
EXT:
LOCATION: http://10.217.0.10:12342/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 971b1cfd-cd4a-4da3-86ee-7a30b19797c4
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-461fc124-43ce-39cd-b84b-ef856086ad64::urn:Belkin:device:**

2017-12-15 15:21:53 fauxmo:282      DEBUG    Sending response to ('10.217.0.9', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 15 Dec 2017 14:21:53 GMT
EXT:
LOCATION: http://10.217.0.10:12340/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 06f039d3-7cd9-42f7-8979-a67501e57d87
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-2d4ac336-8683-3660-992a-d056b5382a8d::urn:Belkin:device:**

^C2017-12-15 15:22:08 asyncio:1379     INFO     poll took 14651.496 ms: 1 events
2017-12-15 15:22:08 fauxmo:143      DEBUG    Shutdown starting...
SK8081 commented 6 years ago

Unfortunately, I saw these comments after I installed and got fauxmo running. I have a new Echo plus and it doesn't discover. I see the SSDP traffic in my -vvv output but no discovery is actually finished.

schnudeldudel commented 6 years ago

Same issue here with latest ECHO PLUS Gen2 - Firmware-Version 595530520. RPi3 with fauxmo 0.4.5 is not responding to "b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: ssdp:all\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"" requests at all.

schnudeldudel commented 6 years ago

Please tell me if I can, and how I can support here with further debug logs etc. Really looking forward to get fauxmo running...

AshZS commented 6 years ago

@BetMadZac73 Hi. I too have some Energenie power plugs and looking to setup Echo Dot to control them via 433MHz from RaspberryPi with Fauxmo. Would you mind sharing code on how you accomplished this please?

BetMadZac73 commented 6 years ago

Hi AshZS,

Unfortunately I was not extremely organised when I first set this up, So I can tell you 'how' and share some bits of code, but some I am missing.

You will need 433MHz transmitter/receiver (very cheap online, receiver needed only to decode the hand-held remote) 433Utils - by ninjaBlocks Astral - by STFJunkie and of course Fauxmo plus (some patience with me, because I work these things out, but I'm not an expert this was my first python coding).

I learnt along the way - get your Pi to restart everyday using cron (it's just neater and cleaner I restart at 03:05). Consider logging (see the nighttime.py example later) to the /tmp so it's easy to check that your automation is running properly) You will need to attach a short wire to the 433Mhz transmitter where the Arial connector is, otherwise the sockets won't always hear the commands, but with a wire the transmission will reach though walls fine.

First off - 433Mhz - I got a receiver and a transmitter board (I think it cost me about £2.50 for 3 of each), Then I used an Arduino to receive and interpret the Energenie remote codes (You will be able to do this using the PI, the Utils does have a sniffer for this - Also I lost the Arduino Sketch when the Hard-drive on My MacBook died). Anyway - armed with the 433MHz codes (each Energenie remote is using different codes) I did the following:-

Install 433Utils on the PI - https://github.com/ninjablocks/433Utils Follow the instructions to get set-up (installing wiringpi as well) then test out the transmit/receive.

Next Install Astral - https://github.com/sffjunkie/astral. (This is only required if you like to be able to calculate Sunset and Sunrise times - which is handy for getting the Pi to schedule on/off but move automatically every day as the Sunrise/Sunset move) - I set some lights on 1 hour before sunset as it's already getting darker) - I then schedule this daily with cron, it writes to a /tmp file so I can check it. `""" night_time.py This will use Astral module to check the time night starts """ from astral import * import datetime from datetime import datetime import time import os import logging logging.basicConfig(filename='/tmp/night_time.log',level=logging.DEBUG)

ast = Astral() l = Location(('Town_name', 'UK', 53.14, -1.25, 'Europe/London', 0)) l.sun() sun = l.sun()

nowtime = datetime.now() sunset = sun['sunset']

now = ('%02d%02d' % (nowtime.hour, nowtime.minute)) sun = ('%02d%02d' % (sunset.hour - 1, sunset.minute))

a = 1 while a == 1 : nowtime = datetime.now() now = ('%02d%02d' % (nowtime.hour, nowtime.minute)) if now < sun: print "it is still daytime" print('now %s sunset %s' % (now, sun)) logging.info('%s WAITING time is %s and sunset -1hr is %s' % (nowtime,now,sun)) time.sleep(60) else: print "it is now night" logging.info('%s LIGHTS-ON time is %s and sunset -1hr is %s' % (nowtime,now,sun)) break os.system("python /home/pi/python/lights_on.py")`

The contents of the "lights_on.py" are below (I throw the switch off first, and then send the on signal twice just to be sure. `""" lights_on.py Fairly simple this will first send the off codes, then the on codes for switch code 1 it is 851983 is on and 851982 is off """ import time import os

os.system("/home/pi/433Utils/RPi_utils/codesend 851982") time.sleep(0.1) os.system("/home/pi/433Utils/RPi_utils/codesend 851983") time.sleep(0.1) os.system("/home/pi/433Utils/RPi_utils/codesend 851983")`

You should create short python scripts for turning on and off whichever devices you want, remember with energenie you can pair the sockets to the same button or to different buttons or to different ones (also the sockets will remember a code from another controller as well i.e. they can be controlled by 2 different codes which might be handy when you have multiple sets).

The rest is just straight-forward use of the fauxmo set-up, when you receive an on or off command from Alexa you execute your on or off python command from the fauxmo session.

You could (if you are interested to do this) hook up both the transmitter and receiver to the Pi, then listen for signals all the time, this way you can make sure the Pi always knows the on/off state of the sockets whether they are controlled by Alex/pi or by the hand-held remote.

By-The-Way - check Amazon, as Energenie have released their MiHome-Hub and they also sell Pi-Boards for the transmission of 433Mhz. I know this is about cracking it with Pi, but I mention it, because My Mum has Energenie sockets already but I am not setting a Pi up at her house, because let's face it - Mums break tech all the time, she is getting an Echo and a MiHome Hum with 3 extra sockets for Christmas (And I am already anticipating my regret!!).

n8henrie commented 6 years ago

@AshZS They're a little older now, but I've written up a few posts on getting 433 working with the Pi -- you may consider giving them a look in addition to the info @BetMadZac73 has provided.

That said, let's not clutter this issue with unrelated discussion.

I still don't have an Echo Plus (and don't plan to get one, since I don't have any Zigbee devices and my Echo works just fun), so I have no practical way of even trying to resolve this issue right now. Sorry folks.

If someone can get me a pcap of the Echo 2 interacting with a Belkin WeMo, that would be a good start. Until then...

jcarley commented 6 years ago

I have an Echo Plus and would be willing to purchase a Belkin WeMo device to capture a pcap if somebody wants to help me through it. Will any WeMo device do? I was thinking about getting something like this (because its the cheapest). http://www.belkin.com/us/F7C063-Belkin/p/P-F7C063/

I have Wireshark installed on my Mac already. What isn't clear to me is how to set it up to get the pcap (or any other desired output). Any advice or good articles that anybody can recommend?

ronny130286 commented 6 years ago

If i read the log correctly (https://github.com/n8henrie/fauxmo/issues/38#issuecomment-352018492), it seems that the setup.xml was not send, normally must "Fauxmo response to setup request" stand in the log or?

n8henrie commented 6 years ago

@jcarley It's tough to say for sure, but I would think that WeMo plug would work.

Basically, to start you'll want to figure out the IP address and MAC address for the WeMo plug, then use WireShark filters to only capture or display information from that address.

You should look at the official docs on filtering, display filtering and capture filtering. If memory serves, capture filtering may only be possible by MAC address (not IP address), but I could have that backwards.

What I would do is set it up so that the switch seems to be working, then set up your filters so you can toggle the switch on and off to make sure your filters are capturing information. Then clear out your WireShark log, reset your WeMo switch to factory settings, start capturing, then set up the WeMo device from scratch while capturing.

I think that should do it. Unfortunately I don't think this method will capture the initial broadcast message from the Echo (since it is not to or from the WeMo address, but instead is a broadcast to all local devices), but I think we should be able to glean that from the fauxmo logs.

jcarley commented 6 years ago

@n8henrie Thanks. I ordered a plug yesterday (12/27). It'll be here tomorrow (12/29). I'll mess around with the package capture and see what I come up with. I'm hoping I can grab everything that the plug responds with. When I have something, I'll post here.

I also have a Philips Hue lightbulb. But thats a Zigbee device. My understanding is that Zigbee is a radio waves type of communication. Can't use Wireshark for that. If there is anything there I can help with let me know.

Monarch73 commented 6 years ago

@n8henrie I have a POC ready to emulate a Phillips Hue Bridge that has two lights connected to it. Maybe you want to take a look at it. Emulating Hue has the advantage of no longer being dependant on wemo support by alexa.

https://github.com/Monarch73/org.huesken.hueemu It is written in C# but should be quite readable.

ronny130286 commented 6 years ago

maybe the solution i my case the Echo Plus find all of my devices, please try an report

Edit protocols.py following lines

def data_received(self, data: bytes) -> None:
        msg = data.decode()

        logger.debug(f"Received message:\n{msg}")
        if msg.startswith('GET /setup.xml HTTP/1.1'):
            logger.info("setup.xml requested by Echo")
            self.handle_setup()

    #Fix for Issues 38
        elif '/eventservice.xml' in msg:
            logger.info("eventservice.xml request by Echo")
            self.handle_event()
    #End    

        elif msg.startswith('POST /upnp/control/basicevent1 HTTP/1.1'):
            self.handle_action(msg)
#Fix for Issues 38        
def handle_event(self) -> None:

        eventservice_xml = ('<scpd xmlns="urn:Belkin:service-1-0">'
                            '<actionList>'
                            '<action>'
                            '<name>SetBinaryState</name>'
                            '<argumentList>'
                            '<argument>'
                            '<retval/>'
                            '<name>BinaryState</name>'
                            '<relatedStateVariable>BinaryState</relatedStateVariable>'
                            '<direction>in</direction>'
                            '</argument>'
                            '</argumentList>'
                            '</action>'
                            '<action>'
                            '<name>GetBinaryState</name>'
                            '<argumentList>'
                            '<argument>'
                            '<retval/>'
                            '<name>BinaryState</name>'
                            '<relatedStateVariable>BinaryState</relatedStateVariable>'
                            '<direction>out</direction>'
                            '</argument>'
                            '</argumentList>'
                            '</action>'
                            '</actionList>'
                            '<serviceStateTable>'
                            '<stateVariable sendEvents="yes">'
                            '<name>BinaryState</name>'
                            '<dataType>Boolean</dataType>'
                            '<defaultValue>0</defaultValue>'
                            '</stateVariable>'
                            '<stateVariable sendEvents="yes">'
                            '<name>level</name>'
                            '<dataType>string</dataType>'
                            '<defaultValue>0</defaultValue>'
                            '</stateVariable>'
                            '</serviceStateTable>'
                            '</scpd>\r\n\r\n'
                            )

        logger.debug(f"Fauxmo response to setup request:\n{eventservice_xml}")
        self.transport.write(eventservice_xml.encode())
        self.transport.close()
    #end

and

def respond_to_search(self, addr: Tuple[str, int]) -> None:
        """Build and send an appropriate response to an SSDP search request.

        Args:
            addr: Address sending search request
        """
        date_str = formatdate(timeval=None, localtime=False, usegmt=True)
        for device in self.devices:

            name = device.get('name')
            ip_address = device.get('ip_address')
            port = device.get('port')

            location = f'http://{ip_address}:{port}/setup.xml'
            serial = make_serial(name)
            response = '\n'.join([
                'HTTP/1.1 200 OK',
                'CACHE-CONTROL: max-age=86400',
                f'DATE: {date_str}',
                'EXT:',
                f'LOCATION: {location}',
                'OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01',
                f'01-NLS: {uuid.uuid4()}',
                'SERVER: Fauxmo, UPnP/1.0, Unspecified',
                'ST: urn:Belkin:device:**',
                f'USN: uuid:Socket-1_0-{serial}::upnp:rootdevice',
                ]) + '\n\n'

            logger.debug(f"Sending response to {addr}:\n{response}")
            self.transport.sendto(response.encode(), addr)
        random.shuffle(self.devices)

At this time i have only 1 prob with the state from device, i can control the gpio with commandline plugin (sucessfully change gpio between high/low) , but the state was not corect

n8henrie commented 6 years ago

@jcarley if you're not very familiar with it, you might consider emailing the pcap to me instead of publicly posting; I would be concerned that there could be some private info in it.

Net-Eng-05 commented 6 years ago

I'd like to see if there are requests going to Belkin from Alexa during the discovery. I'm curious if I could fake a response via some DNS entries on my firewall. Essentially, make Alexa think that Belkin is responding.

I'll setup a test network and run some packet captures myself. I do not have a Wemo device to test with though.

n8henrie commented 6 years ago

I saw a minor change that @ronny130286 had in his reportedly working config and pulled this into issue_38. Would our Echo Plus crowd be willing to update to the latest commit on the issue_38 branch and report back? cc @BetMadZac73 @Monarch73 @demvil

nbabaka commented 6 years ago

Hi. With @ronny130286 fixes I still have a problem with discovery. I used sample config & Echo g2. it send response for setup.xml, then send response for eventservice.xml and got request for metainfoservice.xml and nothing =( I just started with it. May be I used wrong config?

n8henrie commented 6 years ago

@nbabaka Can you post the actual logs?

nbabaka commented 6 years ago
2017-12-29 12:04:41 fauxmo:37       INFO     Fauxmo v0.4.5
2017-12-29 12:04:41 fauxmo:38       DEBUG    3.6.4 (default, Dec 25 2017, 14:57:46)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]
2017-12-29 12:04:41 fauxmo:46       INFO     Using config: config.json
2017-12-29 12:04:41 fauxmo:24       DEBUG    Attempting to get IP address automatically
2017-12-29 12:04:41 fauxmo:37       DEBUG    Using IP address: 10.0.0.138
2017-12-29 12:04:41 fauxmo:100      DEBUG    plugin_vars: {}
2017-12-29 12:04:41 fauxmo:103      DEBUG    device config: {'port': 12341, 'on_cmd': 'http://192.168.1.104/myserver/fakeswitches/01/on', 'off_cmd': 'http://192.168.1.104/myserver/fakeswitches/01/off', 'method': 'GET', 'name': 'fake switch one'}
2017-12-29 12:04:41 asyncio:1068     INFO     <Server sockets=[<socket.socket fd=10, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('10.0.0.138', 12341)>]> is serving
2017-12-29 12:04:41 fauxmo:121      DEBUG    Started fauxmo device: {'name': 'fake switch one', 'plugin': <fauxmo.plugins.simplehttpplugin.SimpleHTTPPlugin object at 0x10be40e48>}
2017-12-29 12:04:41 fauxmo:123      INFO     Starting UDP server
2017-12-29 12:04:41 asyncio:948      DEBUG    Datagram endpoint remote_addr=None created: (<_SelectorDatagramTransport fd=11 read=idle write=<idle, bufsize=0>>, <fauxmo.protocols.SSDPServer object at 0x10be00630>)
2017-12-29 12:04:48 asyncio:1385     INFO     poll took 7072.046 ms: 1 events
2017-12-29 12:04:48 fauxmo:291      DEBUG    Received data below from ('10.0.0.104', 50000):
2017-12-29 12:04:48 fauxmo:292      DEBUG    b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: ssdp:all\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n'
2017-12-29 12:04:48 fauxmo:333      DEBUG    Sending response to ('10.0.0.104', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 29 Dec 2017 17:04:48 GMT
EXT:
LOCATION: http://10.0.0.138:12341/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 7087ca70-9ef0-4c7a-9f4a-3dc9ddd1064d
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-2d4ac336-8683-3660-992a-d056b5382a8d::upnp:rootdevice

2017-12-29 12:04:48 asyncio:1385     DEBUG    poll took 0.022 ms: 1 events
2017-12-29 12:04:48 fauxmo:291      DEBUG    Received data below from ('10.0.0.104', 50000):
2017-12-29 12:04:48 fauxmo:292      DEBUG    b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: upnp:rootdevice\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n'
2017-12-29 12:04:48 fauxmo:333      DEBUG    Sending response to ('10.0.0.104', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 29 Dec 2017 17:04:48 GMT
EXT:
LOCATION: http://10.0.0.138:12341/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 27928a91-53fe-4d90-8d8e-a988cf8a5a50
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-2d4ac336-8683-3660-992a-d056b5382a8d::upnp:rootdevice

2017-12-29 12:04:48 asyncio:1385     DEBUG    poll took 154.308 ms: 1 events
2017-12-29 12:04:48 asyncio:182      DEBUG    <Server sockets=[<socket.socket fd=10, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('10.0.0.138', 12341)>]> got a new connection from ('10.0.0.104', 58245): <socket.socket fd=12, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('10.0.0.138', 12341), raddr=('10.0.0.104', 58245)>
2017-12-29 12:04:48 fauxmo:39       DEBUG    Connection made with: ('10.0.0.104', 58245)
2017-12-29 12:04:48 fauxmo:45       DEBUG    Received message:
GET /setup.xml HTTP/1.1
Host: 10.0.0.138:12341
Connection: Keep-Alive
User-Agent: Android/5.1.1 UPnP/1.0 Cling/2.0

2017-12-29 12:04:48 fauxmo:47       INFO     setup.xml requested by Echo
2017-12-29 12:04:48 fauxmo:156      DEBUG    Fauxmo response to setup request:
HTTP/1.1 200 OK
CONTENT-LENGTH: 955
CONTENT-TYPE: text/xml
DATE: Fri, 29 Dec 2017 17:04:48 GMT
LAST-MODIFIED: Sat, 01 Jan 2000 00:01:15 GMT
SERVER: Unspecified, UPnP/1.0, Unspecified
X-User-Agent: Fauxmo
CONNECTION: close

<?xml version="1.0"?><root><specVersion><major>1</major><minor>0</minor></specVersion><device><deviceType>urn:Belkin:device:controllee:1</deviceType><friendlyName>fake switch one</friendlyName><manufacturer>Belkin International Inc.</manufacturer><modelName>Emulated Socket</modelName><modelNumber>3.1415</modelNumber><UDN>uuid:Socket-1_0-2d4ac336-8683-3660-992a-d056b5382a8d</UDN><serviceList><service><serviceType>urn:Belkin:service:basicevent:1</serviceType><serviceId>urn:Belkin:serviceId:basicevent1</serviceId><controlURL>/upnp/control/basicevent1</controlURL><eventSubURL>/upnp/event/basicevent1</eventSubURL><SCPDURL>/eventservice.xml</SCPDURL></service><service><serviceType>urn:Belkin:service:metainfo:1</serviceType><serviceId>urn:Belkin:serviceId:metainfo1</serviceId><controlURL>/upnp/control/metainfo1</controlURL><eventSubURL>/upnp/event/metainfo1</eventSubURL><SCPDURL>/metainfoservice.xml</SCPDURL></service></serviceList></device></root>
2017-12-29 12:04:49 asyncio:1385     DEBUG    poll took 124.776 ms: 1 events
2017-12-29 12:04:49 asyncio:182      DEBUG    <Server sockets=[<socket.socket fd=10, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('10.0.0.138', 12341)>]> got a new connection from ('10.0.0.104', 42853): <socket.socket fd=12, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('10.0.0.138', 12341), raddr=('10.0.0.104', 42853)>
2017-12-29 12:04:49 fauxmo:39       DEBUG    Connection made with: ('10.0.0.104', 42853)
2017-12-29 12:04:49 asyncio:1385     DEBUG    poll took 12.325 ms: 1 events
2017-12-29 12:04:49 fauxmo:45       DEBUG    Received message:
GET /eventservice.xml HTTP/1.1
Host: 10.0.0.138:12341
Connection: Keep-Alive
User-Agent: Android/5.1.1 UPnP/1.0 Cling/2.0

2017-12-29 12:04:49 fauxmo:52       INFO     eventservice.xml request by Echo
2017-12-29 12:04:49 fauxmo:103      DEBUG    Fauxmo response to setup request:
<scpd xmlns="urn:Belkin:service-1-0"><actionList><action><name>SetBinaryState</name><argumentList><argument><retval/><name>BinaryState</name><relatedStateVariable>BinaryState</relatedStateVariable><direction>in</direction></argument></argumentList></action><action><name>GetBinaryState</name><argumentList><argument><retval/><name>BinaryState</name><relatedStateVariable>BinaryState</relatedStateVariable><direction>out</direction></argument></argumentList></action></actionList><serviceStateTable><stateVariable sendEvents="yes"><name>BinaryState</name><dataType>Boolean</dataType><defaultValue>0</defaultValue></stateVariable><stateVariable sendEvents="yes"><name>level</name><dataType>string</dataType><defaultValue>0</defaultValue></stateVariable></serviceStateTable></scpd>

2017-12-29 12:04:49 asyncio:1385     DEBUG    poll took 49.849 ms: 1 events
2017-12-29 12:04:49 asyncio:182      DEBUG    <Server sockets=[<socket.socket fd=10, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('10.0.0.138', 12341)>]> got a new connection from ('10.0.0.104', 37181): <socket.socket fd=12, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('10.0.0.138', 12341), raddr=('10.0.0.104', 37181)>
2017-12-29 12:04:49 fauxmo:39       DEBUG    Connection made with: ('10.0.0.104', 37181)
2017-12-29 12:04:49 fauxmo:45       DEBUG    Received message:
GET /metainfoservice.xml HTTP/1.1
Host: 10.0.0.138:12341
Connection: Keep-Alive
User-Agent: Android/5.1.1 UPnP/1.0 Cling/2.0

2017-12-29 12:04:49 asyncio:1385     DEBUG    poll took 144.067 ms: 1 events
2017-12-29 12:04:49 fauxmo:291      DEBUG    Received data below from ('10.0.0.104', 50000):
2017-12-29 12:04:49 fauxmo:292      DEBUG    b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: upnp:rootdevice\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n'
2017-12-29 12:04:49 fauxmo:333      DEBUG    Sending response to ('10.0.0.104', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 29 Dec 2017 17:04:49 GMT
EXT:
LOCATION: http://10.0.0.138:12341/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 3a307615-0d2c-4d17-9058-a4bbd1f2b634
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-2d4ac336-8683-3660-992a-d056b5382a8d::upnp:rootdevice

2017-12-29 12:04:49 asyncio:1385     DEBUG    poll took 508.804 ms: 1 events
2017-12-29 12:04:49 fauxmo:291      DEBUG    Received data below from ('10.0.0.104', 50000):
2017-12-29 12:04:49 fauxmo:292      DEBUG    b'M-SEARCH * HTTP/1.1\r\nMX: 3\r\nST: ssdp:all\r\nHOST: 239.255.255.250:1900\r\nMAN: "ssdp:discover"\r\n\r\n'
2017-12-29 12:04:49 fauxmo:333      DEBUG    Sending response to ('10.0.0.104', 50000):
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Fri, 29 Dec 2017 17:04:49 GMT
EXT:
LOCATION: http://10.0.0.138:12341/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: a5c5f9be-fadd-4ee0-b5c5-293166b62fb8
SERVER: Fauxmo, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-2d4ac336-8683-3660-992a-d056b5382a8d::upnp:rootdevice
nbabaka commented 6 years ago

I just added this code:

    def handle_metainfo(self) -> None:
        metainfo = ('<scpd xmlns="urn:Belkin:service-1-0">'
                    '<specVersion>'
                    '<major>1</major>'
                    '<minor>0</minor>'
                    '</specVersion>'
                    '<actionList>'
                    '<action>'
                    '<name>GetMetaInfo</name>'
                    '<argumentList>'
                    '<retval />'
                    '<name>GetMetaInfo</name>'
                    '<relatedStateVariable>MetaInfo</relatedStateVariable>'
                    '<direction>in</direction>'
                    '</argumentList>'
                    '</action>'
                    '</actionList>'
                    '<serviceStateTable>'
                    '<stateVariable sendEvents="yes">'
                    '<name>MetaInfo</name>'
                    '<dataType>string</dataType>'
                    '<defaultValue>0</defaultValue>'
                    '</stateVariable>'
                    '</serviceStateTable>'
                    '</scpd>\r\n\r\n')
        logger.debug(f"Fauxmo response to setup request:\n{metainfo}")
        self.transport.write(metainfo.encode())
        self.transport.close()

and change this -

    def data_received(self, data: bytes) -> None:
        msg = data.decode()

        logger.debug(f"Received message:\n{msg}")
        if msg.startswith('GET /setup.xml HTTP/1.1'):
            logger.info("setup.xml requested by Echo")
            self.handle_setup()

    #Fix for Issues 38
        elif '/eventservice.xml' in msg:
            logger.info("eventservice.xml request by Echo")
            self.handle_event()
    #End    
        elif '/metainfoservice.xml' in msg:
            logger.info("metainfoservice.xml request by Echo")
            self.handle_metainfo()
        elif msg.startswith('POST /upnp/control/basicevent1 HTTP/1.1'):
            logger.info("request BasicEvent1")
            self.handle_action(msg)

And Echo found my device!

Syberteck commented 6 years ago

https://github.com/Syberteck/esp8266-Smart-Plug

I have 1 Echo Plus, 1 Echo and 2 Echo Dots. All 2nd generation. File is verified and working. Voice command and button. Flashed on a Sonoff S20.

Monarch73 commented 6 years ago

@nbabaka Awesome work!

n8henrie commented 6 years ago

@Monarch73 -- so are you confirming that this works for you on your Echo Plus?

ronny130286 commented 6 years ago

In my setup.xml i dont use the metainfoservice.xml ;)

setup_xml = ('<?xml version="1.0"?>'
                '<root>'
                '<specVersion><major>1</major><minor>0</minor></specVersion>'
                '<device>'
                '<deviceType>urn:Belkin:device:controllee:1</deviceType>'
                f'<friendlyName>{self.name}</friendlyName>'
                '<manufacturer>Belkin International Inc.</manufacturer>'
                '<modelName>Socket</modelName>'
                '<modelNumber>3.1415</modelNumber>'
                '<modelDescription>Belkin Plugin Socket 1.0</modelDescription>'
                f'<UDN>uuid:Socket-1_0-{self.serial}</UDN>'
                '<serialNumber>221517K0101769</serialNumber>'
                '<binaryState>0</binaryState>'
                '<serviceList>'
                '<service>'
                '<serviceType>urn:Belkin:service:basicevent:1</serviceType>'
                '<serviceId>urn:Belkin:serviceId:basicevent1</serviceId>'
                '<controlURL>/upnp/control/basicevent1</controlURL>'
                '<eventSubURL>/upnp/event/basicevent1</eventSubURL>'
                '<SCPDURL>/eventservice.xml</SCPDURL>'
                '</service>'
                '</serviceList>'
                '</device>'
                '</root>'
            )

I am use the same setup.xml link: https://github.com/Syberteck/esp8266-Smart-Plug

I am tested the code (without metainfoservice.xml) with Echo Plus and Echo G2, maybe if use the setup.xml with der meta...xml so you must define this one.

Does anyone have an idea how to get it solved with the commandline plugin, the correct status?

TIPP: During my tests, I noticed that my echo, if i make something wrong in code, sometimes no more sends UDP => Echo de-energized and then it goes again

Syberteck commented 6 years ago

https://github.com/Syberteck/esp8266-Smart-Plug

I have 1 Echo Plus, 1 Echo and 2 Echo Dots. All 2nd generation. File is verified and working. Voice command and button. Flashed on a Sonoff S20.

Net-Eng-05 commented 6 years ago

This still does not answer the question as to whether or not one needs to have the Wemo skill added to Alexa before this will work.

I have an Echo Dot V2 597464620.

I am using NodeMCU boards and cannot get Alexa to discover devices.

elvquant commented 6 years ago

Adding changes from ronny130286 https://github.com/n8henrie/fauxmo/issues/38#issuecomment-354380793 and nbabaka https://github.com/n8henrie/fauxmo/issues/38#issuecomment-354474377 to repositories sources. NO NEED for setup_xml-changes: https://github.com/n8henrie/fauxmo/issues/38#issuecomment-354487504

Can confirm, that devices will recognized at Echo Dot V2 (Version 597464620)

Additional info (Dec 30.): Checked simplehttpplugin using on_cmd, off_cmd, status_cmd ... all works fine.

AshZS commented 6 years ago

Thanks @BetMadZac73 for your code examples. This is my first dip into Python and I'm now up and running.

Just a note that I have an Echo Dot v2 running 597464620 and discovery worked fine. I am however running an old build of Fauxmo that was bundled with https://github.com/toddmedema/echo where I first discovered Fauxmo.

Syberteck commented 6 years ago

I only have a Sonoff S20 device to try it on. It is based on a esp8266. This works on a esp8266 and you do not need the Wemo skill added to Echo.

ddimitriou commented 6 years ago

I can confirm that with Echo 2nd gen I still have issues with discovery. I even did a MIM packet sniffing, with my Wemo Insight Plug connected, all requests and responses are correct (even with the latest patch from @nbabaka ) , yet still alexa doesn't recognise the devices... My firmware is : 595530420. Something else is going on here, I think that they have completely ditched the SSDP server and the discovery happens via their own servers... Sample setup.xml from my Plug:

<root xmlns="urn:Belkin:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<deviceType>urn:Belkin:device:insight:1</deviceType>
<friendlyName>Light</friendlyName>
<manufacturer>Belkin International Inc.</manufacturer>
<manufacturerURL>http://www.belkin.com</manufacturerURL>
<modelDescription>Belkin Insight 1.0</modelDescription>
<modelName>Insight</modelName>
<modelNumber>1.0</modelNumber>
<modelURL>http://www.belkin.com/plugin/</modelURL>
<serialNumber>XXXXXXXXXX</serialNumber>
<UDN>uuid:Insight-1_0-XXXXXXXXXX</UDN>
<UPC>123456789</UPC>
<macAddress>YYYYYYYYYY</macAddress>
<firmwareVersion>WeMo_WW_2.00.10966.PVT-OWRT-Insight</firmwareVersion>
<iconVersion>3|49153</iconVersion>
<binaryState>0</binaryState>
<iconList>
<icon>
<mimetype>jpg</mimetype>
<width>100</width>
<height>100</height>
<depth>100</depth>
<url>icon.jpg</url>
</icon>
</iconList>
<serviceList>
<service>
<serviceType>urn:Belkin:service:WiFiSetup:1</serviceType>
<serviceId>urn:Belkin:serviceId:WiFiSetup1</serviceId>
<controlURL>/upnp/control/WiFiSetup1</controlURL>
<eventSubURL>/upnp/event/WiFiSetup1</eventSubURL>
<SCPDURL>/setupservice.xml</SCPDURL>
</service>
<service>
<serviceType>urn:Belkin:service:timesync:1</serviceType>
<serviceId>urn:Belkin:serviceId:timesync1</serviceId>
<controlURL>/upnp/control/timesync1</controlURL>
<eventSubURL>/upnp/event/timesync1</eventSubURL>
<SCPDURL>/timesyncservice.xml</SCPDURL>
</service>
<service>
<serviceType>urn:Belkin:service:basicevent:1</serviceType>
<serviceId>urn:Belkin:serviceId:basicevent1</serviceId>
<controlURL>/upnp/control/basicevent1</controlURL>
<eventSubURL>/upnp/event/basicevent1</eventSubURL>
<SCPDURL>/eventservice.xml</SCPDURL>
</service>
<service>
<serviceType>urn:Belkin:service:firmwareupdate:1</serviceType>
<serviceId>urn:Belkin:serviceId:firmwareupdate1</serviceId>
<controlURL>/upnp/control/firmwareupdate1</controlURL>
<eventSubURL>/upnp/event/firmwareupdate1</eventSubURL>
<SCPDURL>/firmwareupdate.xml</SCPDURL>
</service>
<service>
<serviceType>urn:Belkin:service:rules:1</serviceType>
<serviceId>urn:Belkin:serviceId:rules1</serviceId>
<controlURL>/upnp/control/rules1</controlURL>
<eventSubURL>/upnp/event/rules1</eventSubURL>
<SCPDURL>/rulesservice.xml</SCPDURL>
</service>
<service>
<serviceType>urn:Belkin:service:metainfo:1</serviceType>
<serviceId>urn:Belkin:serviceId:metainfo1</serviceId>
<controlURL>/upnp/control/metainfo1</controlURL>
<eventSubURL>/upnp/event/metainfo1</eventSubURL>
<SCPDURL>/metainfoservice.xml</SCPDURL>
</service>
<service>
<serviceType>urn:Belkin:service:remoteaccess:1</serviceType>
<serviceId>urn:Belkin:serviceId:remoteaccess1</serviceId>
<controlURL>/upnp/control/remoteaccess1</controlURL>
<eventSubURL>/upnp/event/remoteaccess1</eventSubURL>
<SCPDURL>/remoteaccess.xml</SCPDURL>
</service>
<service>
<serviceType>urn:Belkin:service:deviceinfo:1</serviceType>
<serviceId>urn:Belkin:serviceId:deviceinfo1</serviceId>
<controlURL>/upnp/control/deviceinfo1</controlURL>
<eventSubURL>/upnp/event/deviceinfo1</eventSubURL>
<SCPDURL>/deviceinfoservice.xml</SCPDURL>
</service>
<service>
<serviceType>urn:Belkin:service:insight:1</serviceType>
<serviceId>urn:Belkin:serviceId:insight1</serviceId>
<controlURL>/upnp/control/insight1</controlURL>
<eventSubURL>/upnp/event/insight1</eventSubURL>
<SCPDURL>/insightservice.xml</SCPDURL>
</service>
<service>
<serviceType>urn:Belkin:service:smartsetup:1</serviceType>
<serviceId>urn:Belkin:serviceId:smartsetup1</serviceId>
<controlURL>/upnp/control/smartsetup1</controlURL>
<eventSubURL>/upnp/event/smartsetup1</eventSubURL>
<SCPDURL>/smartsetup.xml</SCPDURL>
</service>
<service>
<serviceType>urn:Belkin:service:manufacture:1</serviceType>
<serviceId>urn:Belkin:serviceId:manufacture1</serviceId>
<controlURL>/upnp/control/manufacture1</controlURL>
<eventSubURL>/upnp/event/manufacture1</eventSubURL>
<SCPDURL>/manufacture.xml</SCPDURL>
</service>
</serviceList>
<presentationURL>/pluginpres.html</presentationURL>
</device>
</root>
Perforex commented 6 years ago

I'm also still having problems. I have a brand new Echo Plus (2nd Gen) not sure what firmware version (how do I find the firmware version?). I've installed the fauxmo dev version and set the branch to issue_38, which hopefully will enable the new patches. When I scan for devices I find nothing. If I can provide more information that might help please do say. I'd like to get this cracked.

ddimitriou commented 6 years ago

Actually the key was @ronny130286 change and the comment he made regarding the checks alexa makes. If you do something wrong in your code and she gets a malformed response she doesnt retry the discovery at that specific IP if you ask her to rediscover. You have to restart her and try again. I'm also not sure if the metainfo is needed.

Finally I got it working. I'm creating a pull request on this branch with their code changes if you guys want to merge it. Props to the guys!

demvil commented 6 years ago

@ddimitriou Nice, works for me!

pler commented 6 years ago

Can confirm https://github.com/n8henrie/fauxmo/pull/43 works on Echo Plus 2 version 595530420

Thanks @ddimitriou !

Perforex commented 6 years ago

Echo Plus 2 version 595530420 - Still not working for me. Did you guys previously have working code that stopped working? For me this is the first attempt to use this code so I'm wondering if Alexa is honouring previously good devices but because I've never had any devices she won't discover them on this level of firmware. It's a guess but I don't know what else is wrong.