Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to change bulb state #154

Open
janek515 opened this issue Nov 6, 2022 · 4 comments
Open

Unable to change bulb state #154

janek515 opened this issue Nov 6, 2022 · 4 comments
Assignees
Labels

Comments

@janek515
Copy link

janek515 commented Nov 6, 2022

OS: Windows 11 22623.875
Python: 3.11

Hi,
I am able to connect to the bulb and to get its state info back, but when i try altering its state in any way using
bulb.turn_off() or bulb.set_state(PilotBuilder(colortemp=color_temp)) the following error message is printed:

Fatal write error on datagram transport
protocol: <pywizlight.protocol.WizProtocol object at 0x00000236AA61F650>
transport: <_ProactorDatagramTransport fd=760 read=<_OverlappedFuture cancelled>>
Traceback (most recent call last):
  File "C:\...\Python311\Lib\asyncio\proactor_events.py", line 529, in _loop_writing
    self._write_fut = self._loop._proactor.send(self._sock,
                      ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'send'
127.0.0.1 - - [06/Nov/2022 14:08:55] "POST /v1/set?ct=5050&bri=1.000000 HTTP/1.1" 500 -
Traceback (most recent call last):
  File "C:\...\Python311\Lib\asyncio\tasks.py", line 490, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\...\pypoetry\Cache\virtualenvs\flux-2fB9oRMh-py3.11\Lib\site-packages\pywizlight\bulb.py", line 758, in send
    resp = await asyncio.wait_for(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\Python311\Lib\asyncio\tasks.py", line 492, in wait_for
    raise exceptions.TimeoutError() from exc
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\...\pypoetry\Cache\virtualenvs\flux-2fB9oRMh-py3.11\Lib\site-packages\flask\app.py", line 2548, in __call__
    return self.wsgi_app(environ, start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\pypoetry\Cache\virtualenvs\flux-2fB9oRMh-py3.11\Lib\site-packages\flask\app.py", line 2528, in wsgi_app
    response = self.handle_exception(e)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\pypoetry\Cache\virtualenvs\flux-2fB9oRMh-py3.11\Lib\site-packages\flask\app.py", line 2525, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\pypoetry\Cache\virtualenvs\flux-2fB9oRMh-py3.11\Lib\site-packages\flask\app.py", line 1822, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\pypoetry\Cache\virtualenvs\flux-2fB9oRMh-py3.11\Lib\site-packages\flask\app.py", line 1820, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\pypoetry\Cache\virtualenvs\flux-2fB9oRMh-py3.11\Lib\site-packages\flask\app.py", line 1796, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\pypoetry\Cache\virtualenvs\flux-2fB9oRMh-py3.11\Lib\site-packages\asgiref\sync.py", line 218, in __call__
    return call_result.result()
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\...\Python311\Lib\concurrent\futures\_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "C:\...\Python311\Lib\concurrent\futures\_base.py", line 401, in __get_result
    raise self._exception
  File "C:\...\pypoetry\Cache\virtualenvs\flux-2fB9oRMh-py3.11\Lib\site-packages\asgiref\sync.py", line 284, in main_wrap
    result = await self.awaitable(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\code\flux\app.py", line 46, in v1set
    await set_color_temp()
  File "D:\code\flux\app.py", line 34, in set_color_temp
    await bulb.turn_off()
  File "C:\...\pypoetry\Cache\virtualenvs\flux-2fB9oRMh-py3.11\Lib\site-packages\pywizlight\bulb.py", line 630, in turn_off
    await self.send({"method": "setPilot", "params": {"state": False}})
  File "C:\...\pypoetry\Cache\virtualenvs\flux-2fB9oRMh-py3.11\Lib\site-packages\pywizlight\bulb.py", line 762, in send
    raise WizLightConnectionError(str(ex)) from ex
pywizlight.exceptions.WizLightConnectionError
@sbidy sbidy self-assigned this Nov 7, 2022
@sbidy sbidy added the Bug ??? label Nov 7, 2022
@sbidy
Copy link
Owner

sbidy commented Nov 7, 2022

It seems to me that you can't connect successfully to the bulb. Please try to send a nc to the bulb to test the basic connectivity.
See here: #89 (comment)

@janek515
Copy link
Author

janek515 commented Nov 7, 2022

It appears to be something else as the response seems fine.

{"method":"getSystemConfig","env":"pro","result":{"mac":"6c29901***","homeId":763***,"roomId":11***,"rgn":"eu","moduleName":"ESP03_SHTW1W_01","fwVersion":"1.28.0","groupId":0,"ping":0}}

@sbidy
Copy link
Owner

sbidy commented Nov 7, 2022

Can you please try to send the same command (turn off) via nc: {"method": "setPilot", "params": {"state": False}} (replace the part after echo)

@janek515
Copy link
Author

janek515 commented Nov 7, 2022

It works as expected and returns {"method":"setPilot","env":"pro","result":{"success":true}}

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

No branches or pull requests

2 participants