raulgbcr / lednetwf_ble

Home Assistant custom integration for LEDnetWF devices
MIT License
24 stars 2 forks source link

On/off toggle causes python exception #20

Closed valerii-fr closed 6 months ago

valerii-fr commented 6 months ago

Hello, I'm using AliExpress kits with following SNs:

`Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service response = await hass.services.async_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2543, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2580, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 971, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1043, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/light/init.py", line 631, in async_handle_light_on_service await light.async_turn_on(*filter_turn_on_params(light, params)) File "/config/custom_components/lednetwf_ble/light.py", line 134, in async_turn_on await self._instance.turn_on() File "/config/custom_components/lednetwf_ble/lednetwf.py", line 61, in _async_wrap_retry_bluetooth_connection_error return await func(self, args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/lednetwf_ble/lednetwf.py", line 388, in turn_on await self._write(self._turn_on_cmd) File "/config/custom_components/lednetwf_ble/lednetwf.py", line 179, in _write data[0] = 0xFF00 & self._packet_counter


TypeError: 'NoneType' object does not support item assignment`

HA is installed in a docker container if it matters.
I'm going to try to research this issue but it will be my first python expreience, so, don't look forward to hear sth useful from me soon  :)
valerii-fr commented 6 months ago

no idea why, but now it works

raulgbcr commented 6 months ago

Glad you fixed it! How do you have bluetooth support on docker HA? Are you using esphome proxys?

valerii-fr commented 6 months ago

Just reproduced again :( No correlation with environment for now

No, I don't use proxying, i've mounted dbus and use bt dongle

raulgbcr commented 6 months ago

Give this branch a try: https://github.com/raulgbcr/lednetwf_ble/tree/8none1/new_models

Check #18 on how to install it

valerii-fr commented 6 months ago

It fixed my problem, thanks! Will report if I have any issues with test branch

8none1 commented 5 months ago

I'm reasonably sure that I hit this in the past and that branch should indeed have a fix for it. Sounds like it does. :+1:

8none1 commented 5 months ago

Actually, I'm wrong. I can see the bug now. I will address it in the feature branch.