mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-05 23:15:07 -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:
20
state.go
Normal file
20
state.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package gomeassistant
|
||||
|
||||
import "github.com/saml-dev/gome-assistant/internal/http"
|
||||
|
||||
// State is used to retrieve state from Home Assistant.
|
||||
type State struct {
|
||||
httpClient *http.HttpClient
|
||||
}
|
||||
|
||||
func NewState(c *http.HttpClient) *State {
|
||||
return &State{httpClient: c}
|
||||
}
|
||||
|
||||
func (s *State) Get(entityId string) (string, error) {
|
||||
resp, err := s.httpClient.GetState(entityId)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(resp), nil
|
||||
}
|
||||
Reference in New Issue
Block a user