tapo: drop IP-address handling, use host string throughout#29914
Draft
andig wants to merge 2 commits into
Draft
Conversation
The Tapo library used to require a netip.Addr, which forced us to parse the configured URI, extract the hostname, and reject anything that wasn't an IP literal. With insomniacslk/tapo#8 the library now takes a plain host string (hostname or IP), so we can hand the URL's Host straight through. This makes the UI's "host or IP" hint actually work, no DNS resolution lives in evcc anymore, and the connection setup is one step shorter. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider whether
tapo.NewPlugshould receiveu.Hostname()instead ofu.Host, as the current change will now pass through any explicit port as part of the host string, which differs from the previousnetip.ParseAddr(url.Hostname())behavior. - The
NewConnectionURI validation only checksu.Host == ""; if you care about rejecting malformed inputs like missing scheme or path-only strings, you might want to useurl.ParseRequestURIor add an explicit scheme/host sanity check. - Given the temporary
replacedirective ingo.mod, you might want to add a brief inline comment (e.g.// TODO: drop once insomniacslk/tapo#8 is tagged) to make the intent clear to future maintainers.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider whether `tapo.NewPlug` should receive `u.Hostname()` instead of `u.Host`, as the current change will now pass through any explicit port as part of the host string, which differs from the previous `netip.ParseAddr(url.Hostname())` behavior.
- The `NewConnection` URI validation only checks `u.Host == ""`; if you care about rejecting malformed inputs like missing scheme or path-only strings, you might want to use `url.ParseRequestURI` or add an explicit scheme/host sanity check.
- Given the temporary `replace` directive in `go.mod`, you might want to add a brief inline comment (e.g. `// TODO: drop once insomniacslk/tapo#8 is tagged`) to make the intent clear to future maintainers.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
With the upstream library accepting a plain host string, there is no need
for evcc to round-trip through a URL. Switch the config field and the
template render output from "uri: http://{{ .host }}" to "host: {{ .host }}",
drop the url package import in connection.go, and pass the host directly
to tapo.NewPlug.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Cleanup follow-up to #29768. Hands the configured URI's host straight to the Tapo library instead of round-tripping through
netip.Addr.netip.ParseAddrstep (and the "invalid ip address" rejection of hostnames)net/httpinside the tapo libraryCompanion upstream PR: insomniacslk/tapo#8 (drops
netip.Addrfrom the public API;tapo.NewPlugnow takes a host string).Replace #29768