diff --git a/internal/homekit/api.go b/internal/homekit/api.go index 5d2b38d2..d46ace84 100644 --- a/internal/homekit/api.go +++ b/internal/homekit/api.go @@ -72,9 +72,18 @@ func apiHomekit(w http.ResponseWriter, r *http.Request) { } func apiHomekitAccessories(w http.ResponseWriter, r *http.Request) { - src := r.URL.Query().Get("src") - stream := streams.Get(src) + id := r.URL.Query().Get("id") + stream := streams.Get(id) + if stream == nil { + http.Error(w, "", http.StatusNotFound) + return + } + rawURL := findHomeKitURL(stream.Sources()) + if rawURL == "" { + http.Error(w, "", http.StatusBadRequest) + return + } client, err := hap.Dial(rawURL) if err != nil {