Refactor how entities are created for homekit_controller services#43242
Merged
Jc2k merged 1 commit intohome-assistant:devfrom Nov 16, 2020
Merged
Refactor how entities are created for homekit_controller services#43242Jc2k merged 1 commit intohome-assistant:devfrom
Jc2k merged 1 commit intohome-assistant:devfrom
Conversation
21 tasks
davet2001
approved these changes
Nov 16, 2020
Contributor
davet2001
left a comment
There was a problem hiding this comment.
This looks good to me. Code quality seems fine and new appears to replicate functionality of old. I tried the tests locally and they seem fine.
I don't fully understand this integration, but this does look to be an improvement, replacing dict/string lookups with constants.
The only suggestion I could make is perhaps to add some type hints to the function definitions, but no reason that couldn't be a separate PR.
Member
Author
|
Cheers for the review! I have a few more rounds of clean up planned for this part of the code so i'll keep your type hint suggestion in mind! |
KJonline
pushed a commit
to Pyhass/core
that referenced
this pull request
Nov 17, 2020
* 'dev' of https://github.com/home-assistant/core: (77 commits) Fix kodi media_player unavailable at start (home-assistant#41714) Add an option to template delay_on/off in template binary sensor (home-assistant#43259) Bump hatasmota to 0.0.31 (home-assistant#43319) Update cloud integration to 0.38.0 (home-assistant#43314) Add progress translation key to hassfest (home-assistant#43311) Bump codecov/codecov-action from v1.0.14 to v1.0.15 (home-assistant#43304) Improvement to allow parsing of station ID in vasttrafik integration. Addresses home-assistant#34851 (home-assistant#43136) Abort vizio discovery flow without unique ID (home-assistant#43303) Update directv to 0.4.0 (home-assistant#43302) Add notification binary_sensor to Plugwise integration (home-assistant#41473) [ci skip] Translation update Bump bimmer_connected to 0.7.13 (home-assistant#43294) Bump aioguardian to 1.0.4 (home-assistant#43299) Refactor how entities are created for homekit_controller services (home-assistant#43242) Updated frontend to 20201111.1 (home-assistant#43298) Update pytradfri to 7.0.4 (home-assistant#43297) Remove pts adjustments in stream (home-assistant#42399) Fix Enigma2 available entity property (home-assistant#43292) Make MQTT climate return PRESET_NONE when no preset is set (home-assistant#43257) Bump env_canada to 0.2.4, fix config validation (home-assistant#43251) ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed change
#42676 and #43100 highlighted something i've been thinking about for a while. The way HomeKit services are enumerated and turned into entities is currently not only too limiting but also awkward because you have to directly parse the JSON data from HomeKit.
This PR allows the functions that create entities to instead operate on the aiohomekit entity map abstraction which is already used in the entity implementations themselves.
It turns something like this:
Into:
It also means we can use the aiohomekit constants for service types.
No new tests - but this bit of code is already exercised quite well by the existing ones.
Type of change
Example entry for
configuration.yaml:N/A
Additional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: