Add HomeKit support for fans#14351
Conversation
cdce8p
left a comment
There was a problem hiding this comment.
This PR is already looking quite good. I didn't had time to test it yet, but nevertheless added a few small comments.
There was a problem hiding this comment.
Is their a reason you use split_entity_id instead of DOMAIN imported from components.fan?
As I see it, it should be enough to use the later one.
There was a problem hiding this comment.
No reason, just copied the base code from type_switches. I agree though, I've updated to import from components.fan
There was a problem hiding this comment.
Does this change over time? At the moment no homekit type accounts for chnages in supported features, so I think changing this to self.speed_list would work.
There was a problem hiding this comment.
No, you're correct in that it doesn't change after being initialized at startup.
There was a problem hiding this comment.
Can you use hass.services.call instead. Also for the ones below.
I just haven't gotten around to harmonize that for the other types.
There was a problem hiding this comment.
No problem, I can help with updating the other types accordingly too.
There was a problem hiding this comment.
No need to do that now. I'm planing to start converting the first methods to async, maybe as soon as this weekend. I can do it then.
That in mind it would be great if we could finish up on #14159 first. As a heads up: I'm rewriting almost all tests at the moment to use pytest and async. Should get the PR out in the next few hours. It might require a rebase then.
There was a problem hiding this comment.
Sounds good.
I'll get #14159 wrapped up tonight so that can be closed out.
Regarding tests for this PR, should I wait for your new PR, then rebase and add/update for fans?
There was a problem hiding this comment.
I just opened the PR #14377
The foundations stayed the same. It might be best if you take a look at one of the new type tests and write the new tests based on that structure. They should work even without the PR being merged.
However, it is likely that #14159 needs to be rebased once the PR is merged.
There was a problem hiding this comment.
Understood, I'll look at the new tests tonight and update this PR.
There was a problem hiding this comment.
I just merged the test PR, should be good to rebase now.
There was a problem hiding this comment.
Can we use if instead? Dictionary mapping is a bit much for just to values.
There was a problem hiding this comment.
No problem, updated.
There was a problem hiding this comment.
What reason is their to define it as class variable? As I see it, it's only used in update_state. Same for self._direction and self._oscillating.
There was a problem hiding this comment.
Sorry, I just copied the base code from type_lights. It's not needed so I removed.
There was a problem hiding this comment.
Same as before. I think if is more than enough here.
There was a problem hiding this comment.
No problem, updated.
There was a problem hiding this comment.
line too long (82 > 79 characters)
There was a problem hiding this comment.
line too long (82 > 79 characters)
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
566d839 to
81aa101
Compare
| if CHAR_ROTATION_DIRECTION in self.chars: | ||
| direction = new_state.attributes.get(ATTR_DIRECTION) | ||
| if not self._flag[CHAR_ROTATION_DIRECTION] and \ | ||
| direction in (DIRECTION_FORWARD, DIRECTION_REVERSE): |
There was a problem hiding this comment.
This currently doesn't work if set from the frontend. See home-assistant/frontend#1158
014e350 to
14197ad
Compare
|
@cdce8p I tested the latest commit, all good here. I also updated description to explain lack of speed support. PR for docs is updated as well. Ready to merge. |
Description:
Adds support for fans in HomeKit. In addition to basic on/off it uses
supported_featuresto add additional characteristics fordirectionandoscillation(in HomeKit,oscillation=swing_mode).Support for
speedis not being implemented yet due to the current architecture ofspeed_list. Refer to home-assistant/architecture#27 for more details. Once an improved architecture forspeed_listis set and entities updated, HomeKit will be updated to supportspeed.Related issue (if applicable): N/A
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#5346
Example entry for
configuration.yaml(if applicable):Checklist:
tox. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.If the code does not interact with devices: