Skip to content
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

Fix lutron caseta triggers when device fails to setup before startup finishes #82714

Merged
merged 5 commits into from Nov 30, 2022

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Nov 25, 2022

Proposed change

Refactor the trigger attach so its not dependent on the integration being already setup

Alternative to #82605 which avoids reverting #80797 which is where this regressed

fixes #82495 & fixes #81999 & closes #82605 & fixes https://community.home-assistant.io/t/lutron-caseta-pico-not-firing-automations-in-11-2/487552 & fixes https://community.home-assistant.io/t/lutron-caseta-pico-core-integration-only/280419/75?u=bdraco

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)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

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.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @swails, @danaues, mind taking a look at this pull request as it has been labeled with an integration (lutron_caseta) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of lutron_caseta can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign lutron_caseta Removes the current integration label and assignees on the issue, add the integration domain after the command.

@bdraco bdraco force-pushed the lutron_late_setup branch 2 times, most recently from c42ba11 to 3542218 Compare November 25, 2022 19:32
class LutronButton(TypedDict):
"""A lutron_caseta button."""

lutron_device_id: int
leap_button_number: int
button_name: str
led_device_id: int
led_device_id: str | None
Copy link
Member Author

Choose a reason for hiding this comment

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

The typing on this was wrong

) -> LutronKeypadData:
"""Register keypad devices (Keypads and Pico Remotes) in the device registry."""

device_registry = dr.async_get(hass)

bridge_devices = bridge.get_devices()
bridge_buttons = bridge.buttons
bridge_devices: dict[str, dict[str, str | int]] = bridge.get_devices()
Copy link
Member Author

Choose a reason for hiding this comment

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

I had so much trouble following this code so I added some more typing to make sure I didn't screw it up

…finishes

Refactor the trigger attach so its not dependant on the intergration
being already setup

fixes home-assistant#82495 & fixes home-assistant#81999
@@ -298,6 +302,8 @@ async def test_if_fires_on_button_event_without_lip(hass, calls, device_reg):
ATTR_DEVICE_NAME: device["Name"],
ATTR_AREA_NAME: device.get("Area", {}).get("Name"),
ATTR_ACTION: "press",
ATTR_DEVICE_ID: device_id,
ATTR_BUTTON_TYPE: "Kitchen Pendants",
Copy link
Member Author

@bdraco bdraco Nov 25, 2022

Choose a reason for hiding this comment

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

This should have been a button type and not a name since it is unstable if the name is changed on the lutron device.

I can't fix this in this PR as it would require a redesign and a breaking change

@bdraco bdraco added this to the 2022.11.5 milestone Nov 25, 2022
@bdraco bdraco marked this pull request as ready for review November 25, 2022 19:51
@bdraco
Copy link
Member Author

bdraco commented Nov 25, 2022

@danaues This should avoid the revert but I can't fix the instability with the name changing in this PR since it would be a breaking change.

Can you test this on your system?

@danaues
Copy link
Contributor

danaues commented Nov 26, 2022

I’m away from my system right now, but I’ll give it a full test tomorrow afternoon when I’m back.

@bdraco bdraco modified the milestones: 2022.11.5, 2022.12.0b0 Nov 28, 2022
@balloob
Copy link
Member

balloob commented Nov 29, 2022

@danaues did you have time to test it?

@danaues
Copy link
Contributor

danaues commented Nov 29, 2022

Just finished testing. Looks good!
Tested on Caseta Pro and RA3

@bdraco
Copy link
Member Author

bdraco commented Nov 30, 2022

Thanks. I tested the other systems

@balloob balloob merged commit a3ec952 into home-assistant:dev Nov 30, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants