core icon indicating copy to clipboard operation
core copied to clipboard

Home Assistant Core 2024.2.0 Switchbot Blind Tilt bluetooth not reporting State

Open scoobiesti2006 opened this issue 5 months ago • 6 comments

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

scoobiesti2006 avatar Feb 08 '24 05:02 scoobiesti2006

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)

home-assistant[bot] avatar Feb 08 '24 05:02 home-assistant[bot]

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'

Tntdruid avatar Feb 08 '24 07:02 Tntdruid

same issue image

lviciedo avatar Feb 08 '24 13:02 lviciedo

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'

c0nt4x avatar Feb 08 '24 14:02 c0nt4x

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'

Aipoc76 avatar Feb 08 '24 14:02 Aipoc76

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.

msva17 avatar Feb 08 '24 23:02 msva17

Issue still present with Core 2024.2.1

jorgwolski avatar Feb 09 '24 12:02 jorgwolski

Issue still present with Core 2024.2.1

Still broken.

Tntdruid avatar Feb 09 '24 12:02 Tntdruid

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: https://github.com/home-assistant/core/issues/109734 https://github.com/home-assistant/core/issues/108087 https://github.com/Danielhiversen/pySwitchbot/pull/226

bdraco avatar Feb 09 '24 16:02 bdraco

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.

jonnybergdahl avatar Feb 09 '24 16:02 jonnybergdahl

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 https://github.com/Danielhiversen/pySwitchbot/pull/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

blindguynar avatar Feb 09 '24 17:02 blindguynar

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: https://github.com/Danielhiversen/pySwitchbot/pull/226#issuecomment-1935971390

bdraco avatar Feb 09 '24 18:02 bdraco

Same exact Error here. Same logs already provided.

RudiP avatar Feb 10 '24 06:02 RudiP

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.

austwhite avatar Feb 10 '24 13:02 austwhite

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"

willliamchan avatar Feb 10 '24 19:02 willliamchan

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

dcmeglio avatar Feb 11 '24 02:02 dcmeglio

@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'

laskatj avatar Feb 11 '24 04:02 laskatj

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.

jorgwolski avatar Feb 11 '24 04:02 jorgwolski

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

dcmeglio avatar Feb 11 '24 04:02 dcmeglio

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?

jonnybergdahl avatar Feb 11 '24 13:02 jonnybergdahl

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

bdraco avatar Feb 11 '24 16:02 bdraco

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.

jorgwolski avatar Feb 11 '24 17:02 jorgwolski

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.

bdraco avatar Feb 11 '24 17:02 bdraco

Tested on mine and confirmed it is working!

Thanks!


From: J. Nick Koston @.> Sent: 11 February 2024 17:15 To: home-assistant/core @.> Cc: willliamchan @.>; Comment @.> Subject: Re: [home-assistant/core] Home Assistant Core 2024.2.0 Switchbot Blind Tilt bluetooth not reporting State (Issue #109947)

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.

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/109947#issuecomment-1937813068, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANBLBDPF3KSXQYBAKGFRKHDYTD4CJAVCNFSM6AAAAABC7CEQEOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZXHAYTGMBWHA. You are receiving this because you commented.Message ID: @.***>

willliamchan avatar Feb 11 '24 17:02 willliamchan

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.

dcmeglio avatar Feb 11 '24 17:02 dcmeglio

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!

aarnaegg avatar Feb 11 '24 19:02 aarnaegg

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

c0nt4x avatar Feb 12 '24 16:02 c0nt4x

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!

BigThunderSR avatar Feb 15 '24 13:02 BigThunderSR

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.

Aipoc76 avatar Feb 15 '24 15:02 Aipoc76

Thanks for this. Works for me too.

Tvojm100 avatar Feb 15 '24 20:02 Tvojm100