Conversation
There was a problem hiding this comment.
'homeassistant.components.device_tracker.DOMAIN' imported but unused
|
I've run tox in my local repo, but I have no output so I'm not sure it's actually testing anything... I have some questions regarding this PR: First of all, is it ok to make this pull request to initiate discussions even if it depends on a third-party library version that is not released yet, or should I have waited? Secondly, the Freebox requires a manual intervention from the user to authorize applications, pretty much like the Hue bridge does: the first time an application requests access to the server, the user must authorize it directly on the device. What would be the correct way to handle this? Do I need to make a custom component so that the user can configure the access from the home page, as is done for Hue for instance, or is it acceptable to simply give instructions in the documentation (for starters)? About the automatic setup through discovery, I was wondering if it is something desirable for device trackers? Device tracking can be seen as a bit intrusive, is it a good idea to start doing it without user intervention? If not, what would be the correct approach to notify the user that we discovered a Freebox device, along with the host and port to use in her configuration file if she wishes to set it up? |
|
WIP PRs are OK. You can use the configurator component to ask the user to perform actions to facilitate login or setup. Look at eg the August component. Another alternative is the new config entry flow. See #12830 for hue. This flow is very new and might be considered experimental. It also requires test coverage if you implement it. The config flow approach will also handle discovery and let the user dismiss a discovered device if its not wanted to be setup as an integration. The user can turn off discovery component if it's not wanted. It's also possible to configure it to ignore certain platforms. |
|
Is there a way to beta test ? |
|
@MartinHjelmare The new config flow seems to be exactly what I had in mind, I'll read through the related PRs and see if I can implement it. @ylecuyer Beta testing would be much welcomed, but for now it requires a bit of manual intervention to install the unreleased-yet dependencies. You will need to install freepybox with the latest changes, either from the upstream repo, or from my fork where the version number has already been bumped to 0.0.3. If you want to test discovery, you will need a version of netdisco with this commit, or you can rollback the netdisco version number to 1.2.4 and use manual configuration. Please let me know if you have any questions or feedback! |
3c5f277 to
c181382
Compare
c181382 to
f77a40f
Compare
f77a40f to
1a806f2
Compare
|
It's been a while since I reached out to the maintainer of Freepybox without response, so I decided to fork his work in an asynchronous library, which will be more suited to integration in Hass. I've released it on PyPI (aiofreepybox) and I've modified the component to make it asynchronous as well. However, I still have an error I'm not sure how to solve: my log repeatedly indicates that "
I have this error even when I disable the Freebox device tracker, so I'm not sure it comes from my code, but since it seems to relate to the asyncio loop, I'm wondering if it could be related to the other error. Any insight? FYI, I'm currently working on Windows with Python 3.6.4. |
1a806f2 to
9c464d9
Compare
9c464d9 to
adf3c70
Compare
|
I've tested my code on Ubuntu with Python 3.5.3: I no longer have the error in asyncio, but I still have the "coroutine was never awaited" one, so I guess I'm doing something wrong with |
|
Shouldn't If you search for |
There was a problem hiding this comment.
Do we need to create a new instance of Freepybox at every update? Can't we instantiate this in init and save it as an instance attribute?
There was a problem hiding this comment.
Sure, I'll do that. Do you see any problem if I leave the session opening/closing in the update function though? Doing so, we don't have to deal explicitely with lost connection, auth token refresh etc.
There was a problem hiding this comment.
The future that this returns is never awaited.
There was a problem hiding this comment.
Since we're not interested in the result of the future, ie the return value of async_see, I suggest you use asyncio.wait instead of asyncio.gather.
There was a problem hiding this comment.
Why do we need the try... finally?
There was a problem hiding this comment.
If getting the hosts blows up, nothing in the following normal flow will execute, including awaiting the closing task.
There was a problem hiding this comment.
The goal was to "fire and forget" the closing task when an exception occurs (push the async task to the event loop, but without waiting for it to finish before rethrowing the exception), and "fire and await" in the normal flow, but I may have misunderstood how this works (this is my first time developing with asyncio).
Perhaps I should wrap this in an async context manager, I'll need to check how to do that properly.
adf3c70 to
61b2018
Compare
There was a problem hiding this comment.
asyncio is part of standard library so should be imported at the top of the module.
There was a problem hiding this comment.
asyncio is part of standard library so should be imported at the top of the module.
There was a problem hiding this comment.
If we expect an exception here, maybe we should try to catch it, if we know what it is and if it will happen often?
There was a problem hiding this comment.
Move the rest of the docstring from this line to the documentation. Replace this line with a link to the documentation. See other platforms for the correct link format.
61b2018 to
114e68d
Compare
|
@MartinHjelmare Thanks for the reviews, all good points! I will be on holidays for the next week, I'll make the changes when I'll be back. However, I still don't understand why |
|
No, we should use Are you still getting that warning after the latest changes? |
|
@MartinHjelmare After investigating a bit, I think I understand what the problem is. The Throttle decorator wraps the coroutine function in a non-coroutine function (and rightfully so, |
114e68d to
04863ae
Compare
|
Since you're scheduling the update from this module, I suggest simply taking the max of configured scan interval and min time between updates, and use that as update interval. And remove the throttle. |
|
Documentation added in home-assistant/home-assistant.io#5415. |
04863ae to
5d8225d
Compare
There was a problem hiding this comment.
Put this and the see call within an else: here. These calls should not be done if the error happens.
There was a problem hiding this comment.
Add a check if last_results is truthy before doing this.
5d8225d to
c8de2aa
Compare
|
Hi ! This component works great :) @stilllman have you tried to add internet status support (sensor I guess?), in order to see which state is the connection (1,2 ... to 6), connexion uptime, current speed dl/up,... ? |
|
Hey @gsemet! I have considered making a full-fledged component instead of just a device tracker, with support for toggling wifi, getting list of missed calls, etc., but I wanted to see if there was a need in the community before doing so :) I won't start working on this before at least a few weeks though, I just had a happy event in my life that will keep me quite busy! In the meantime, how about creating a feature request with the features you would like to see in the component? You can take a look at the Freebox API to see what would be feasible or not. |
|
Congrat for this happy event :) mine is expected by the end of this year, so I may find some time to implement the freebox status + some action switchs ;) |
Description:
This pull request adds a device tracker platform for the Freebox, the server/router of the french FAI Free, along the lines of PR #10702. It is based on freepybox, but it necessitates some changes that have not been released yet.
The platform can be set up automatically through discovery (once this netdisco commit will be released), or configured as usual.
There is some documentation in the header of the file, I can make that a full documentation page in home-assistant.github.io if need be.
Example entry for
configuration.yaml(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
toxrun successfully. Your PR cannot be merged unless tests passREQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.If the code does not interact with devices:
toxrun successfully. Your PR cannot be merged unless tests pass