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
Add basic support for IKEA Fyrtur blinds #26659
Conversation
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
IKEA = "IKEA of Sweden" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use the IKEA
constant in many platforms. We can move it to const.py in the package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, looking more closely at it, I'm not sure it's being used at all. I'll remove it from all files.
|
||
def set_cover_position(self, **kwargs): | ||
"""Move the cover to a specific position.""" | ||
if ATTR_POSITION in kwargs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to check for this. It's validated by the service schema already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, removed it.
@callback | ||
def _async_start_observe(self, exc=None): | ||
"""Start observation of cover.""" | ||
from pytradfri.error import PytradfriError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move 3rd party imports to the top of the module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed and changed in all files.
I've posted in the HA forums where adding support has been requested for and asked for someone to do a test against a real blind. |
Make sure to run black from the project root.
|
Thanks, I have a sneaking feeling there was something I'd forgotten in the process! Mind if I add a link to that blog post to the development checklist? |
How can I test this? |
@robbinonline: clone my branch, run the docker script and start HASS. Pair the gateway as usual and the blind should be there. |
Hmm that sounds like a big project. Not possible to install it like a custom component or update the changed files? |
I’m afraid I don’t know how that works. You need to update pytradfri to 6.3.0 and add a file to the tradfri folder but if that is possible as a custom component is beyond me. The dockerfile ia dockerfile.dev (in my repo, not the official one) if you feel adventurous. |
I have updated pytradfri to 6.3.0 and change .coveragerc and add cover.py. Do I also need the other files for the blinds? |
No, only cover.py. |
@robbinonline woke up this morning realizing I’ve forgotten to change one file. 🤦♂️ Will fix and post here when done. |
Ah thats hopefully the reason its not working here, try it for hours yesterday 😅 |
Really sorry about that 🙈 Its been a while since I last built something för HA. |
Really appreciate it, looking forward to the updated code! |
@robbinonline the forgotten change has been added to the code now. You also need to update the |
@ggravlingen Allright update the code, and now the blinds shows up in the Integrations, only with the state: entity not available Checking the logs:
Did I miss something? |
@robbinonline you did nothing wrong at all and this is the reason we're testing 😄 It appears I needed to add a |
"""Return if the cover is closed or not.""" | ||
if self.current_cover_position == 0: | ||
return True | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a return False
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@robbinonline that's a bit of progress then that we can track current state :) No errors in the log? I've also adressed the comment of @MartinHjelmare but don't know if that will do anything to make changing the state work. @MartinHjelmare sorry about spamming this PR. I can ping you when it's working if you want to turn off notifications for this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't worry about notifying me. I'm happy to see the progress. It's also easier to review small chunks at a time. 👍
Has someone tested the observation method in pytradfri with the blinds? |
@MartinHjelmare good point, I'll go back to pytradfri to find someone to test. This would have been so much easier if I'd had a blind. :) |
@MartinHjelmare I made some changes to pytradfri to see if we can fix the error that's starting to pop up with the new gateway firmware (#26673). Hence the version bump to 6.3.1. |
It would be better to put the library bump in a separate PR since we then could include it in a patch release since it's potentially a fix for a problem. |
@MartinHjelmare I agree and I will do so as I reckon it will take a bit longer to sort out observation. There are a few people who are up and running testing this branch, including a few who experience the bug, so I figured it'd be an easy way of testing to just bump the version here. |
Argh, I rebased and messed up 🤦♂ |
I'll fix this later tonight |
@MartinHjelmare when you feel the code is in line with HA standards, this one is good to go. I got confirmation on the forums that it works as expected:
|
def __init__(self, cover, api, gateway_id): | ||
"""Initialize a cover.""" | ||
self._api = api | ||
self._unique_id = f"cover-{gateway_id}-{cover.id}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entity registry is aware of the integration domain and platform domain of the entity, so adding cover
isn't necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The light platform has two kinds of entities, light and group. If there are more than one type of entity in a platform and the rest of the id is the same between the two kinds, we need to add a differentiator.
I don't know if this is actually the case for the light platform, ie if group.id
and light.id
are the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, thanks for the explanation
Can be merged when build passes. |
Thank you for the advice during review and to all the testers 🎉🙏 |
Description:
This PR adds basic support for the IKEA Fyrtur window blinds.
Caveat: I don't have one myself, so I need to find someone to test the code. I suggest this to be done before reviewing the code.
Related issue (if applicable): fixes #
Pull request with documentation for home-assistant.io (if applicable): home-assistant/home-assistant.io#10373
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:
python3 -m script.hassfest
.requirements_all.txt
by runningpython3 -m script.gen_requirements_all
..coveragerc
.If the code does not interact with devices: