Skip to content

Zwave panel api#7456

Merged
balloob merged 18 commits into
home-assistant:devfrom
turbokongen:zwave-panel
May 10, 2017
Merged

Zwave panel api#7456
balloob merged 18 commits into
home-assistant:devfrom
turbokongen:zwave-panel

Conversation

@turbokongen
Copy link
Copy Markdown
Contributor

Description:

API to the zwave-panel

Related issue (if applicable): fixes #
home-assistant/frontend#260

Copy link
Copy Markdown
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

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

Awesome start! Got some minor comments but it looks great.

Comment thread homeassistant/components/zwave/api.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be debug at best, probably better to just remove it?

Comment thread homeassistant/components/zwave/api.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No need to use keys(), that's the default. Just use for key in groupdata:

Comment thread homeassistant/components/zwave/api.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are you sure you need to do this? What are the values in groupdata ?

Also, if you need to cast node_id to int, please do it once at the top.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's not the desired output. It's missing the max_associations so it needs to be done to get that.

Comment thread homeassistant/components/zwave/api.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Change it to {node_id:\d+} to only match numbers.

Comment thread homeassistant/components/zwave/api.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This shouldn't be logged as info.

Comment thread homeassistant/components/zwave/api.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please don't log this.

Comment thread homeassistant/components/zwave/api.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove this

Comment thread homeassistant/components/zwave/api.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add regex

Comment thread homeassistant/components/zwave/api.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Parse node_id once.

Comment thread homeassistant/components/zwave/api.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use a guard clause

if not node.has_command_class(…):
    return self.json_message(…)

for value in

Copy link
Copy Markdown
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

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

👍

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

expected 2 blank lines, found 1

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

too many blank lines (3)

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'tests.common.mock_http_component_app' imported but unused

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

local variable 'mock_network' is assigned to but never used

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

expected 2 blank lines, found 1

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

local variable 'mock_network' is assigned to but never used

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

expected 2 blank lines, found 1

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

local variable 'mock_network' is assigned to but never used

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

too many blank lines (4)

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'tests.mock.zwave.MockNode' imported but unused

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'homeassistant.setup.async_setup_component' imported but unused

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'unittest.mock.patch' imported but unused

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'pytest' imported but unused

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

too many blank lines (3)

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

local variable 'ZWaveGroup' is assigned to but never used

@balloob
Copy link
Copy Markdown
Member

balloob commented May 9, 2017

So this is a good start for tests, however, the tests don't test anything yet?? It expects an empty dictionary?

Comment thread homeassistant/components/zwave/api.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why fetch the groups as dict, then iterate over the keys and construct group objects again?

Seems like node.groups will give you a list of groups too? https://github.com/OpenZWave/python-openzwave/blob/master/src-api/openzwave/node.py#L289

@balloob
Copy link
Copy Markdown
Member

balloob commented May 9, 2017

Updated one of your tests to show how to fetch data.

Comment thread tests/components/zwave/test_api.py Outdated
result = yield from resp.json()

assert result == {'message': 'Node not found'}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

blank line at end of file

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

local variable 'network' is assigned to but never used

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

local variable 'value' is assigned to but never used

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

closing bracket does not match visual indentation

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

closing bracket does not match visual indentation

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

too many blank lines (3)

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

local variable 'value' is assigned to but never used

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

missing whitespace after ':'

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

redefinition of unused 'test_get_groups' from line 11

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

missing whitespace after ':'

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

missing whitespace after ':'

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

redefinition of unused 'test_get_groups' from line 11

Comment thread tests/components/zwave/test_api.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

missing whitespace after ':'

@balloob balloob merged commit 1eaec8f into home-assistant:dev May 10, 2017
@balloob
Copy link
Copy Markdown
Member

balloob commented May 10, 2017

🎉 🐬 ❤️

@home-assistant home-assistant locked and limited conversation to collaborators Aug 12, 2017
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