Fix import cameras from Hass config

This commit is contained in:
Alexey Khit
2023-03-19 16:53:36 +03:00
parent 43840576ea
commit 7c79c1ff26
2 changed files with 7 additions and 2 deletions
+6 -1
View File
@@ -1,6 +1,7 @@
package hass package hass
import ( import (
"bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/AlexxIT/go2rtc/cmd/api" "github.com/AlexxIT/go2rtc/cmd/api"
@@ -62,12 +63,16 @@ func Init() {
var options struct { var options struct {
StreamSource string `json:"stream_source"` StreamSource string `json:"stream_source"`
} }
if err = json.Unmarshal(entrie.Data, &options); err != nil { if err = json.Unmarshal(entrie.Options, &options); err != nil {
continue continue
} }
urls[entrie.Title] = options.StreamSource urls[entrie.Title] = options.StreamSource
case "homekit_controller": case "homekit_controller":
if !bytes.Contains(entrie.Data, []byte("iOSPairingId")) {
continue
}
var data struct { var data struct {
ClientID string `json:"iOSPairingId"` ClientID string `json:"iOSPairingId"`
ClientPrivate string `json:"iOSDeviceLTSK"` ClientPrivate string `json:"iOSDeviceLTSK"`
+1 -1
View File
@@ -35,7 +35,7 @@ func apiHandle(w http.ResponseWriter, r *http.Request) {
switch r.Method { switch r.Method {
case "GET": case "GET":
if Auth.UserData == nil { if Auth.UserData == nil {
http.Error(w, "", http.StatusNotFound) http.Error(w, "no auth", http.StatusNotFound)
return return
} }