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

Add additional property to HomeKitSwitch to show whether the Homekit outlet is in use #17448

Merged
merged 2 commits into from Nov 6, 2018

Conversation

Projects
None yet
6 participants
@drndos
Contributor

drndos commented Oct 14, 2018

Description:

This pull request adds a feature where you get additional property to your switch that is representing Homekit outlet indicating whether the actual outlet is in use or not. Tested on Koogeek P1EU and working.
image

Related issue (if applicable):

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#<home-assistant.io PR number goes here>

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

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

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

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

If the code does not interact with devices:

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

@drndos drndos force-pushed the drndos:homekit-outlet-in-use branch from e66758a to ec8ccfe Oct 14, 2018

@robbiet480 robbiet480 removed the cla-error label Oct 15, 2018

@home-assistant home-assistant deleted a comment from homeassistant Oct 20, 2018

@@ -62,3 +70,20 @@ def turn_off(self, **kwargs):
'iid': self._chars['on'],
'value': False}]
self.put_characteristics(characteristics)
@property
def state_attributes(self):

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Oct 20, 2018

Member

This should be device_state_attributes.

This comment has been minimized.

@drndos

drndos Oct 21, 2018

Contributor

Ok so base entities are using state_attributes and platforms like homekit should use device_state_attributes. Is that correct ?

This comment has been minimized.

@MartinHjelmare

This comment has been minimized.

@drndos

drndos Oct 21, 2018

Contributor

Thank you very much for clarification. I am just learning how to contribute and use things properly. I appreciate your time and help :)

return data
@property
def outlet_in_use(self):

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Oct 20, 2018

Member

We don't need a property. Just assign to a regular instance attribute.

This comment has been minimized.

@drndos

drndos Oct 21, 2018

Contributor

ok

"""Return the optional state attributes."""
data = {}
for prop, attr in PROP_TO_ATTR.items():

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Oct 20, 2018

Member

If it's only one attribute we don't need a dict or use getattr. Keep it simple for now.

This comment has been minimized.

@drndos

drndos Oct 21, 2018

Contributor

ok

@MartinHjelmare

Looks good! Can be merged when build passes.

@balloob balloob merged commit 24efda2 into home-assistant:dev Nov 6, 2018

5 checks passed

Hound No violations found. Woof!
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.05%) to 93.601%
Details

@wafflebot wafflebot bot removed the in progress label Nov 6, 2018

zxdavb added a commit to zxdavb/home-assistant that referenced this pull request Nov 13, 2018

Add additional property to HomeKitSwitch to show whether the Homekit …
…outlet is in use (home-assistant#17448)

* Add additional property to HomeKitSwitch to show whether the Homekit outlet is in use or not

* Fix issues from review - Remove unused property, simplify and rename the device_state_attributes method

@balloob balloob referenced this pull request Nov 29, 2018

Merged

0.83 #18776

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment