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

Support proxy of binary messages from addons to HA #4605

Merged
merged 5 commits into from
Oct 14, 2023
Merged

Conversation

mdegat01
Copy link
Contributor

@mdegat01 mdegat01 commented Oct 5, 2023

Proposed change

Currently supervisor can only proxy messages of type text from addons to HA. Some addons need to be able to send binary messages as well.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality to the supervisor)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to cli pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast supervisor tests)
  • Tests have been added to verify that the new code works.

If API endpoints of add-on configuration are added/changed:

Copy link
Member

@pvizeli pvizeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Maybe not hard break if the type is not supported, only log it for not break on unknown things

@mdegat01 mdegat01 force-pushed the addon-binary-ws-proxy branch from bf36081 to 848da8a Compare October 12, 2023 20:17
@mdegat01 mdegat01 marked this pull request as ready for review October 12, 2023 20:17
@mdegat01
Copy link
Contributor Author

mdegat01 commented Oct 12, 2023

@pvizeli I was just trying to keep behavior as it was today:

await client.send_str(server_read.result())

If send_str is passed anything other then a string today it will raise TypeError just like I am. If we think that's aggressive I can change it. Although the problem with only logging it is whoever sent the message will have no idea something went wrong. The user will see the log but they can't do anything about that since this is communication between addon and HA.

EDIT: Also I should note, it will actually just log it and close the connection on TypeError:

except (RuntimeError, ConnectionError, TypeError) as err:
_LOGGER.info("Home Assistant WebSocket API error: %s", err)

@pvizeli pvizeli merged commit 012bfd7 into main Oct 14, 2023
@pvizeli pvizeli deleted the addon-binary-ws-proxy branch October 14, 2023 16:07
@github-actions github-actions bot locked and limited conversation to collaborators Oct 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants