Autoadd cameras from Hass config
This commit is contained in:
+28
-11
@@ -41,28 +41,45 @@ func Init() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ent := new(entries)
|
storage := new(entries)
|
||||||
if err = json.Unmarshal(data, ent); err != nil {
|
if err = json.Unmarshal(data, storage); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
urls := map[string]string{}
|
urls := map[string]string{}
|
||||||
|
|
||||||
for _, entrie := range ent.Data.Entries {
|
|
||||||
switch entrie.Domain {
|
|
||||||
case "generic":
|
|
||||||
if entrie.Options.StreamSource != "" {
|
|
||||||
urls[entrie.Title] = entrie.Options.StreamSource
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
streams.HandleFunc("hass", func(url string) (streamer.Producer, error) {
|
streams.HandleFunc("hass", func(url string) (streamer.Producer, error) {
|
||||||
if hurl := urls[url[5:]]; hurl != "" {
|
if hurl := urls[url[5:]]; hurl != "" {
|
||||||
return streams.GetProducer(hurl)
|
return streams.GetProducer(hurl)
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("can't get url: %s", url)
|
return nil, fmt.Errorf("can't get url: %s", url)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
for _, entrie := range storage.Data.Entries {
|
||||||
|
switch entrie.Domain {
|
||||||
|
case "generic":
|
||||||
|
if entrie.Options.StreamSource == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
urls[entrie.Title] = entrie.Options.StreamSource
|
||||||
|
|
||||||
|
//case "homekit_controller":
|
||||||
|
// if entrie.Data.ClientID == "" {
|
||||||
|
// continue
|
||||||
|
// }
|
||||||
|
// urls[entrie.Title] = fmt.Sprintf(
|
||||||
|
// "homekit://%s:%d?client_id=%s&client_private=%s%s&device_id=%s&device_public=%s",
|
||||||
|
// entrie.Data.DeviceHost, entrie.Data.DevicePort,
|
||||||
|
// entrie.Data.ClientID, entrie.Data.ClientPrivate, entrie.Data.ClientPublic,
|
||||||
|
// entrie.Data.DeviceID, entrie.Data.DevicePublic,
|
||||||
|
// )
|
||||||
|
|
||||||
|
default:
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
streams.Get("hass:" + entrie.Title)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var log zerolog.Logger
|
var log zerolog.Logger
|
||||||
|
|||||||
Reference in New Issue
Block a user