Skip to content

Rachio Async fixes#33549

Merged
balloob merged 9 commits intohome-assistant:devfrom
brg468:dev
Apr 3, 2020
Merged

Rachio Async fixes#33549
balloob merged 9 commits intohome-assistant:devfrom
brg468:dev

Conversation

@brg468
Copy link
Copy Markdown
Contributor

@brg468 brg468 commented Apr 2, 2020

Proposed change

Fix Rachio functions

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

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

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

@probot-home-assistant
Copy link
Copy Markdown

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

@brg468
Copy link
Copy Markdown
Contributor Author

brg468 commented Apr 2, 2020

@MartinHjelmare let me know what I messed up

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.

Please also rename state_attributes property to device_state_attributes in RachioZone class.

Comment thread homeassistant/components/rachio/switch.py
Comment thread homeassistant/components/rachio/switch.py
Comment thread homeassistant/components/rachio/switch.py
Comment thread homeassistant/components/rachio/switch.py Outdated
Comment thread homeassistant/components/rachio/switch.py Outdated
@MartinHjelmare
Copy link
Copy Markdown
Member

MartinHjelmare commented Apr 2, 2020

There was some legacy code that I've commented on too now.

Comment thread homeassistant/components/rachio/switch.py Outdated
Comment thread homeassistant/components/rachio/switch.py Outdated
@brg468
Copy link
Copy Markdown
Contributor Author

brg468 commented Apr 2, 2020

Ill push the rest of the changes later.

Thanks @bdraco !

@bdraco
Copy link
Copy Markdown
Member

bdraco commented Apr 3, 2020

I'll retest after dinner

Copy link
Copy Markdown
Member

@bdraco bdraco left a comment

Choose a reason for hiding this comment

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

LGTM

@brg468
Copy link
Copy Markdown
Contributor Author

brg468 commented Apr 3, 2020

@bdraco. I should have let you handle this one 😄. I’m thinking I’m out of my element here. Lint is failing on undo_dispatcher.

Do we still need this?

async def async_will_remove_from_hass(self):
        """Unsubscribe from updates."""
        if self._undo_dispatcher:
            self._undo_dispatcher()

@bdraco
Copy link
Copy Markdown
Member

bdraco commented Apr 3, 2020

@bdraco. I should have let you handle this one 😄. I’m thinking I’m out of my element here. Lint is failing on undo_dispatcher.

Do we still need this?

async def async_will_remove_from_hass(self):
        """Unsubscribe from updates."""
        if self._undo_dispatcher:
            self._undo_dispatcher()

Its not needed anymore since the self.async_on_remove( wrapping is doing that

@brg468
Copy link
Copy Markdown
Contributor Author

brg468 commented Apr 3, 2020

That was my guess but wasn’t sure. Thanks again 👍

@bdraco
Copy link
Copy Markdown
Member

bdraco commented Apr 3, 2020

That was my guess but wasn’t sure. Thanks again 👍

Here is what is going on under the hood
homeassistant/helpers/entity.py

    @callback
    def async_on_remove(self, func: CALLBACK_TYPE) -> None:
        """Add a function to call when entity removed."""
        if self._on_remove is None:
            self._on_remove = []
        self._on_remove.append(func)

    async def async_remove(self) -> None:
        """Remove entity from Home Assistant."""
        assert self.hass is not None
        await self.async_internal_will_remove_from_hass()
        await self.async_will_remove_from_hass()

        if self._on_remove is not None:
            while self._on_remove:
                self._on_remove.pop()()

@brg468
Copy link
Copy Markdown
Contributor Author

brg468 commented Apr 3, 2020

Thanks again! I'm fairly new to this and I obviously have a lot left to learn. I don't have any more PR's in the works for a while 😄.

@bdraco
Copy link
Copy Markdown
Member

bdraco commented Apr 3, 2020

Thanks again! I'm fairly new to this and I obviously have a lot left to learn. I don't have any more PR's in the works for a while 😄.

The code base is still under heavy development and we are all learning. Happy to review more PRs if you do come up with more!

@bdraco
Copy link
Copy Markdown
Member

bdraco commented Apr 3, 2020

Tested schedules, flex schedules, on/off via app and via home assistant.
Tested setting up config flow
Tested removing integration

TEST PASS

@bdraco
Copy link
Copy Markdown
Member

bdraco commented Apr 3, 2020

Thanks again! I'm fairly new to this and I obviously have a lot left to learn. I don't have any more PR's in the works for a while 😄.

If you are feeling ambitious and want to do a new PR, binary_sensor.py has many of the same issues that your just fixed !

@brg468 brg468 requested a review from MartinHjelmare April 3, 2020 03:33
@balloob balloob merged commit 2065039 into home-assistant:dev Apr 3, 2020
@lock lock Bot locked and limited conversation to collaborators Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants