-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix blocking HA process using asyncio #9
Conversation
Also stop/play media on volume change so it is applied
Timeout on connection
Thanks for contributing! There is unhandled exception when device is unavailable: 2024-03-16 17:06:37.084 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.vacuum fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 945, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1262, in async_device_update
await self.async_update()
File "/config/custom_components/sox/media_player.py", line 218, in async_update
await self._async_send("") # For compatibility with old sound server
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/sox/media_player.py", line 195, in _async_send
if writer:
^^^^^^
UnboundLocalError: cannot access local variable 'writer' where it is not associated with a value |
Ups missed that :) |
Integration doesn't try to connect to device if it was offline during HA start. However after successful start reconnecting works. Any ideas? |
I'm suspecting of async def async_update(self):
"""Get the latest data and update the state."""
if self._is_connected is None or self._volume is not None:
await self._async_send("") # For compatibility with old sound server Although it should connect as soon as a command is sent. I'm testing that. BTW, I'm curious, did you also notice your home assistant working better with this PR? |
Ok, If it is not connected, HA won't send the play command. I guess it used to work because the send command would error. |
fix reconnection
Do you know why the update function has an |
Should be fixed now |
It's definitely better now.
The first version of sound server doesn't support volume control and state reporting. I used |
Also stop/play media on volume change so it is applied
Fixes #8