Parse URL and pass it to clients

Right now, this SDK only works with IP:Port.
I'm however running on https://home.example.com and need https or wss and an implicit port 443.

Using net/url should be the best option.
This commit is contained in:
Matthias Loibl
2025-01-17 01:45:42 +01:00
parent 066441762b
commit b5d35235f8
7 changed files with 67 additions and 71 deletions

View File

@@ -1,4 +1,4 @@
package example
package main
import (
"encoding/json"
@@ -11,12 +11,12 @@ import (
func main() {
app, err := ga.NewApp(ga.NewAppRequest{
IpAddress: "192.168.86.67", // Replace with your Home Assistant IP Address
URL: "http://192.168.86.67:8123", // Replace with your Home Assistant IP Address
HAAuthToken: os.Getenv("HA_AUTH_TOKEN"),
HomeZoneEntityId: "zone.home",
})
if err != nil {
slog.Error("Error connecting to HASS:", err)
slog.Error("Error connecting to HASS:", "error", err)
os.Exit(1)
}