Closed patbos closed 4 years ago
This might be the same thing as #17 what seems to have helped there was to run a patched bluepy, see if that helps for you as well?
Installed the PR version of bluepy, did not work. Still go the "'Unexpected response (wr)'"
Could this be related? https://github.com/IanHarvey/bluepy/issues/177
Might be, I had code at one point that took pains to do everything on one thread (or with locks) and no simultaneous talking to bluepy, but that mostly led to missed notifications.
bluepy has several problems, maybe the most prominent that it's not really maintained and actively developer. I've been looking at replacing it with bleak (https://github.com/hbldh/bleak) which is using the dbus interface to bluez directly. We'll see where I get with that.
Great component! I'm also getting the Unexpected response (wr) error. Running on Raspberry Pi 4 with Hass.io I have Nabu Casa and Google Home set up. When I use voice command to turn a light on/off the light turns on/off and then my Google device tells me that an error occured, it can't connect to the light. Any ideas?
I've pointed some people with issues at https://github.com/IanHarvey/bluepy/pull/355 and installing bluepy with that patch has seemed to help with some issues. Can you try that?
Sorry for being new to this. I've tried to do that but don't know how to. I'm running Hass.io, is it possible to patch bluepy on Hass.io? I can't find any file with the name btle.py on my system. Please advice.
@axlthorell I'm having the same problem, and applying the mentioned fix seems to help, but it's hard to verify since the problem doesn't occur all the time.
@treet Thanks for your help! I put a copy of the zip file in my /config/www/ directory and replaced "bluepy" with "http://127.0.0.1:8123/bluepy.zip#bluepy==1.3.0" in the manifest.json. The problem mostly occurs for me when trying to turn on a group of plejd lights. I get stuff like:
2019-12-09 18:12:09 WARNING (Thread-11) [custom_components.plejd.light] Encountered bluepy internal error: 'Unexpected response (wr)'
2019-12-09 18:12:13 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 564, in async_request_call
await coro
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 116, in turn_on
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
File "/config/custom_components/plejd/light.py", line 303, in plejd_write
pi["device"].writeCharacteristic(handle, data, wait)
KeyError: 'device'
2019-12-09 18:12:20 WARNING (Thread-11) [custom_components.plejd.light] Encountered bluepy internal error: 'Unexpected response (wr)'
How do I know if I'm using the custom bluepy?
@axlthorell Actually, I'm not sure. I restarted home assistant and I thought that was it, but now I'm getting the same error again with stack traces like /usr/local/lib/python3.7/site-packages/bluepy/btle.py
which does not look like the patched bluepy...
I've just merged a partial re-write using dbus directly instead of bluepy, please try with that. This should be fixed.
First of all, great initiative creating this component. Really hope that is can be an official component in HA.
Sometimes when I turn on or off a plejd light it fails and I see this in the logs:
2019-09-10 19:46:01 WARNING (Thread-4) [custom_components.plejd.light] Encountered bluepy internal error: 'Unexpected response (wr)'