chvolkmann / govee_btled

A Python wrapper for controlling a cheap Bluetooth RGB light bulb.
91 stars 14 forks source link

Timeout error on Windows #9

Open jonahclarsen opened 2 years ago

jonahclarsen commented 2 years ago

Hi there,

Thanks for creating this. I am trying to use it on Windows 10, and I managed to resolve the first (#8) error by changing line 40 of govee_btled/bluetooth_led.py from self._bt = bt_backend_cls() to self._bt = pygatt.BGAPIBackend(serial_port='COM1').

However, I am now getting the following error:

python __main.py Traceback (most recent call last): File "__main.py", line 7, in led = BluetoothLED('A4:C1:38:69:96:D7') File "C:\Users\jonah\Downloads\govee_btled-master\govee_btled\bluetooth_led.py", line 41, in init self._bt.start() File "C:\Users\jonah\Anaconda3\envs\kasa\lib\site-packages\pygatt\backends\bgapi\bgapi.py", line 230, in start self.disable_advertising() File "C:\Users\jonah\Anaconda3\envs\kasa\lib\site-packages\pygatt\backends\bgapi\bgapi.py", line 277, in disable_advertising self.expect(ResponsePacketType.gap_set_mode) File "C:\Users\jonah\Anaconda3\envs\kasa\lib\site-packages\pygatt\backends\bgapi\bgapi.py", line 582, in expect return self.expect_any([expected], *args, **kargs) File "C:\Users\jonah\Anaconda3\envs\kasa\lib\site-packages\pygatt\backends\bgapi\bgapi.py", line 618, in expect_any raise exc pygatt.backends.bgapi.exceptions.ExpectedResponseTimeout: Timed out after 1.000000s waiting for [<ResponsePacketType.gap_set_mode: 58>]

Any suggestions would be greatly appreciated.

kabyru commented 1 year ago

Hi there,

Thanks for creating this. I am trying to use it on Windows 10, and I managed to resolve the first (#8) error by changing line 40 of govee_btled/bluetooth_led.py from self._bt = bt_backend_cls() to self._bt = pygatt.BGAPIBackend(serial_port='COM1').

However, I am now getting the following error:

python main.py Traceback (most recent call last): File "main.py", line 7, in led = BluetoothLED('A4:C1:38:69:96:D7') File "C:\Users\jonah\Downloads\govee_btled-master\govee_btled\bluetooth_led.py", line 41, in init self._bt.start() File "C:\Users\jonah\Anaconda3\envs\kasa\lib\site-packages\pygatt\backends\bgapi\bgapi.py", line 230, in start self.disable_advertising() File "C:\Users\jonah\Anaconda3\envs\kasa\lib\site-packages\pygatt\backends\bgapi\bgapi.py", line 277, in disable_advertising self.expect(ResponsePacketType.gap_set_mode) File "C:\Users\jonah\Anaconda3\envs\kasa\lib\site-packages\pygatt\backends\bgapi\bgapi.py", line 582, in expect return self.expect_any([expected], *args, **kargs) File "C:\Users\jonah\Anaconda3\envs\kasa\lib\site-packages\pygatt\backends\bgapi\bgapi.py", line 618, in expect_any raise exc pygatt.backends.bgapi.exceptions.ExpectedResponseTimeout: Timed out after 1.000000s waiting for [<ResponsePacketType.gap_set_mode: 58>]

Any suggestions would be greatly appreciated.

Have you had any luck resolving this issue?

jonahclarsen commented 1 year ago

Hi there, Thanks for creating this. I am trying to use it on Windows 10, and I managed to resolve the first (#8) error by changing line 40 of govee_btled/bluetooth_led.py from self._bt = bt_backend_cls() to self._bt = pygatt.BGAPIBackend(serial_port='COM1'). However, I am now getting the following error:

python main.py Traceback (most recent call last): File "main.py", line 7, in led = BluetoothLED('A4:C1:38:69:96:D7') File "C:\Users\jonah\Downloads\govee_btled-master\govee_btled\bluetooth_led.py", line 41, in init self._bt.start() File "C:\Users\jonah\Anaconda3\envs\kasa\lib\site-packages\pygatt\backends\bgapi\bgapi.py", line 230, in start self.disable_advertising() File "C:\Users\jonah\Anaconda3\envs\kasa\lib\site-packages\pygatt\backends\bgapi\bgapi.py", line 277, in disable_advertising self.expect(ResponsePacketType.gap_set_mode) File "C:\Users\jonah\Anaconda3\envs\kasa\lib\site-packages\pygatt\backends\bgapi\bgapi.py", line 582, in expect return self.expect_any([expected], *args, **kargs) File "C:\Users\jonah\Anaconda3\envs\kasa\lib\site-packages\pygatt\backends\bgapi\bgapi.py", line 618, in expect_any raise exc pygatt.backends.bgapi.exceptions.ExpectedResponseTimeout: Timed out after 1.000000s waiting for [<ResponsePacketType.gap_set_mode: 58>]

Any suggestions would be greatly appreciated.

Have you had any luck resolving this issue?

Unfortunately no. I've had to make do with the Android Govee app. I would love to find a working solution for changing the lights from Windows or Mac.

kabyru commented 1 year ago

Hi, so I've re-implemented this wrapper to have Windows capability. Long story short we just needed to shift away from PyGATT as the backend to use something that is natively compatible with Windows' UWP BLE stack. I chose to use Bleak as the backend for my re-implementation.

Have a look, hopefully this is what you're looking for!

govee_btled_windows

jonahclarsen commented 1 year ago

@kabyru I've been trying to install this for a while now, and after an hour of troubleshooting problems building bleak, I'm now stuck at this error (after running 'pip install bleak'):

[1/13] Building CXX object CMakeFiles_winrt.dir\cmake_pch.cxx.obj FAILED: CMakeFiles/_winrt.dir/cmake_pch.cxx.obj C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1434~1.319\bin\Hostx86\x64\cl.exe /nologo /TP -D_winrt_EXPORTS -IC:\Users\jonah\AppData\Local\Temp\pip-install-mq34ijci\bleak-winrt_5023463063674144aadf74fa82d581e1\cppwinrt -IC:\Users\jonah\AppData\Local\Temp\pip-install-mq34ijci\bleak-winrt_5023463063674144aadf74fa82d581e1\pywinrt\bleak_winrt\src -external:IC:\Users\jonah\Anaconda3\envs\govee\Include -external:W0 /DWIN32 /D_WINDOWS /EHsc /d2FH4 /O2 /Ob2 /DNDEBUG -MT /await /bigobj /GR- /permissive- -std:c++17 /YcC:/Users/jonah/AppData/Local/Temp/pip-install-mq34ijci/bleak-winrt_5023463063674144aadf74fa82d581e1/_skbuild/win-amd64-3.6/cmake-build/CMakeFiles/_winrt.dir/cmake_pch.hxx /FpC:/Users/jonah/AppData/Local/Temp/pip-install-mq34ijci/bleak-winrt_5023463063674144aadf74fa82d581e1/_skbuild/win-amd64-3.6/cmake-build/CMakeFiles/_winrt.dir/./cmake_pch.cxx.pch /FIC:/Users/jonah/AppData/Local/Temp/pip-install-mq34ijci/bleak-winrt_5023463063674144aadf74fa82d581e1/_skbuild/win-amd64-3.6/cmake-build/CMakeFiles/_winrt.dir/cmake_pch.hxx /showIncludes /FoCMakeFiles_winrt.dir\cmake_pch.cxx.obj /FdCMakeFiles_winrt.dir\ /FS -c C:\Users\jonah\AppData\Local\Temp\pip-install-mq34ijci\bleak-winrt_5023463063674144aadf74fa82d581e1_skbuild\win-amd64-3.6\cmake-build\CMakeFiles_winrt.dir\cmake_pch.cxx C:\Users\jonah\AppData\Local\Temp\pip-install-mq34ijci\bleak-winrt_5023463063674144aadf74fa82d581e1\pywinrt\bleak_winrt\src\pybase.h(939): error C2065: 'PyDateTime_TimeZone_UTC': undeclared identifier C:\Users\jonah\AppData\Local\Temp\pip-install-mq34ijci\bleak-winrt_5023463063674144aadf74fa82d581e1\pywinrt\bleak_winrt\src\pybase.h(972): error C2065: 'PyDateTime_TimeZone_UTC': undeclared identifier ninja: build stopped: subcommand failed. Traceback (most recent call last): File "C:\Users\jonah\AppData\Local\Temp\pip-build-env-veqbywhv\overlay\Lib\site-packages\skbuild\setuptools_wrap.py", line 640, in setup cmkr.make(make_args, install_target=cmake_install_target, env=env) File "C:\Users\jonah\AppData\Local\Temp\pip-build-env-veqbywhv\overlay\Lib\site-packages\skbuild\cmaker.py", line 684, in make self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env) File "C:\Users\jonah\AppData\Local\Temp\pip-build-env-veqbywhv\overlay\Lib\site-packages\skbuild\cmaker.py", line 716, in make_impl "An error occurred while building with CMake.\n"

An error occurred while building with CMake. Command: cmake --build . --target install --config Release -- Install target: install Source directory: C:\Users\jonah\AppData\Local\Temp\pip-install-mq34ijci\bleak-winrt_5023463063674144aadf74fa82d581e1 Working directory: C:\Users\jonah\AppData\Local\Temp\pip-install-mq34ijci\bleak-winrt_5023463063674144aadf74fa82d581e1_skbuild\win-amd64-3.6\cmake-build Please check the install target is valid and see CMake's output for more information.

ERROR: Failed building wheel for bleak-winrt Failed to build bleak-winrt ERROR: Could not build wheels for bleak-winrt which use PEP 517 and cannot be installed directly