mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-15 08:12:00 -06:00
enforce ToState when using Duration
This commit is contained in:
@@ -71,12 +71,12 @@ func get(url, token string) ([]byte, error) {
|
||||
// defer resp.Body.Close()
|
||||
|
||||
// if resp.StatusCode == 401 {
|
||||
// log.Fatalln("ERROR: Auth token is invalid. Please double check it or create a new token in your Home Assistant profile")
|
||||
// panic("ERROR: Auth token is invalid. Please double check it or create a new token in your Home Assistant profile")
|
||||
// }
|
||||
|
||||
// body, err := io.ReadAll(resp.Body)
|
||||
// if err != nil {
|
||||
// log.Fatalln(err)
|
||||
// panic(err)
|
||||
// }
|
||||
|
||||
// return body, nil
|
||||
|
||||
@@ -59,21 +59,21 @@ func SetupConnection(connString string, authToken string) (*websocket.Conn, cont
|
||||
_, err = ReadMessage(conn, ctx)
|
||||
if err != nil {
|
||||
ctxCancel()
|
||||
log.Fatalln("Unknown error creating websocket client")
|
||||
panic("Unknown error creating websocket client")
|
||||
}
|
||||
|
||||
// Send auth message
|
||||
err = SendAuthMessage(conn, ctx, authToken)
|
||||
if err != nil {
|
||||
ctxCancel()
|
||||
log.Fatalln("Unknown error creating websocket client")
|
||||
panic("Unknown error creating websocket client")
|
||||
}
|
||||
|
||||
// Verify auth message was successful
|
||||
err = VerifyAuthResponse(conn, ctx)
|
||||
if err != nil {
|
||||
ctxCancel()
|
||||
log.Fatalln("ERROR: Auth token is invalid. Please double check it or create a new token in your Home Assistant profile")
|
||||
panic("ERROR: Auth token is invalid. Please double check it or create a new token in your Home Assistant profile")
|
||||
}
|
||||
|
||||
return conn, ctx, ctxCancel
|
||||
@@ -132,7 +132,7 @@ func SubscribeToEventType(eventType string, conn *websocket.Conn, ctx context.Co
|
||||
}
|
||||
err := WriteMessage(e, conn, ctx)
|
||||
if err != nil {
|
||||
log.Fatalln("Error writing to websocket: ", err)
|
||||
panic("Error writing to websocket: ", err)
|
||||
}
|
||||
// m, _ := ReadMessage(conn, ctx)
|
||||
// log.Default().Println(string(m))
|
||||
|
||||
Reference in New Issue
Block a user