-
Notifications
You must be signed in to change notification settings - Fork 11
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 possibility of using an address list instead #202
Conversation
I am unsure of why the linter fails to install poetry |
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's an amazing improvements, thanks man! Have a few suggestions
Please see my changes and the last comment that are open 😃 |
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.
Yay! Amazing job, man! Thanks 💯
Just a minor comment about default IPs/port, then we figure out why CI fails and it's good to go 🚀
p.s. speaking of CI and failing linters, can you please try few things:
- rebase this branch to latest
master
when doing changes - run
poetry install
locally - run
poetry run pre-commit install
locally - run
poetry run pre-commit run all-files
locally
Hopefully it should help your linters get up to date and fix the issues :)
I have no idea of what went wrong and why it essentially deletes and the adds |
Can it be line endings? |
3b3118d
to
c8d2fbf
Compare
Got it fixed, i have no idea what went wrong but rolled back to a working commit and fixed the linter. @leikoilja Can I get you to release a new version after this is merged? Oh and can i get you to merged it? 😄 |
Can you give some context about what problem you're solving with this? |
79440fe
to
08f7029
Compare
leikoilja/ha-google-home#340 is just one of them. As i am working on moving the ha-google-home code to the separate module, i ran into some problems with zeroconf on WSL2. Code run in WSL2 can't discover devices through zeroconf. This just makes it much easier for me to test it while i am coding 😄 |
Thanks, makes sense. I think breaking compatibility for such change is not necessary, so let's keep Instead add |
@KapJI We need to pass the name of the device as the key and the IP address as the value. If we don't, we can't match the IP address to the device and so on. Making it a separate argument, means the user now needs to set |
You don't need to disable discovery completely. If it crashes on WSL2, you can disable it automatically if running inside WSL2. Mapping from IP to name makes more sense from UX perspective which I believe should come before implementation. You can build reverse dict here if needed. |
I Think you are missing the point of what i am trying to do with this PR. It dosen't make sense to reverse it like you are takling about. We match on device name not the IP. |
Ok, having name as a key is fine actually. |
Nice! |
@leikoilja Thanks for both invites! Haven really been active here, so that is fine that i am only getting it now 😆 I will let @KapJI suggestions about |
Approach I proposes should be more flexible. Basically you can still use discovery and extend it with your own list. Also empty dict for disabling discovery while None enables it, is not very clear API. |
@KapJI Good point about it not being clear the way i have proposed. |
08f7029
to
9ef7340
Compare
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.
Amazing stuff, thanks, @DurgNomis-drol 🚀
To me, we are ready to merge 💥
@KapJI? :)
Co-authored-by: Ilja Leiko <[email protected]>
Good catch! Co-authored-by: Ilja Leiko <[email protected]>
Amazing work, thank you, @DurgNomis-drol 💯 🔥 |
ping @DurgNomis-drol for v0.6 release |
@@ -405,6 +429,14 @@ def find_device(unique_id: str) -> NetworkDevice | None: | |||
unique_id, | |||
) | |||
network_device = find_device(unique_id) | |||
elif item.device_name in address_dict: |
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.
This means if discovery is enabled, address_dict
won't be used. That contradicts the idea to have separate disable_discovery
flag.
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.
Also if there's no item with such name in address_dict
, it's worth to print a warning message.
@@ -335,6 +337,7 @@ def get_google_devices( | |||
self, | |||
models_list: list[str] | None = None, | |||
disable_discovery: bool = False, | |||
addresses: dict[str, str] | None = None, |
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.
It's better to add new arguments in the end, to not break reverse compatibility.
This changes
disable_discovery
from a bool toaddress_list
containing a dict. Example dict: ``{"Living room": "192.168.0.69"}` Not setting the address_list results in discovery been enabled. Setting it to and empty dict results in discovery being disabled.I was not 100% sure on how to best implement this, so please provide feedback if something can be done better. 😄
Code is tested, but can someone double check to make sure that we are not breaking anything with this.