Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

wemo.switch doesn't return #2

Open
johngo7470 opened this issue Dec 23, 2017 · 2 comments
Open

wemo.switch doesn't return #2

johngo7470 opened this issue Dec 23, 2017 · 2 comments
Labels

Comments

@johngo7470
Copy link

After installing wemo (sudo pip3.6 install wemo), I started a python3.6 shell, ran import, then entered 'bedroom = wemo.switch('192.168.2.121'), but the command didn't return.

I'm able to go to http://192.168.2.121:49153/setup.xml and see output from the switch, and am able to send commands to turn the switch on/off, using other software.

Am I missing something?

@evaneliasyoung
Copy link
Owner

evaneliasyoung commented Dec 23, 2017

The statement bedroom = wemo.switch('192.168.2.121') should output nothing if it is successful.
The bedroom is now a wemo.switch object and you can call several different functions: enable(), disable(), getStatus(), and toggle() are the main few.

Edit: Type type(bedroom) and the output should be <class 'wemo.switch'>

@johngo7470
Copy link
Author

Initially I reported it doesn't return (meaning no prompt, no error thrown), though it turns out I wasn't patient enough. It did eventually throw an error (actually 4 of them) after 30 seconds - all were 'no route to host' errors.

BTW, on an unrelated note, I updated my init.py to use python3.6, as, I'm thinking 'python3' will run 3.5.3 (the default, in my particular installation).

Some of the output makes reference to port 80, which is surprising, because I believe the management port for wemo is 49153.

I do see in init.py, that there is a reference to the port number range 49152-49156, but I don't see this range being tested based on the thrown errors.

pi@raspi:~/Downloads/wemo-master/wemo $ python3.6
Python 3.6.3 (default, Nov 1 2017, 13:26:02)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.

import wemo
bedroom = wemo.switch('192.168.2.131')
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 83, in create_connection
raise err
File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 73, in create_connection
sock.connect(sa)
OSError: [Errno 113] No route to host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 357, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/local/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 166, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 150, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x75f8c6b0>: Failed to establish a new connection: [Errno 113] No route to host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.2.131', port=80): Max retries exceeded with url: /upnp/control/basicevent1 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x75f8c6b0>: Failed to establish a new connection: [Errno 113] No route to host',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.6/site-packages/wemo/init.py", line 23, in init
self.status = self.getStatus()
File "/usr/local/lib/python3.6/site-packages/wemo/init.py", line 38, in getStatus
rsp = post(self.url, headers=hd, data=data).text
File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 112, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 508, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.2.131', port=80): Max retries exceeded with url: /upnp/control/basicevent1 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x75f8c6b0>: Failed to establish a new connection: [Errno 113] No route to host',))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants