sbidy / pywizlight

A python connector for WiZ devices
MIT License
463 stars 79 forks source link

WizLightTimeOutError #89

Closed stodgysam closed 3 years ago

stodgysam commented 3 years ago

Hello, I have been using this library to control my light. I tried to use it today and I am getting a time out error. Here is the full text: raise WizLightTimeOutError("The request to the bulb timed out") pywizlight.exceptions.WizLightTimeOutError: The request to the bulb timed out

I updated the package and checked that I could still discover the light. I can still see it in my network, but I cannot control it.

mozilla2012 commented 3 years ago

This is affecting me too. I'm wondering if the bulbs updated and they broke it. I'm on firmware 1.24.0, and this started for me just a day or two ago; not a full 7 days ago.

Edit: Apparently 1.24.0 is new as of roughly the day this post was created. Definitely seems suspect. https://m.apkpure.com/wiz/com.tao.wiz/versions

I'm not sure if we can roll back to the previous firmware or not.

sbidy commented 3 years ago

A rollback of the FW is not possible. But I saw one of my bulbs have a 1.25.1 FW. I'll check if any function was changed while this update.

Can you provide the failed function call (stack trace) or is no connection at all possible?

mozilla2012 commented 3 years ago

Here's the error I see:

Oct 19 20:57:07 : Task exception was never retrieved
Oct 19 20:57:07 : future: <Task finished name='Task-71' coro=<DatagramClient.send() done, defined at /usr/local/lib/python3.8/dist-packages/asyncio_dgram/aio.py:128> exception=ConnectionRefusedError(111, 'Connection refused')>
Oct 19 20:57:07 : Traceback (most recent call last):
Oct 19 20:57:07 :   File "/usr/local/lib/python3.8/dist-packages/asyncio_dgram/aio.py", line 132, in send
Oct 19 20:57:07 :     await super().send(data)
Oct 19 20:57:07 :   File "/usr/local/lib/python3.8/dist-packages/asyncio_dgram/aio.py", line 94, in send
Oct 19 20:57:07 :     _ = self.exception
Oct 19 20:57:07 :   File "/usr/local/lib/python3.8/dist-packages/asyncio_dgram/aio.py", line 52, in exception
Oct 19 20:57:07 :     raise exc
Oct 19 20:57:07 :   File "/usr/lib/python3.8/asyncio/selector_events.py", line 1011, in _read_ready
Oct 19 20:57:07 :     data, addr = self._sock.recvfrom(self.max_size)
Oct 19 20:57:07 : ConnectionRefusedError: [Errno 111] Connection refused
Oct 19 20:57:08 : Task exception was never retrieved
Oct 19 20:57:08 : future: <Task finished name='Task-73' coro=<DatagramClient.send() done, defined at /usr/local/lib/python3.8/dist-packages/asyncio_dgram/aio.py:128> exception=ConnectionRefusedError(111, 'Connection refused')>
Oct 19 20:57:08 : Traceback (most recent call last):
Oct 19 20:57:08 :   File "/usr/local/lib/python3.8/dist-packages/asyncio_dgram/aio.py", line 132, in send
Oct 19 20:57:08 :     await super().send(data)
Oct 19 20:57:08 :   File "/usr/local/lib/python3.8/dist-packages/asyncio_dgram/aio.py", line 94, in send
Oct 19 20:57:08 :     _ = self.exception
Oct 19 20:57:08 :   File "/usr/local/lib/python3.8/dist-packages/asyncio_dgram/aio.py", line 52, in exception
Oct 19 20:57:08 :     raise exc
Oct 19 20:57:08 :   File "/usr/lib/python3.8/asyncio/selector_events.py", line 1011, in _read_ready
Oct 19 20:57:08 :     data, addr = self._sock.recvfrom(self.max_size)
Oct 19 20:57:08 : ConnectionRefusedError: [Errno 111] Connection refused

Thanks for hopping on this so fast!

sbidy commented 3 years ago

Mh, it seems to be a connection error on the network stack and not on the UDP-Interface of the bulb. To decouple these, please try to send a "nc" (raw network - nc is a tool for Linux/Mac) command to the bulb: echo '{"method":"getSystemConfig","env":"dev","params":{}}' | nc -u -w 1 <theIPofYourBulb> 38899

This should return something like this:

{
    "method": "getSystemConfig",
    "env": "pro",
    "result": {
        "mac": "a8bb50xxxxx",
        "homeId": 4228671,
        "roomId": 6402395,
        "rgn": "eu",
        "moduleName": "ESP01_SHRGB_03",
        "fwVersion": "1.24.0",
        "groupId": 0,
        "drvConf": [
            20,
            2
        ],
        "ping": 0
    }
}

If you get a connection error, the bulb is not reliably connected to the Wi-Fi. Maybe you can move the bulb closer to an access point.

mozilla2012 commented 3 years ago

That works:

{
  "method": "getSystemConfig",
  "env": "pro",
  "result": {
    "mac": "a8bb50cxxxxx",
    "homeId": 1913756,
    "roomId": 2859747,
    "rgn": "eu",
    "moduleName": "ESP03_SHRGB1W_01",
    "fwVersion": "1.24.0",
    "groupId": 0,
    "ping": 0
  }
}

Still getting connection errors though 😢

sbidy commented 3 years ago

In my test, I can't reproduce this error. What version of the lib you are using?

mozilla2012 commented 3 years ago

Well I figured it out.

I have three wiz lights. Apparently the IP address of two of them changed. I just coincidentally ran getSystemConfig on the one that didn't change IP addresses.

I thought I had those set as static.

I apologize for wasting your time and sending you on this wild goose chase! I appreciate your comments; I love this library