Files
go-ha/service.go
Sam Lewis 7bcca889f9 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
2022-10-11 01:22:23 -04:00

22 lines
537 B
Go

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 *services.HomeAssistant
Light *services.Light
}
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),
}
}