mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-05 23:15:07 -06:00
chore: reformat, normalize imports
This commit is contained in:
@@ -85,7 +85,7 @@ The general flow is
|
|||||||
3. Start app
|
3. Start app
|
||||||
|
|
||||||
```go
|
```go
|
||||||
import ga "github.com/Xevion/go-ha"
|
import ha "github.com/Xevion/go-ha"
|
||||||
|
|
||||||
// replace with IP and port of your Home Assistant installation
|
// replace with IP and port of your Home Assistant installation
|
||||||
app, err := ga.NewApp(ga.NewAppRequest{
|
app, err := ga.NewApp(ga.NewAppRequest{
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
ga "github.com/Xevion/go-ha"
|
ha "github.com/Xevion/go-ha"
|
||||||
"github.com/Xevion/go-ha/types"
|
"github.com/Xevion/go-ha/types"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
@@ -68,7 +68,7 @@ func toCamelCase(s string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validateHomeZone verifies that the home zone entity exists and is valid
|
// validateHomeZone verifies that the home zone entity exists and is valid
|
||||||
func validateHomeZone(state ga.State, entityID string) error {
|
func validateHomeZone(state ha.State, entityID string) error {
|
||||||
entity, err := state.Get(entityID)
|
entity, err := state.Get(entityID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("home zone entity '%s' not found: %w", entityID, err)
|
return fmt.Errorf("home zone entity '%s' not found: %w", entityID, err)
|
||||||
@@ -99,7 +99,7 @@ func generate(config Config) error {
|
|||||||
config.HomeZoneEntityId = "zone.home"
|
config.HomeZoneEntityId = "zone.home"
|
||||||
}
|
}
|
||||||
|
|
||||||
app, err := ga.NewApp(types.NewAppRequest{
|
app, err := ha.NewApp(types.NewAppRequest{
|
||||||
URL: config.URL,
|
URL: config.URL,
|
||||||
HAAuthToken: config.HAAuthToken,
|
HAAuthToken: config.HAAuthToken,
|
||||||
HomeZoneEntityId: config.HomeZoneEntityId,
|
HomeZoneEntityId: config.HomeZoneEntityId,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/golang-module/carbon"
|
"github.com/golang-module/carbon"
|
||||||
|
|
||||||
"github.com/Xevion/go-ha/internal"
|
"github.com/Xevion/go-ha/internal"
|
||||||
ws "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
"github.com/Xevion/go-ha/types"
|
"github.com/Xevion/go-ha/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ type BaseEventMsg struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Functions */
|
/* Functions */
|
||||||
func callEventListeners(app *App, msg ws.ChannelMessage) {
|
func callEventListeners(app *App, msg connect.ChannelMessage) {
|
||||||
baseEventMsg := BaseEventMsg{}
|
baseEventMsg := BaseEventMsg{}
|
||||||
_ = json.Unmarshal(msg.Raw, &baseEventMsg)
|
_ = json.Unmarshal(msg.Raw, &baseEventMsg)
|
||||||
listeners, ok := app.eventListeners[baseEventMsg.Event.EventType]
|
listeners, ok := app.eventListeners[baseEventMsg.Event.EventType]
|
||||||
|
|||||||
@@ -7,14 +7,13 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
// "example/entities" // Optional import generated entities
|
// "example/entities" // Optional import generated entities
|
||||||
|
ha "github.com/Xevion/go-ha"
|
||||||
ga "github.com/Xevion/go-ha"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:generate go run github.com/Xevion/go-ha/cmd/generate
|
//go:generate go run github.com/Xevion/go-ha/cmd/generate
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app, err := ga.NewApp(ga.NewAppRequest{
|
app, err := ha.NewApp(ha.NewAppRequest{
|
||||||
URL: "http://192.168.86.67:8123", // Replace with your Home Assistant URL
|
URL: "http://192.168.86.67:8123", // Replace with your Home Assistant URL
|
||||||
HAAuthToken: os.Getenv("HA_AUTH_TOKEN"),
|
HAAuthToken: os.Getenv("HA_AUTH_TOKEN"),
|
||||||
HomeZoneEntityId: "zone.home",
|
HomeZoneEntityId: "zone.home",
|
||||||
@@ -32,25 +31,25 @@ func main() {
|
|||||||
slog.Info("Application shutdown complete")
|
slog.Info("Application shutdown complete")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
pantryDoor := ga.
|
pantryDoor := ha.
|
||||||
NewEntityListener().
|
NewEntityListener().
|
||||||
EntityIds(entities.BinarySensor.PantryDoor). // Use generated entity constant
|
EntityIds(entities.BinarySensor.PantryDoor). // Use generated entity constant
|
||||||
Call(pantryLights).
|
Call(pantryLights).
|
||||||
Build()
|
Build()
|
||||||
|
|
||||||
_11pmSched := ga.
|
_11pmSched := ha.
|
||||||
NewDailySchedule().
|
NewDailySchedule().
|
||||||
Call(lightsOut).
|
Call(lightsOut).
|
||||||
At("23:00").
|
At("23:00").
|
||||||
Build()
|
Build()
|
||||||
|
|
||||||
_30minsBeforeSunrise := ga.
|
_30minsBeforeSunrise := ha.
|
||||||
NewDailySchedule().
|
NewDailySchedule().
|
||||||
Call(sunriseSched).
|
Call(sunriseSched).
|
||||||
Sunrise("-30m").
|
Sunrise("-30m").
|
||||||
Build()
|
Build()
|
||||||
|
|
||||||
zwaveEventListener := ga.
|
zwaveEventListener := ha.
|
||||||
NewEventListener().
|
NewEventListener().
|
||||||
EventTypes("zwave_js_value_notification").
|
EventTypes("zwave_js_value_notification").
|
||||||
Call(onEvent).
|
Call(onEvent).
|
||||||
@@ -63,7 +62,7 @@ func main() {
|
|||||||
app.Start()
|
app.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
func pantryLights(service *ga.Service, state ga.State, sensor ga.EntityData) {
|
func pantryLights(service *ha.Service, state ha.State, sensor ha.EntityData) {
|
||||||
l := "light.pantry"
|
l := "light.pantry"
|
||||||
// l := entities.Light.Pantry // Or use generated entity constant
|
// l := entities.Light.Pantry // Or use generated entity constant
|
||||||
if sensor.ToState == "on" {
|
if sensor.ToState == "on" {
|
||||||
@@ -73,18 +72,18 @@ func pantryLights(service *ga.Service, state ga.State, sensor ga.EntityData) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func onEvent(service *ga.Service, state ga.State, data ga.EventData) {
|
func onEvent(service *ha.Service, state ha.State, data ha.EventData) {
|
||||||
// Since the structure of the event changes depending
|
// Since the structure of the event changes depending
|
||||||
// on the event type, you can Unmarshal the raw json
|
// on the event type, you can Unmarshal the raw json
|
||||||
// into a Go type. If a type for your event doesn't
|
// into a Go type. If a type for your event doesn't
|
||||||
// exist, you can write it yourself! PR's welcome to
|
// exist, you can write it yourself! PR's welcome to
|
||||||
// the eventTypes.go file :)
|
// the eventTypes.go file :)
|
||||||
ev := ga.EventZWaveJSValueNotification{}
|
ev := ha.EventZWaveJSValueNotification{}
|
||||||
json.Unmarshal(data.RawEventJSON, &ev)
|
json.Unmarshal(data.RawEventJSON, &ev)
|
||||||
slog.Info("On event invoked", "event", ev)
|
slog.Info("On event invoked", "event", ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
func lightsOut(service *ga.Service, state ga.State) {
|
func lightsOut(service *ha.Service, state ha.State) {
|
||||||
// always turn off outside lights
|
// always turn off outside lights
|
||||||
service.Light.TurnOff(entities.Light.OutsideLights)
|
service.Light.TurnOff(entities.Light.OutsideLights)
|
||||||
s, err := state.Get(entities.BinarySensor.LivingRoomMotion)
|
s, err := state.Get(entities.BinarySensor.LivingRoomMotion)
|
||||||
@@ -99,7 +98,7 @@ func lightsOut(service *ga.Service, state ga.State) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sunriseSched(service *ga.Service, state ga.State) {
|
func sunriseSched(service *ha.Service, state ha.State) {
|
||||||
service.Light.TurnOn(entities.Light.LivingRoomLamps)
|
service.Light.TurnOn(entities.Light.LivingRoomLamps)
|
||||||
service.Light.TurnOff(entities.Light.ChristmasLights)
|
service.Light.TurnOff(entities.Light.ChristmasLights)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ import (
|
|||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
ga "github.com/Xevion/go-ha"
|
ha "github.com/Xevion/go-ha"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
MySuite struct {
|
MySuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
app *ga.App
|
app *ha.App
|
||||||
config *Config
|
config *Config
|
||||||
suiteCtx map[string]any
|
suiteCtx map[string]any
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ func (s *MySuite) SetupSuite() {
|
|||||||
slog.Error("Error unmarshalling config file", "error", err)
|
slog.Error("Error unmarshalling config file", "error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
s.app, err = ga.NewApp(ga.NewAppRequest{
|
s.app, err = ha.NewApp(ha.NewAppRequest{
|
||||||
HAAuthToken: s.config.Hass.HAAuthToken,
|
HAAuthToken: s.config.Hass.HAAuthToken,
|
||||||
IpAddress: s.config.Hass.IpAddress,
|
IpAddress: s.config.Hass.IpAddress,
|
||||||
HomeZoneEntityId: s.config.Hass.HomeZoneEntityId,
|
HomeZoneEntityId: s.config.Hass.HomeZoneEntityId,
|
||||||
@@ -76,13 +76,13 @@ func (s *MySuite) SetupSuite() {
|
|||||||
entityId := s.config.Entities.LightEntityId
|
entityId := s.config.Entities.LightEntityId
|
||||||
if entityId != "" {
|
if entityId != "" {
|
||||||
s.suiteCtx["entityCallbackInvoked"] = false
|
s.suiteCtx["entityCallbackInvoked"] = false
|
||||||
etl := ga.NewEntityListener().EntityIds(entityId).Call(s.entityCallback).Build()
|
etl := ha.NewEntityListener().EntityIds(entityId).Call(s.entityCallback).Build()
|
||||||
s.app.RegisterEntityListeners(etl)
|
s.app.RegisterEntityListeners(etl)
|
||||||
}
|
}
|
||||||
|
|
||||||
s.suiteCtx["dailyScheduleCallbackInvoked"] = false
|
s.suiteCtx["dailyScheduleCallbackInvoked"] = false
|
||||||
runTime := time.Now().Add(1 * time.Minute).Format("15:04")
|
runTime := time.Now().Add(1 * time.Minute).Format("15:04")
|
||||||
dailySchedule := ga.NewDailySchedule().Call(s.dailyScheduleCallback).At(runTime).Build()
|
dailySchedule := ha.NewDailySchedule().Call(s.dailyScheduleCallback).At(runTime).Build()
|
||||||
s.app.RegisterSchedules(dailySchedule)
|
s.app.RegisterSchedules(dailySchedule)
|
||||||
|
|
||||||
// start GA app
|
// start GA app
|
||||||
@@ -122,13 +122,13 @@ func (s *MySuite) TestSchedule() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Capture event after light entity state has changed
|
// Capture event after light entity state has changed
|
||||||
func (s *MySuite) entityCallback(se *ga.Service, st ga.State, e ga.EntityData) {
|
func (s *MySuite) entityCallback(se *ha.Service, st ha.State, e ha.EntityData) {
|
||||||
slog.Info("Entity callback called.", "entity id", e.TriggerEntityId, "from state", e.FromState, "to state", e.ToState)
|
slog.Info("Entity callback called.", "entity id", e.TriggerEntityId, "from state", e.FromState, "to state", e.ToState)
|
||||||
s.suiteCtx["entityCallbackInvoked"] = true
|
s.suiteCtx["entityCallbackInvoked"] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Capture planned daily schedule
|
// Capture planned daily schedule
|
||||||
func (s *MySuite) dailyScheduleCallback(se *ga.Service, st ga.State) {
|
func (s *MySuite) dailyScheduleCallback(se *ha.Service, st ha.State) {
|
||||||
slog.Info("Daily schedule callback called.")
|
slog.Info("Daily schedule callback called.")
|
||||||
s.suiteCtx["dailyScheduleCallbackInvoked"] = true
|
s.suiteCtx["dailyScheduleCallbackInvoked"] = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,14 @@ module example
|
|||||||
go 1.23
|
go 1.23
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/Xevion/go-ha v0.7.0
|
||||||
github.com/golang-cz/devslog v0.0.8
|
github.com/golang-cz/devslog v0.0.8
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.10.0
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
github.com/Xevion/gome-assistant v0.2.0
|
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/Workiva/go-datastructures v1.1.5 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/gobuffalo/envy v1.10.2 // indirect
|
github.com/gobuffalo/envy v1.10.2 // indirect
|
||||||
github.com/gobuffalo/packd v1.0.2 // indirect
|
github.com/gobuffalo/packd v1.0.2 // indirect
|
||||||
@@ -21,4 +22,6 @@ require (
|
|||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/rogpeppe/go-internal v1.11.0 // indirect
|
github.com/rogpeppe/go-internal v1.11.0 // indirect
|
||||||
golang.org/x/mod v0.9.0 // indirect
|
golang.org/x/mod v0.9.0 // indirect
|
||||||
|
golang.org/x/net v0.33.0 // indirect
|
||||||
|
resty.dev/v3 v3.0.0-beta.3 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
github.com/Workiva/go-datastructures v1.1.5 h1:5YfhQ4ry7bZc2Mc7R0YZyYwpf5c6t1cEFvdAhd6Mkf4=
|
||||||
|
github.com/Workiva/go-datastructures v1.1.5/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5BnDuE2Ya2MMGhzP6A=
|
||||||
|
github.com/Xevion/go-ha v0.7.0 h1:jf+ZVSDaw0xjY0TcCA/TodWmAehtm47hDQI5z8XJMQE=
|
||||||
|
github.com/Xevion/go-ha v0.7.0/go.mod h1:TN+40o0znxEdvR7GQgm5YWMiCEJvsoFbnro2oW38RVU=
|
||||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||||
@@ -44,6 +48,7 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh
|
|||||||
github.com/nathan-osman/go-sunrise v1.1.0 h1:ZqZmtmtzs8Os/DGQYi0YMHpuUqR/iRoJK+wDO0wTCw8=
|
github.com/nathan-osman/go-sunrise v1.1.0 h1:ZqZmtmtzs8Os/DGQYi0YMHpuUqR/iRoJK+wDO0wTCw8=
|
||||||
github.com/nathan-osman/go-sunrise v1.1.0/go.mod h1:RcWqhT+5ShCZDev79GuWLayetpJp78RSjSWxiDowmlM=
|
github.com/nathan-osman/go-sunrise v1.1.0/go.mod h1:RcWqhT+5ShCZDev79GuWLayetpJp78RSjSWxiDowmlM=
|
||||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||||
|
github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
|
||||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
@@ -66,28 +71,48 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS
|
|||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
|
github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg=
|
||||||
|
github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q=
|
||||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||||
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
|
golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
|
||||||
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
|
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
|
||||||
|
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
@@ -96,5 +121,5 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
github.com/Xevion/gome-assistant v0.2.0 h1:Clo5DrziTdsYydVUTQfroeBVmToMnNHoObr+k6HhbMY=
|
resty.dev/v3 v3.0.0-beta.3 h1:3kEwzEgCnnS6Ob4Emlk94t+I/gClyoah7SnNi67lt+E=
|
||||||
github.com/Xevion/gome-assistant v0.2.0/go.mod h1:jsZUtnxANCP0zB2B7iyy4j7sZohMGop8g+5EB2MER3o=
|
resty.dev/v3 v3.0.0-beta.3/go.mod h1:OgkqiPvTDtOuV4MGZuUDhwOpkY8enjOsjjMzeOHefy4=
|
||||||
|
|||||||
@@ -4,14 +4,10 @@ import (
|
|||||||
"github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type AdaptiveLighting struct {
|
type AdaptiveLighting struct {
|
||||||
conn *connect.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
// Set manual control for an adaptive lighting entity.
|
// Set manual control for an adaptive lighting entity.
|
||||||
func (al AdaptiveLighting) SetManualControl(entityId string, enabled bool) error {
|
func (al AdaptiveLighting) SetManualControl(entityId string, enabled bool) error {
|
||||||
req := NewBaseServiceRequest("")
|
req := NewBaseServiceRequest("")
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ws "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type AlarmControlPanel struct {
|
type AlarmControlPanel struct {
|
||||||
conn *ws.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
// Send the alarm the command for arm away.
|
// Send the alarm the command for arm away.
|
||||||
// Takes an entityId and an optional
|
// Takes an entityId and an optional
|
||||||
// map that is translated into service_data.
|
// map that is translated into service_data.
|
||||||
|
|||||||
@@ -5,14 +5,10 @@ import (
|
|||||||
"github.com/Xevion/go-ha/types"
|
"github.com/Xevion/go-ha/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type Climate struct {
|
type Climate struct {
|
||||||
conn *connect.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
func (c Climate) SetFanMode(entityId string, fanMode string) error {
|
func (c Climate) SetFanMode(entityId string, fanMode string) error {
|
||||||
req := NewBaseServiceRequest(entityId)
|
req := NewBaseServiceRequest(entityId)
|
||||||
req.Domain = "climate"
|
req.Domain = "climate"
|
||||||
|
|||||||
@@ -4,14 +4,10 @@ import (
|
|||||||
"github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type Cover struct {
|
type Cover struct {
|
||||||
conn *connect.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
// Close all or specified cover. Takes an entityId.
|
// Close all or specified cover. Takes an entityId.
|
||||||
func (c Cover) Close(entityId string) error {
|
func (c Cover) Close(entityId string) error {
|
||||||
req := NewBaseServiceRequest(entityId)
|
req := NewBaseServiceRequest(entityId)
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ type FireEventRequest struct {
|
|||||||
EventData map[string]any `json:"event_data,omitempty"`
|
EventData map[string]any `json:"event_data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
// Fire an event. Takes an event type and an optional map that is sent
|
// Fire an event. Takes an event type and an optional map that is sent
|
||||||
// as `event_data`.
|
// as `event_data`.
|
||||||
func (e Event) Fire(eventType string, eventData ...map[string]any) error {
|
func (e Event) Fire(eventType string, eventData ...map[string]any) error {
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ws "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type InputBoolean struct {
|
type InputBoolean struct {
|
||||||
conn *ws.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
func (ib InputBoolean) TurnOn(entityId string) error {
|
func (ib InputBoolean) TurnOn(entityId string) error {
|
||||||
req := NewBaseServiceRequest(entityId)
|
req := NewBaseServiceRequest(entityId)
|
||||||
req.Domain = "input_boolean"
|
req.Domain = "input_boolean"
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ws "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type InputButton struct {
|
type InputButton struct {
|
||||||
conn *ws.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
func (ib InputButton) Press(entityId string) error {
|
func (ib InputButton) Press(entityId string) error {
|
||||||
req := NewBaseServiceRequest(entityId)
|
req := NewBaseServiceRequest(entityId)
|
||||||
req.Domain = "input_button"
|
req.Domain = "input_button"
|
||||||
|
|||||||
@@ -4,17 +4,13 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
ws "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type InputDatetime struct {
|
type InputDatetime struct {
|
||||||
conn *ws.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
func (ib InputDatetime) Set(entityId string, value time.Time) error {
|
func (ib InputDatetime) Set(entityId string, value time.Time) error {
|
||||||
req := NewBaseServiceRequest(entityId)
|
req := NewBaseServiceRequest(entityId)
|
||||||
req.Domain = "input_datetime"
|
req.Domain = "input_datetime"
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ws "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type InputNumber struct {
|
type InputNumber struct {
|
||||||
conn *ws.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
func (ib InputNumber) Set(entityId string, value float32) error {
|
func (ib InputNumber) Set(entityId string, value float32) error {
|
||||||
req := NewBaseServiceRequest(entityId)
|
req := NewBaseServiceRequest(entityId)
|
||||||
req.Domain = "input_number"
|
req.Domain = "input_number"
|
||||||
|
|||||||
@@ -4,14 +4,10 @@ import (
|
|||||||
"github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type InputText struct {
|
type InputText struct {
|
||||||
conn *connect.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
func (ib InputText) Set(entityId string, value string) error {
|
func (ib InputText) Set(entityId string, value string) error {
|
||||||
req := NewBaseServiceRequest(entityId)
|
req := NewBaseServiceRequest(entityId)
|
||||||
req.Domain = "input_text"
|
req.Domain = "input_text"
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ws "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type Light struct {
|
type Light struct {
|
||||||
conn *ws.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
// TurnOn a light entity. Takes an entityId and an optional
|
// TurnOn a light entity. Takes an entityId and an optional
|
||||||
// map that is translated into service_data.
|
// map that is translated into service_data.
|
||||||
func (l Light) TurnOn(entityId string, serviceData ...map[string]any) error {
|
func (l Light) TurnOn(entityId string, serviceData ...map[string]any) error {
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ws "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type Lock struct {
|
type Lock struct {
|
||||||
conn *ws.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
// Lock a lock entity. Takes an entityId and an optional
|
// Lock a lock entity. Takes an entityId and an optional
|
||||||
// map that is translated into service_data.
|
// map that is translated into service_data.
|
||||||
func (l Lock) Lock(entityId string, serviceData ...map[string]any) error {
|
func (l Lock) Lock(entityId string, serviceData ...map[string]any) error {
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ws "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type MediaPlayer struct {
|
type MediaPlayer struct {
|
||||||
conn *ws.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
// Send the media player the command to clear players playlist.
|
// Send the media player the command to clear players playlist.
|
||||||
// Takes an entityId.
|
// Takes an entityId.
|
||||||
func (mp MediaPlayer) ClearPlaylist(entityId string) error {
|
func (mp MediaPlayer) ClearPlaylist(entityId string) error {
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ws "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
"github.com/Xevion/go-ha/types"
|
"github.com/Xevion/go-ha/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Notify struct {
|
type Notify struct {
|
||||||
conn *ws.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify sends a notification. Takes a types.NotifyRequest.
|
// Notify sends a notification. Takes a types.NotifyRequest.
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ws "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Number struct {
|
type Number struct {
|
||||||
conn *ws.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ib Number) SetValue(entityId string, value float32) error {
|
func (ib Number) SetValue(entityId string, value float32) error {
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ws "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type Scene struct {
|
type Scene struct {
|
||||||
conn *ws.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
// Apply a scene. Takes map that is translated into service_data.
|
// Apply a scene. Takes map that is translated into service_data.
|
||||||
func (s Scene) Apply(serviceData ...map[string]any) error {
|
func (s Scene) Apply(serviceData ...map[string]any) error {
|
||||||
req := NewBaseServiceRequest("")
|
req := NewBaseServiceRequest("")
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ws "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type Script struct {
|
type Script struct {
|
||||||
conn *ws.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
// Reload a script that was created in the HA UI.
|
// Reload a script that was created in the HA UI.
|
||||||
func (s Script) Reload(entityId string) error {
|
func (s Script) Reload(entityId string) error {
|
||||||
req := NewBaseServiceRequest(entityId)
|
req := NewBaseServiceRequest(entityId)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package services
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/Xevion/go-ha/internal"
|
"github.com/Xevion/go-ha/internal"
|
||||||
ws "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
func BuildService[
|
func BuildService[
|
||||||
@@ -29,7 +29,7 @@ func BuildService[
|
|||||||
Timer |
|
Timer |
|
||||||
Vacuum |
|
Vacuum |
|
||||||
ZWaveJS,
|
ZWaveJS,
|
||||||
](conn *ws.HAConnection) *T {
|
](conn *connect.HAConnection) *T {
|
||||||
return &T{conn: conn}
|
return &T{conn: conn}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ws "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type Switch struct {
|
type Switch struct {
|
||||||
conn *ws.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
func (s Switch) TurnOn(entityId string) error {
|
func (s Switch) TurnOn(entityId string) error {
|
||||||
req := NewBaseServiceRequest(entityId)
|
req := NewBaseServiceRequest(entityId)
|
||||||
req.Domain = "switch"
|
req.Domain = "switch"
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ws "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type Timer struct {
|
type Timer struct {
|
||||||
conn *ws.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
// See https://www.home-assistant.io/integrations/timer/#action-timerstart
|
// See https://www.home-assistant.io/integrations/timer/#action-timerstart
|
||||||
func (t Timer) Start(entityId string, duration string) error {
|
func (t Timer) Start(entityId string, duration string) error {
|
||||||
req := NewBaseServiceRequest(entityId)
|
req := NewBaseServiceRequest(entityId)
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
connect "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type TTS struct {
|
type TTS struct {
|
||||||
conn *connect.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
// Remove all text-to-speech cache files and RAM cache.
|
// Remove all text-to-speech cache files and RAM cache.
|
||||||
func (tts TTS) ClearCache() error {
|
func (tts TTS) ClearCache() error {
|
||||||
req := NewBaseServiceRequest("")
|
req := NewBaseServiceRequest("")
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ws "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type Vacuum struct {
|
type Vacuum struct {
|
||||||
conn *ws.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
// Tell the vacuum cleaner to do a spot clean-up.
|
// Tell the vacuum cleaner to do a spot clean-up.
|
||||||
// Takes an entityId.
|
// Takes an entityId.
|
||||||
func (v Vacuum) CleanSpot(entityId string) error {
|
func (v Vacuum) CleanSpot(entityId string) error {
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ws "github.com/Xevion/go-ha/internal/connect"
|
"github.com/Xevion/go-ha/internal/connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Structs */
|
|
||||||
|
|
||||||
type ZWaveJS struct {
|
type ZWaveJS struct {
|
||||||
conn *ws.HAConnection
|
conn *connect.HAConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
|
||||||
|
|
||||||
// ZWaveJS bulk_set_partial_config_parameters service.
|
// ZWaveJS bulk_set_partial_config_parameters service.
|
||||||
func (zw ZWaveJS) BulkSetPartialConfigParam(entityId string, parameter int, value any) error {
|
func (zw ZWaveJS) BulkSetPartialConfigParam(entityId string, parameter int, value any) error {
|
||||||
req := NewBaseServiceRequest(entityId)
|
req := NewBaseServiceRequest(entityId)
|
||||||
|
|||||||
Reference in New Issue
Block a user