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

Home Assistant Core 2024.2.0 Switchbot Blind Tilt bluetooth not reporting State #109947

Closed
scoobiesti2006 opened this issue Feb 8, 2024 · 38 comments · Fixed by #110275
Closed

Comments

@scoobiesti2006
Copy link

The problem

-Home Assistant Core 2024.2.0 Switchbot Blind Tilt Bluetooth not reporting state and showing "unknown"

  • When using GUI to change blind position, A failed position call service notification appears but still works.
    -issue appeared right after update

What version of Home Assistant Core has the issue?

core-2024.2.0

What was the last working version of Home Assistant Core?

core-2024.1.6

What type of installation are you running?

Home Assistant OS

Integration causing the issue

switchbot

Link to integration documentation on our website

https://www.home-assistant.io/integrations/switchbot/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@home-assistant
Copy link

home-assistant bot commented Feb 8, 2024

Hey there @Danielhiversen, @RenierM26, @murtas, @Eloston, @dsypniewski, mind taking a look at this issue as it has been labeled with an integration (switchbot) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of switchbot can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign switchbot Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


switchbot documentation
switchbot source
(message by IssueLinks)

@Tntdruid
Copy link

Tntdruid commented Feb 8, 2024

Some error log

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:240
Integration: websocket_api (documentation, issues)
First occurred: 08.21.32 (3 occurrences)
Last logged: 08.21.53

[140308806352192] 'position'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 240, in handle_call_service
response = await hass.services.async_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2279, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2316, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 892, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 962, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/switchbot/cover.py", line 165, in async_open_cover_tilt
self._last_run_success = bool(await self._device.open())
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/switchbot/devices/device.py", line 96, in _async_update_after_operation_wrap
await self.update()
File "/usr/local/lib/python3.12/site-packages/switchbot/devices/device.py", line 576, in update
self._update_parsed_data(info)
File "/usr/local/lib/python3.12/site-packages/switchbot/devices/device.py", line 611, in _update_parsed_data
self._set_parsed_data(self._sb_adv_data, merged_data)
File "/usr/local/lib/python3.12/site-packages/switchbot/devices/curtain.py", line 68, in _set_parsed_data
new_position = data["position"]
~~~~^^^^^^^^^^^^
KeyError: 'position'

@lviciedo
Copy link

lviciedo commented Feb 8, 2024

same issue
image

@c0nt4x
Copy link

c0nt4x commented Feb 8, 2024

Same here but the position of mine are showing closed whether they're open or closed.

Also a separate error same as above but showing KeyError: MotionDirection

Logger: homeassistant.components.bluetooth.manager
Source: components/bluetooth/manager.py:109
Integration: Bluetooth (documentation, issues)
First occurred: 1:02:04 PM (3 occurrences)
Last logged: 1:59:50 PM

Error in bluetooth callback
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/manager.py", line 109, in _discover_service_info
    callback(service_info, BluetoothChange.ADVERTISEMENT)
  File "/usr/src/homeassistant/homeassistant/components/switchbot/coordinator.py", line 114, in _async_handle_bluetooth_event
    super()._async_handle_bluetooth_event(service_info, change)
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/active_update_coordinator.py", line 163, in _async_handle_bluetooth_event
    super()._async_handle_bluetooth_event(service_info, change)
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/passive_update_coordinator.py", line 89, in _async_handle_bluetooth_event
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/passive_update_coordinator.py", line 51, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/components/switchbot/cover.py", line 198, in _handle_coordinator_update
    self._attr_is_opening = self.parsed_data["motionDirection"]["opening"]
                            ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'motionDirection'

@Aipoc76
Copy link

Aipoc76 commented Feb 8, 2024

same error, although the blinds to physically move, they do not communicate with HA.

Logger: homeassistant.components.bluetooth.manager
Source: components/bluetooth/manager.py:109
Integration: Bluetooth (documentation, issues)
First occurred: 7:37:10 AM (32 occurrences)
Last logged: 8:15:48 AM

