Skip to content

Convert songpal to use asynchronous websocket for state updates#19129

Merged
balloob merged 7 commits intohome-assistant:devfrom
rytilahti:songpal_nonpolling
Dec 12, 2018
Merged

Convert songpal to use asynchronous websocket for state updates#19129
balloob merged 7 commits intohome-assistant:devfrom
rytilahti:songpal_nonpolling

Conversation

@rytilahti
Copy link
Copy Markdown
Member

@rytilahti rytilahti commented Dec 8, 2018

Description:

This PR converts songpal platform to use the websocket interface for instantaneous updates on state changes.

Related issue (if applicable): fixes #

Example entry for configuration.yaml (if applicable):

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@rytilahti rytilahti changed the title Add websocket-based non-polling variant for songpal Convert songpal to use asynchronous websocket for state updates Dec 9, 2018
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Looks good! Just two small comments.

@property
def should_poll(self):
"""Return True if the device should be polled."""
return self._poll
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we keep the attribute?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd prefer keeping it around for the time being, if someone comes up with a broken setup it makes it easy to check if the polling variant would work in that case.

self._available = True

# activate notifications if wanted
if not self._poll:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this check?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

See above. If you think it's better to remove it, I'll do that.

@MartinHjelmare
Copy link
Copy Markdown
Member

I think we can merge.

@balloob balloob merged commit 2fc0dfe into home-assistant:dev Dec 12, 2018
@ghost ghost removed the in progress label Dec 12, 2018
@rytilahti rytilahti deleted the songpal_nonpolling branch December 12, 2018 22:26
dshokouhi pushed a commit to dshokouhi/home-assistant that referenced this pull request Dec 25, 2018
…-assistant#19129)

* Add websocket-based non-polling variant for songpal

* linting fixes

* changes based on Martin's feedback

* Fix linting

* add backoff timer for reconnects, fix variable naming (I thought that this wouldn't matter for internals..)

* Remove poll configuration variable

* bump the version just to be sure, the previous release lacked a version file (required for setup.py)
@balloob balloob mentioned this pull request Jan 10, 2019
rytilahti added a commit to home-assistant/home-assistant.io that referenced this pull request Jan 20, 2019
Songpal defaults to local push since home-assistant/core#19129 .
fabaff pushed a commit to home-assistant/home-assistant.io that referenced this pull request Jan 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants