-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Zwave: add power_consumption attribute #60 8000 67
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
Conversation
…into zwave_power Conflicts: homeassistant/components/zwave/__init__.py
…into zwave_power
@andrey-git, thanks for your PR! By analyzing the history of the files in this pull request, we identified @balloob, @turbokongen and @fabaff to be potential reviewers. |
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.
Why?
This is already discovered as a sensor entity in the sensor component:
https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/sensor/zwave.py#L41
Also there is changes to the light component, and partially refactors of the other attributes present in this PR.
Re: why The sensor is a separate device. Putting this in the attributes allows to use it for automation. The change to light is indeed unrelated. Should I put it in a separate PR? I cleaned up data access in init.py so it won't access zwave data on attribute fetch |
The init changes are already a part of a different discussion over here: |
@turbokongen I'll hold this PR until you commit your z-wave refactoring |
…into zwave_power Conflicts: homeassistant/components/zwave/__init__.py
Merged with other submitted PRs. Ready for review. |
Added a minor change: made attribute internal to Z-Wave. |
I btw think that this is a very good change. We should keep as many attributes from a device together. |
@@ -712,8 +720,9 @@ def _value_handler(self, method=None, class_id=None, index=None, | |||
May only be used inside callback. | |||
|
|||
""" | |||
if class_id is not None: | |||
if class_id is not None and not isinstance(class_id, list): |
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.
The code surrounding class_id
is very complex:
- if
class_id
is given but it is not a list, use OZW method to filter it - if
class_id
is given but it is a list, use our methods to filter it.
I think that this should be done in a nicer way: (example ignores the class_id is None
part)
values = []
if not isinstance(class_id, list):
class_id = [class_id]
for cid in class_id:
values.extend(self._value.node.get_values(class_id=cid).values())
And now you don't need to add any extra filtering below.
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.
Done
🐬 |
Description:
Add power_consumption attribute to power-measuring z-wave devices
If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests pass