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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report states #11973

Merged
merged 3 commits into from Jan 29, 2018
Merged

Report states #11973

merged 3 commits into from Jan 29, 2018

Conversation

bitglue
Copy link
Member

@bitglue bitglue commented Jan 27, 2018

Description:

This depends on #12016. For review purposes the first commit in this PR can be ignored, since it's in #12016.

This reports properties for PowerController, LockController, and BrightnessController. That should cover most use cases. It covers all the devices I have, at least 馃槃

I did some fairly extensive refactoring to make the implementation of properties more readable. Suggest reviewing commits individually. I'd like to refactor the tests some more as well since there's a lot of copy pasta there, but that can wait for another day.

Related issue (if applicable): fixes #11874

Checklist:

  • The code change is tested and works locally.
  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

assert msg['header']['name'] == 'Discover.Response'
assert msg['header']['namespace'] == 'Alexa.Discovery'

endpoint_ids = set(appliance['endpointId'] for appliance in msg['payload']['endpoints'])

Choose a reason for hiding this comment

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

line too long (92 > 79 characters)

if not self.properties_retrievable():
return

properties = []

Choose a reason for hiding this comment

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

local variable 'properties' is assigned to but never used

@bitglue
Copy link
Member Author

bitglue commented Jan 28, 2018

No pylint, that function doesn't only return None. If you're so good at programming, why don't you open the PRs?

Having an object per interface will make it easier to support
properties.

Ideally, properties are reported in context in all responses. However
current implementation reports them only in response to a ReportState
request. This seems to work sufficiently. As long as the device is
opened in the Alexa app, Amazon will poll the device state every few
seconds with a ReportState request.
Fixes (mostly) home-assistant#11874.

Other interfaces will need properties implemented as well.

Implementing properties for just PowerController seems sufficient to
eliminate the "There was a problem." error for any device that supports
it, even if other interfaces are supported. Of course the additional
properties will be reported incorrectly in the Alexa app.

Includes a minor bugfix: `reportable` was previously placed incorrectly
in the responses, so Amazon was ignoring it.
@balloob balloob merged commit 7d6ef44 into home-assistant:dev Jan 29, 2018
@balloob balloob mentioned this pull request Feb 9, 2018
@home-assistant home-assistant locked and limited conversation to collaborators May 29, 2018
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.

Send State Report to Alexa when a HA entity state changes
4 participants