Error in bluetooth callback
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/manager.py", line 109, in _discover_service_info
    callback(service_info, BluetoothChange.ADVERTISEMENT)
  File "/usr/src/homeassistant/homeassistant/components/switchbot/coordinator.py", line 113, in _async_handle_bluetooth_event
    self.device.update_from_advertisement(adv)
  File "/usr/local/lib/python3.12/site-packages/switchbot/devices/device.py", line 695, in update_from_advertisement
    super().update_from_advertisement(advertisement)
  File "/usr/local/lib/python3.12/site-packages/switchbot/devices/device.py", line 664, in update_from_advertisement
    self._set_advertisement_data(advertisement)
  File "/usr/local/lib/python3.12/site-packages/switchbot/devices/device.py", line 632, in _set_advertisement_data
    self._update_parsed_data(new_data)
  File "/usr/local/lib/python3.12/site-packages/switchbot/devices/device.py", line 611, in _update_parsed_data
    self._set_parsed_data(self._sb_adv_data, merged_data)
  File "/usr/local/lib/python3.12/site-packages/switchbot/devices/curtain.py", line 68, in _set_parsed_data
    new_position = data["position"]
                   ~~~~^^^^^^^^^^^^
KeyError: 'position'

@msva17
Copy link

msva17 commented Feb 8, 2024

Same error here as well. Seeing a lot of error in Bluetooth callback messages like the one above. I do run esp32’s as Bluetooth proxies.

@jorgwolski
Copy link

Issue still present with Core 2024.2.1

@Tntdruid
Copy link

Tntdruid commented Feb 9, 2024

Issue still present with Core 2024.2.1

Still broken.

@bdraco
Copy link
Member

bdraco commented Feb 9, 2024

Unfortunately none of the maintainers have this device so support for it is not so great (and the library currently has no test coverage for them). dcmeglio is going to work on fixing this up. I also ordered a device for testing, but since I have no production use case for it so it would still be much better if someone who uses these devices on a daily basis signed up to maintain support for them.

There are a few outstanding issues with these devices:
#109734
#108087
sblibs/pySwitchbot#226

@jonnybergdahl
Copy link
Contributor

I am a developer that have 2 of the Blind Tilt. Just tell me how to do it and I can help debugging/testing. Also - I am not a newbie, I had PR's accepted into core already.

@blindguynar
Copy link

blindguynar commented Feb 9, 2024

I am a developer that have 2 of the Blind Tilt. Just tell me how to do it and I can help debugging/testing. Also - I am not a newbie, I had PR's accepted into core already.

It likely has to do with this merge sblibs/pySwitchbot#226

the problem is in the python library not the integration though so you'll have to fork it, and install this core component as a custom_component then reconfigure it to you new library fork for testing.

Looks like curtains and blind tilt share the same class? Before it looks like position had defaults, but now it doesn't. That might have be saving blinds since they share a class? Python is not my strong suit, so i'm just guessing at it.

Screenshot 2024-02-09 at 12 06 11 PM

@bdraco
Copy link
Member

bdraco commented Feb 9, 2024

I am a developer that have 2 of the Blind Tilt. Just tell me how to do it and I can help debugging/testing. Also - I am not a newbie, I had PR's accepted into core already.

Suggested solution:
sblibs/pySwitchbot#226 (comment)

@RudiP
Copy link

RudiP commented Feb 10, 2024

Same exact Error here. Same logs already provided.

@austwhite
Copy link

Just commenting as I have the same issue. Although the blinds do what is instructed, an error is thrown saying HA failed to call the service cover/cover_set_tilt_position."position" but the blind will move, but the status stays as "unknown" and the % open does not change.
Only started doing this on HA 2024.2.

@willliamchan
Copy link

willliamchan commented Feb 10, 2024

same issue here. bluetooth proxies + all 5 switchbot blind tilts having the exact same issue, it breaks a few of my automations because status is "unknown"

@dcmeglio
Copy link
Contributor

dcmeglio commented Feb 11, 2024

I believe I have a fix, but I don't have a tilt so I can't fully test. I ordered a tilt for testing but it won't be here till some time next week.

If anyone who is having the issue knows how to ssh in to the docker container you could manually install the updated library:

pip install git+https://github.com/dcmeglio/pySwitchbot.git@cover_refactor

and report back if the issue is resolved. Note that until my PR is merged, updating HA will auto-remove the package upgrade and cause the issue to reoccur. If someone can help test this I think we can probably get it in the next 2024.2.X

Note: This requires the advanced ssh addon, not the regular terminal addon and knowledge on how to get into the docker container for homeassistant

@laskatj
Copy link

laskatj commented Feb 11, 2024

@dcmeglio I ran the install command from the console in HA container. Installed successfully, but still getting error below. I restarted the container as well and same results.

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:240
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 7:55:04 PM (3 occurrences)
Last logged: 7:55:06 PM

