8000 Zwave: add power_consumption attribute by andrey-git · Pull Request #6067 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 11 commits into from
Feb 19, 2017

Conversation

andrey-git
Copy link
Contributor

Description:

Add power_consumption attribute to power-measuring z-wave devices

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass

@mention-bot
Copy link

@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.

Copy link
Contributor
@turbokongen turbokongen left a 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.

@andrey-git
Copy link
Contributor Author

Re: why

The sensor is a separate device. Putting this in the attributes allows to use it for automation.
It will also allow to use it for the switch/light UI.

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

@turbokongen
Copy link
Contributor
turbokongen commented Feb 17, 2017

The init changes are already a part of a different discussion over here:
#5961 Feel free to join in.
I think you should keep a PR to the specific change you want to do, and make more PR's ;)
It's much cleaner that way, and easier to review.

@andrey-git
Copy link
Contributor Author

@turbokongen I'll hold this PR until you commit your z-wave refactoring

…into zwave_power

Conflicts:
	homeassistant/components/zwave/__init__.py
@andrey-git
Copy link
Contributor Author

Merged with other submitted PRs. Ready for review.

@balloob
Copy link
Member
balloob commented Feb 18, 2017

Added a minor change: made attribute internal to Z-Wave.

@balloob
Copy link
Member
balloob commented Feb 18, 2017

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):
Copy link
Member
@balloob balloob Feb 18, 2017

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@balloob
Copy link
Member
balloob commented Feb 18, 2017

🐬

@balloob balloob merged commit beb8b4b into home-assistant:dev Feb 19, 2017
@andrey-git andrey-git deleted the zwave_power branch February 23, 2017 17:28
@home-assistant home-assistant locked and limited conversation to collaborators Jun 2, 2017
@ghost ghost removed the platform: light.zwave label Mar 21, 2019
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.

5 participants
0