From 6d264d6336e4eeb643209185cab23fffc38fb5e0 Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Fri, 19 Aug 2022 06:55:43 +0300 Subject: [PATCH] Fix Hass integration --- cmd/hass/hass.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/hass/hass.go b/cmd/hass/hass.go index eb8b32a0..5d89260d 100644 --- a/cmd/hass/hass.go +++ b/cmd/hass/hass.go @@ -24,6 +24,15 @@ func Init() { app.LoadConfig(&conf) + log = app.GetLogger("api") + + // support https://www.home-assistant.io/integrations/rtsp_to_webrtc/ + api.HandleFunc("/static", func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + }) + api.HandleFunc("/stream", handler) + + // support load cameras from Hass config file filename := path.Join(conf.Mod.Config, ".storage/core.config_entries") data, err := os.ReadFile(filename) if err != nil { @@ -52,14 +61,6 @@ func Init() { } return nil, fmt.Errorf("can't get url: %s", url) }) - - // support https://www.home-assistant.io/integrations/rtsp_to_webrtc/ - api.HandleFunc("/static", func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusOK) - }) - api.HandleFunc("/stream", handler) - - log = app.GetLogger("api") } var log zerolog.Logger