[140047130526912] 'position'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 240, in handle_call_service
response = await hass.services.async_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2279, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2316, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 892, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 962, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/switchbot/cover.py", line 187, in async_set_cover_tilt_position
self._last_run_success = bool(await self._device.set_position(position))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/switchbot/devices/device.py", line 96, in _async_update_after_operation_wrap
File "/usr/local/lib/python3.12/site-packages/switchbot/devices/device.py", line 576, in update
File "/usr/local/lib/python3.12/site-packages/switchbot/devices/device.py", line 611, in _update_parsed_data
File "/usr/local/lib/python3.12/site-packages/switchbot/devices/curtain.py", line 68, in _set_parsed_data
@update_after_operation
^^^^^
KeyError: 'position'

@jorgwolski
Copy link

Did a docker exec -it homeasssistant bash followed by pip install git+https://github.com/dcmeglio/pySwitchbot.git@cover_refactor and a HA core restart.
Blinds are still not reporting position. Error message as stated above.

@dcmeglio
Copy link
Contributor

Guess I’ll need to wait till a device arrives. I don’t see how that’s happening right now

@jonnybergdahl
Copy link
Contributor

jonnybergdahl commented Feb 11, 2024

I got this error prior to the one listed above.

2024-02-11 14:03:36.649 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/switchbot/devices/device.py", line 576, in update
self._update_parsed_data(info)
File "/usr/local/lib/python3.12/site-packages/switchbot/devices/device.py", line 611, in _update_parsed_data
self._set_parsed_data(self._sb_adv_data, merged_data)
File "/usr/local/lib/python3.12/site-packages/switchbot/devices/curtain.py", line 68, in _set_parsed_data
new_position = data["position"]
~~~~^^^^^^^^^^^^
KeyError: 'position'

Not sure why it would look for position when the tilt is stored with the tilt key though?

@bdraco
Copy link
Member

bdraco commented Feb 11, 2024

Did a docker exec -it homeasssistant bash followed by pip install git+https://github.com/dcmeglio/pySwitchbot.git@cover_refactor and a HA core restart. Blinds are still not reporting position. Error message as stated above.

That won't work because HA will downgrade the lib back to the version that comes with the HA version.

You can do this instead. Be sure to remove the custom component this will generate later after upgrading to the next HA version.

cd /config
curl -o- -sSL https://gist.githubusercontent.com/bdraco/43f8043cb04b9838383fd71353e99b18/raw/core_integration_pr | bash /dev/stdin -d switchbot -p 110275

@jorgwolski
Copy link

You can do this instead. Be sure to remove the custom component this will generate later after upgrading to the next HA version.

cd /config
curl -o- -sSL https://gist.githubusercontent.com/bdraco/43f8043cb04b9838383fd71353e99b18/raw/core_integration_pr | bash /dev/stdin -d switchbot -p 110275

Complied to those instructions. Blinds are reporting position percentage now, no more Switchbot related error messages in the logs.
A Switchbot Bot is still working as expected, so no negative influence on that device.

@bdraco
Copy link
Member

bdraco commented Feb 11, 2024

Thanks for confirming. I don't use switchbot devices anymore (and I'm only helping out here) so I have limited ability to test. I tested with the blind tilt I bought to test the pr as well as the plug and bots I had in storage and everything is good.

@willliamchan
Copy link

willliamchan commented Feb 11, 2024 via email

@dcmeglio
Copy link
Contributor

Did a docker exec -it homeasssistant bash followed by pip install git+https://github.com/dcmeglio/pySwitchbot.git@cover_refactor and a HA core restart. Blinds are still not reporting position. Error message as stated above.

That won't work because HA will downgrade the lib back to the version that comes with the HA version.

You can do this instead. Be sure to remove the custom component this will generate later after upgrading to the next HA version.

cd /config
curl -o- -sSL https://gist.githubusercontent.com/bdraco/43f8043cb04b9838383fd71353e99b18/raw/core_integration_pr | bash /dev/stdin -d switchbot -p 110275

Ah thanks. I thought HA only ran pip on upgrades not restarts.

@aarnaegg
Copy link

cd /config
curl -o- -sSL https://gist.githubusercontent.com/bdraco/43f8043cb04b9838383fd71353e99b18/raw/core_integration_pr | bash /dev/stdin -d switchbot -p 110275

This fixed it for me as well. Thank you!

@c0nt4x
Copy link

c0nt4x commented Feb 12, 2024

cd /config
curl -o- -sSL https://gist.githubusercontent.com/bdraco/43f8043cb04b9838383fd71353e99b18/raw/core_integration_pr | bash /dev/stdin -d switchbot -p 1102757

