core icon indicating copy to clipboard operation
core copied to clipboard

Add support for non-serialized lutron caseta lights (RA3 Zones)

Open danaues opened this issue 3 years ago • 3 comments

Proposed change

Add support for non-serialized lighting Zones from RA3 Processors.

Type of change

  • [ ] Dependency upgrade
  • [X] 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

RA3 Processors don't return a serial number for light zones. HA requires a UniqueID, and the integration isn't able to generate one with a "None" serial. This generates a UniqueID using the Bridge Unique ID and the Device ID, using the same idea as the occupancy sensors.

Tested on my RA3 and Caseta PRO setups.

Checklist

  • [X] The code change is tested and works locally.
  • [X] Local tests pass. Your PR cannot be merged unless tests pass
  • [X] There is no commented out code in this PR.
  • [X] I have followed the development checklist
  • [X] The code has been formatted using Black (black --fast homeassistant tests)
  • [X] 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.

The integration reached or maintains the following Integration Quality Scale:

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

To help with the load of incoming pull requests:

danaues avatar Jul 16 '22 15:07 danaues

Hey there @swails, @bdraco, 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! (message by CodeOwnersMention)

Thank you for your contribution thus far! 🎖 Since you have been making significant contributions, we would appreciate you'd added yourself to the list of code owners for this integration. ❤️

Please, add your GitHub username to the manifest.json of this integration.

For more information about "code owners", see: Architecture Decision Record 0008: Code owners.

bdraco avatar Jul 16 '22 16:07 bdraco

@bdraco , can you confirm that you're looking to have a test created for this, that will be executed by pytest? Or do you just mean some real world testing by users?

danaues avatar Aug 09 '22 22:08 danaues

@bdraco , can you confirm that you're looking to have a test created for this, that will be executed by pytest? Or do you just mean some real world testing by users?

Ideally pytest

bdraco avatar Aug 13 '22 22:08 bdraco

I'm afraid the creation of this test is beyond my current abilities with HA development. I just can't wrap my head around the test frameworks and how they interact with HA. I'm ok with modifying a test to adapt code changes, but starting from scratch isn't working.

Is there another way to get this tested so we can merge?

PR#101 in pylutron-caseta has now been merged into dev enabling RA3 support.
https://github.com/gurumitts/pylutron-caseta/pull/101

This PR, and a bump in version number to pylutron-caseta (once ready) is all that's left to get it all working.

Thanks.

danaues avatar Aug 19 '22 03:08 danaues

I pushed up a framework for a basic light test.

You'll need to mock out the light device in MockBridge so it adds a light

bdraco avatar Aug 19 '22 04:08 bdraco

Thanks a million. I'll dig into it.

danaues avatar Aug 19 '22 04:08 danaues

Tests are complete and functional. Thanks for the help.

danaues avatar Aug 19 '22 06:08 danaues

I"m just realizing we may need to handle None serials for other device domains too. Cover, fan and switch.
I don't have any of these on my system, but I'll reach out to some other users to get data to build the tests.

danaues avatar Aug 19 '22 12:08 danaues

I pushed a small tweak to make this a bit more DRY

bdraco avatar Aug 20 '22 19:08 bdraco

If you are ready for this to be merged please mark it ready for review

bdraco avatar Aug 20 '22 19:08 bdraco

Ok thanks, I didn't know you could add it to init.py like that.

Will this method in binary_sensor.py override the one in init.py? Otherwise everyone will be dealing with renamed occupancy groups.

https://github.com/home-assistant/core/blob/87be71ce6a111d5dc0ea6bf56ed79ea99dcbb4ef/homeassistant/components/lutron_caseta/binary_sensor.py#L75-L78

danaues avatar Aug 20 '22 19:08 danaues

Ok thanks, I didn't know you could add it to init.py like that.

Will this method in binary_sensor.py override the one in init.py? Otherwise everyone will be dealing with renamed occupancy groups.

https://github.com/home-assistant/core/blob/87be71ce6a111d5dc0ea6bf56ed79ea99dcbb4ef/homeassistant/components/lutron_caseta/binary_sensor.py#L75-L78

The binary_sensor doesn't inherit from LutronCasetaDeviceUpdatableEntity but it would be overriding it anyways if it did

bdraco avatar Aug 20 '22 19:08 bdraco

Everything looks great. Thx!

danaues avatar Aug 20 '22 20:08 danaues

Thanks @danaues

bdraco avatar Aug 20 '22 20:08 bdraco