Skip to content

Commit bc1a4ac

Browse files
committed
Fix API /api/homekit/accessories
1 parent 158f9d3 commit bc1a4ac

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

internal/homekit/api.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,18 @@ func apiHomekit(w http.ResponseWriter, r *http.Request) {
7272
}
7373

7474
func apiHomekitAccessories(w http.ResponseWriter, r *http.Request) {
75-
src := r.URL.Query().Get("src")
76-
stream := streams.Get(src)
75+
id := r.URL.Query().Get("id")
76+
stream := streams.Get(id)
77+
if stream == nil {
78+
http.Error(w, "", http.StatusNotFound)
79+
return
80+
}
81+
7782
rawURL := findHomeKitURL(stream.Sources())
83+
if rawURL == "" {
84+
http.Error(w, "", http.StatusBadRequest)
85+
return
86+
}
7887

7988
client, err := hap.Dial(rawURL)
8089
if err != nil {

0 commit comments

Comments
 (0)