Worked for me on HAOS install. Thanks

@BigThunderSR
Copy link

cd /config
curl -o- -sSL https://gist.githubusercontent.com/bdraco/43f8043cb04b9838383fd71353e99b18/raw/core_integration_pr | bash /dev/stdin -d switchbot -p 1102757

Worked for me on HAOS install. Thanks

+1 and thanks!

@Aipoc76
Copy link

Aipoc76 commented Feb 15, 2024

worked perfect, used terminal in HA to ssl in. Then ran
cd /config curl -o- -sSL https://gist.githubusercontent.com/bdraco/43f8043cb04b9838383fd71353e99b18/raw/core_integration_pr | bash /dev/stdin -d switchbot -p 110275

all blinds (6 in total) running on a Sena USB Bluetooth Adapter (UD100-G03) now operational again. My dusk to dawn script works again! No errors in system logs, or logbook.

Thanks for your work!

edit: removed extra digit in code.

@Tvojm100
Copy link

Thanks for this. Works for me too.

@bikeymouse
Copy link

I can't get this installed on HAOS supervised.
I get this error, why could that be?

[core-ssh ~]$ cd /config
[core-ssh config]$ curl -o- -sSL https://gist.githubusercontent.com/bdraco/43f8043cb04b9838383fd71353e99b18/raw/core_integration_pr | bash /dev/stdin -d switchbot -p 1102757
INFO: Current dir is /config
INFO: Cloning core to 
Cloning into '/tmp/core_git'...
remote: Enumerating objects: 18020, done.
remote: Counting objects: 100% (18020/18020), done.
remote: Compressing objects: 100% (15059/15059), done.
remote: Total 18020 (delta 3022), reused 9186 (delta 1764), pack-reused 0
Receiving objects: 100% (18020/18020), 18.87 MiB | 13.74 MiB/s, done.
Resolving deltas: 100% (3022/3022), done.
Updating files: 100% (15514/15514), done.
INFO: Checking out PR#1102757
fatal: couldn't find remote ref pull/1102757/head
INFO: Cleaning up

@Aipoc76
Copy link

Aipoc76 commented Feb 15, 2024

I can't get this installed on HAOS supervised. I get this error, why could that be?

[core-ssh ~]$ cd /config
[core-ssh config]$ curl -o- -sSL https://gist.githubusercontent.com/bdraco/43f8043cb04b9838383fd71353e99b18/raw/core_integration_pr | bash /dev/stdin -d switchbot -p 1102757
INFO: Current dir is /config
INFO: Cloning core to 
Cloning into '/tmp/core_git'...
remote: Enumerating objects: 18020, done.
remote: Counting objects: 100% (18020/18020), done.
remote: Compressing objects: 100% (15059/15059), done.
remote: Total 18020 (delta 3022), reused 9186 (delta 1764), pack-reused 0
Receiving objects: 100% (18020/18020), 18.87 MiB | 13.74 MiB/s, done.
Resolving deltas: 100% (3022/3022), done.
Updating files: 100% (15514/15514), done.
INFO: Checking out PR#1102757
fatal: couldn't find remote ref pull/1102757/head
INFO: Cleaning up

take off the 7 on the end of the curl . I copied and pasted from line above in reply, but on actual install I used the origional code.

https://gist.githubusercontent.com/bdraco/43f8043cb04b9838383fd71353e99b18/raw/core_integration_pr | bash /dev/stdin -d switchbot -p 110275

is correct.

@bikeymouse
Copy link

Yes, thanks! Confirmed working, with blinds!

@aarnaegg
Copy link

With this issue fixed in 2024.2.2, is it safe to delete the custom switchbot folder under custom_components?

@jorgwolski
Copy link

jorgwolski commented Feb 22, 2024

Be sure to remove the custom component this will generate later after upgrading to the next HA version.

Yes.

@aarnaegg
Copy link

aarnaegg commented Feb 22, 2024

Yes.

@jorgwolski I'm struggling to delete the folder. I get "Directory not empty" when clicking delete. How do I do so?

@Aipoc76
Copy link

Aipoc76 commented Feb 22, 2024

Yes.

@jorgwolski I'm struggling to delete the folder. I get "Directory not empty" when clicking delete. How do I do so?
cd /config/custom_components
rm -r switchbot

@aarnaegg
Copy link

cd /config/custom_components
rm -r switchbot

Got it. Thanks!

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

Successfully merging a pull request may close this issue.