Skip to content

ZHA cover device support#30639

Merged
Adminiuga merged 14 commits into
home-assistant:devfrom
billyburly:dev
Jan 12, 2020
Merged

ZHA cover device support#30639
Adminiuga merged 14 commits into
home-assistant:devfrom
billyburly:dev

Conversation

@billyburly
Copy link
Copy Markdown
Contributor

Description:

Support for ZHA cover devices. Allows control of IKEA Fyrtur blinds via the zha integration

Related issue (if applicable): fixes #

Pull request with documentation for home-assistant.io : home-assistant/home-assistant.io#11695

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist

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

@homeassistant
Copy link
Copy Markdown
Contributor

Hi @billyburly,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@probot-home-assistant
Copy link
Copy Markdown

Hey there @dmulcahey, @Adminiuga, mind taking a look at this pull request as its been labeled with a integration (zha) you are listed as a codeowner for? Thanks!

Copy link
Copy Markdown
Contributor

@Adminiuga Adminiuga left a comment

Choose a reason for hiding this comment

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

Call cluster commands as methods of the channel.

Comment thread homeassistant/components/zha/core/channels/closures.py Outdated
@billyburly
Copy link
Copy Markdown
Contributor Author

@Adminiuga added a check to see if the commands were successful

@Adminiuga
Copy link
Copy Markdown
Contributor

Hrm, I have no ideas why codecov fails.

@Adminiuga Adminiuga self-requested a review January 10, 2020 19:55
Copy link
Copy Markdown
Contributor

@Adminiuga Adminiuga left a comment

Choose a reason for hiding this comment

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

@dmulcahey this looks fine to me. But wouldn't mind a second set of eyes.

@dmulcahey
Copy link
Copy Markdown
Contributor

Awesome, I’ll peek at this in detail in the morning.

@Adminiuga
Copy link
Copy Markdown
Contributor

I think if you cover a couple more lines like in here https://codecov.io/gh/home-assistant/home-assistant/compare/d25aa1f1830f1d3fad42dde3f9bdfae2ad98b7f2...0567474b9473e0c06ee40a3323aae41d54b1d5f1/diff#D4-92 it should pass the coverage test.

@Adminiuga
Copy link
Copy Markdown
Contributor

@Adminiuga
Copy link
Copy Markdown
Contributor

install pre-commit . saves some time ;)

@dmulcahey
Copy link
Copy Markdown
Contributor

I think if you cover a couple more lines like in here https://codecov.io/gh/home-assistant/home-assistant/compare/d25aa1f1830f1d3fad42dde3f9bdfae2ad98b7f2...0567474b9473e0c06ee40a3323aae41d54b1d5f1/diff#D4-92 it should pass the coverage test.

@billyburly You need to add a test to cover the uncovered branch in async_get_state lines 170 and 171. That should get you past the coverage check.

@dmulcahey
Copy link
Copy Markdown
Contributor

This looks good to me. Thanks for the contribution! This can be merged after the coverage check passes.

@Adminiuga
Copy link
Copy Markdown
Contributor

@billyburly wanna give billyburly#1 a try?

I still don't fully understand, why with

    with patch(
        "homeassistant.components.zha.core.channels.ZigbeeChannel.get_attribute_value",
        return_value=coro_mock(100)
    ) as get_attr_mock:

The mock gets called two times, but return 100 only the 1st time, so async_get_state() still was getting None for the attribute value.

Update ZHA cover tests coverage.
@Adminiuga Adminiuga merged commit 4d64172 into home-assistant:dev Jan 12, 2020
@Adminiuga
Copy link
Copy Markdown
Contributor

Thank you!

@billyburly
Copy link
Copy Markdown
Contributor Author

@Adminiuga thanks for the help with the test

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Some suggestions for the future.

"""Open the window cover."""
res = await self._cover_channel.up_open()
if isinstance(res, list) and res[1] is Status.SUCCESS:
self.async_set_state(STATE_OPENING)
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.

"""Close the window cover."""
res = await self._cover_channel.down_close()
if isinstance(res, list) and res[1] is Status.SUCCESS:
self.async_set_state(STATE_CLOSING)
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.

"""Stop the window cover."""
res = await self._cover_channel.stop()
if isinstance(res, list) and res[1] is Status.SUCCESS:
self._state = STATE_OPEN if self._current_position > 0 else STATE_CLOSED
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 async_set_state?


async def async_set_cover_position(self, **kwargs):
"""Move the roller shutter to a specific position."""
new_pos = kwargs.get(ATTR_POSITION)
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.

Position is required.

new_pos = kwargs[ATTR_POSITION]

@lock lock Bot locked and limited conversation to collaborators Jan 13, 2020
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