-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Conversation
…outlet is in use or not
e66758a
to
ec8ccfe
Compare
@@ -62,3 +70,20 @@ def turn_off(self, **kwargs): | |||
'iid': self._chars['on'], | |||
'value': False}] | |||
self.put_characteristics(characteristics) | |||
|
|||
@property | |||
def state_attributes(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be device_state_attributes
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so base entities are using state_attributes and platforms like homekit should use device_state_attributes. Is that correct ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need a property. Just assign to a regular instance attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
"""Return the optional state attributes.""" | ||
data = {} | ||
|
||
for prop, attr in PROP_TO_ATTR.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's only one attribute we don't need a dict or use getattr
. Keep it simple for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
…the device_state_attributes method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Can be merged when build passes.
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.
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:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices: