mirror of
https://github.com/Xevion/go-ha.git
synced 2026-01-31 02:24:26 -06:00
good progress yay:
- impl http client - create http client in App() - generic builder for Service.* - set Service on app to pass to callbacks later - impl State - set State on app to pass to callbacks later - change panic to log.Fatalln
This commit is contained in:
+8
-10
@@ -3,21 +3,19 @@ package gomeassistant
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/saml-dev/gome-assistant/internal/http"
|
||||
"github.com/saml-dev/gome-assistant/internal/services"
|
||||
"nhooyr.io/websocket"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
HomeAssistant homeAssistant
|
||||
Light services.Light
|
||||
HomeAssistant *services.HomeAssistant
|
||||
Light *services.Light
|
||||
}
|
||||
|
||||
type homeAssistant struct {
|
||||
conn websocket.Conn
|
||||
ctx context.Context
|
||||
func NewService(conn *websocket.Conn, ctx context.Context, httpClient *http.HttpClient) *Service {
|
||||
return &Service{
|
||||
Light: services.BuildService[services.Light](conn, ctx),
|
||||
HomeAssistant: services.BuildService[services.HomeAssistant](conn, ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// type light struct {
|
||||
// conn websocket.Conn
|
||||
// ctx context.Context
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user