diff --git a/README.md b/README.md index 2450c47..b5a7328 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,18 @@ -# Gome-Assistant +# go-ha Write strongly typed [Home Assistant](https://www.home-assistant.io/) automations in Go! -## Disclaimer - -Gome-Assistant is a new library, and I'm opening it up early to get some user feedback on the API and help shape the direction. I plan for it to grow to cover all Home Assistant use cases, services, and event types. So it's possible that breaking changes will happen before v1.0.0! - -## Quick Start - -### Installation - -``` -go get github.com/Xevion/gome-assistant +```bash +go get github.com/Xevion/go-ha ``` -### Generate Entity Constants +or in `go.mod`: + +```go +require github.com/Xevion/go-ha +``` + +## Generate Entity Constants You can generate type-safe constants for all your Home Assistant entities using `go generate`. This makes it easier to reference entities in your code. @@ -37,7 +35,7 @@ exclude_domains: ["device_tracker", "person"] 2. Add a `//go:generate` comment in your project: ```go -//go:generate go run github.com/Xevion/gome-assistant/cmd/generate +//go:generate go run github.com/Xevion/go-ha/cmd/generate ``` Optionally use the `-config` flag to customize the file path of the config file. @@ -72,11 +70,11 @@ Check out [`example/example.go`](./example/example.go) for an example of the 3 t ### Run your code -Keeping with the simplicity that Go is famous for, you don't need a specific environment or docker container to run Gome-Assistant. You just write and run your code like any other Go binary. So once you build your code, you can run it however you like — using `screen` or `tmux`, a cron job, a linux service, or wrap it up in a docker container if you like! +Keeping with the simplicity that Go is famous for, you don't need a specific environment or docker container to run go-ha. You just write and run your code like any other Go binary. So once you build your code, you can run it however you like — using `screen` or `tmux`, a cron job, a linux service, or wrap it up in a docker container if you like! -> _❗ No promises, but I may provide a Docker image with file watching to automatically restart gome-assistant, to make it easier to use gome-assistant on a fully managed Home Assistant installation._ +> _❗ No promises, but I may provide a Docker image with file watching to automatically restart go-ha, to make it easier to use go-ha on a fully managed Home Assistant installation._ -## gome-assistant Concepts +## go-ha Concepts ### Overview @@ -87,13 +85,13 @@ The general flow is 3. Start app ```go -import ga "github.com/Xevion/gome-assistant" +import ga "github.com/Xevion/go-ha" // replace with IP and port of your Home Assistant installation app, err := ga.NewApp(ga.NewAppRequest{ - URL: "http://192.168.1.123:8123", - HAAuthToken: os.Getenv("HA_AUTH_TOKEN"), - HomeZoneEntityId: "zone.home", + URL: "http://192.168.1.123:8123", + HAAuthToken: os.Getenv("HA_AUTH_TOKEN"), + HomeZoneEntityId: "zone.home", }) // create automations here (see next sections) @@ -107,7 +105,7 @@ app.RegisterIntervals(...) app.Start() ``` -A full reference is available on [pkg.go.dev](https://pkg.go.dev/github.com/Xevion/gome-assistant), but all you need to know to get started are the four types of automations in gome-assistant. +A full reference is available on [pkg.go.dev](https://pkg.go.dev/github.com/Xevion/go-ha), but all you need to know to get started are the four types of automations in go-ha. - [Daily Schedules](#daily-schedule) - [Entity Listeners](#entity-listener) @@ -226,7 +224,7 @@ func myCallback(service *ga.Service, state ga.State, data ga.EventData) { } ``` -> 💡 Check `eventTypes.go` for pre-defined event types, or create your own struct type for custom events and contribute them back to gome-assistant with a PR. +> 💡 Check `eventTypes.go` for pre-defined event types, or create your own struct type for custom events and contribute them back to go-ha with a PR. ### Interval diff --git a/app.go b/app.go index 9ee65eb..23d56d2 100644 --- a/app.go +++ b/app.go @@ -14,9 +14,9 @@ import ( sunriseLib "github.com/nathan-osman/go-sunrise" "github.com/Workiva/go-datastructures/queue" - internal "github.com/Xevion/gome-assistant/internal" - "github.com/Xevion/gome-assistant/internal/parse" - ws "github.com/Xevion/gome-assistant/internal/websocket" + internal "github.com/Xevion/go-ha/internal" + "github.com/Xevion/go-ha/internal/parse" + ws "github.com/Xevion/go-ha/internal/websocket" ) var ErrInvalidArgs = errors.New("invalid arguments provided") diff --git a/checkers.go b/checkers.go index b372c5f..2736416 100644 --- a/checkers.go +++ b/checkers.go @@ -3,8 +3,8 @@ package gomeassistant import ( "time" - "github.com/Xevion/gome-assistant/internal" - "github.com/Xevion/gome-assistant/internal/parse" + "github.com/Xevion/go-ha/internal" + "github.com/Xevion/go-ha/internal/parse" "github.com/golang-module/carbon" ) diff --git a/checkers_test.go b/checkers_test.go index efd4249..ae4c1d9 100644 --- a/checkers_test.go +++ b/checkers_test.go @@ -4,7 +4,7 @@ import ( "errors" "testing" - "github.com/Xevion/gome-assistant/internal" + "github.com/Xevion/go-ha/internal" "github.com/stretchr/testify/assert" ) diff --git a/cmd/generate/main.go b/cmd/generate/main.go index 8d925d9..e21124f 100644 --- a/cmd/generate/main.go +++ b/cmd/generate/main.go @@ -9,7 +9,7 @@ import ( "strings" "text/template" - ga "github.com/Xevion/gome-assistant" + ga "github.com/Xevion/go-ha" "gopkg.in/yaml.v3" ) diff --git a/entity_listener.go b/entity_listener.go index 13c8a55..a9f1fed 100644 --- a/entity_listener.go +++ b/entity_listener.go @@ -7,8 +7,8 @@ import ( "github.com/golang-module/carbon" - "github.com/Xevion/gome-assistant/internal" - "github.com/Xevion/gome-assistant/internal/parse" + "github.com/Xevion/go-ha/internal" + "github.com/Xevion/go-ha/internal/parse" ) type EntityListener struct { diff --git a/event_listener.go b/event_listener.go index 8d2201f..d86e832 100644 --- a/event_listener.go +++ b/event_listener.go @@ -7,9 +7,9 @@ import ( "github.com/golang-module/carbon" - "github.com/Xevion/gome-assistant/internal" - "github.com/Xevion/gome-assistant/internal/parse" - ws "github.com/Xevion/gome-assistant/internal/websocket" + "github.com/Xevion/go-ha/internal" + "github.com/Xevion/go-ha/internal/parse" + ws "github.com/Xevion/go-ha/internal/websocket" ) type EventListener struct { diff --git a/example/example.go b/example/example.go index c785894..48a78fb 100644 --- a/example/example.go +++ b/example/example.go @@ -8,10 +8,10 @@ import ( // "example/entities" // Optional import generated entities - ga "github.com/Xevion/gome-assistant" + ga "github.com/Xevion/go-ha" ) -//go:generate go run github.com/Xevion/gome-assistant/cmd/generate +//go:generate go run github.com/Xevion/go-ha/cmd/generate func main() { app, err := ga.NewApp(ga.NewAppRequest{ diff --git a/example/example_live_test.go b/example/example_live_test.go index e47d70c..eb24097 100644 --- a/example/example_live_test.go +++ b/example/example_live_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/suite" "gopkg.in/yaml.v3" - ga "github.com/Xevion/gome-assistant" + ga "github.com/Xevion/go-ha" ) type ( diff --git a/go.mod b/go.mod index 5325562..07b328f 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/Xevion/gome-assistant +module github.com/Xevion/go-ha go 1.21 diff --git a/internal/services/adaptive_lighting.go b/internal/services/adaptive_lighting.go index a913e01..a55acf1 100644 --- a/internal/services/adaptive_lighting.go +++ b/internal/services/adaptive_lighting.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) /* Structs */ diff --git a/internal/services/alarm_control_panel.go b/internal/services/alarm_control_panel.go index 2445738..cfae9b9 100644 --- a/internal/services/alarm_control_panel.go +++ b/internal/services/alarm_control_panel.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) /* Structs */ diff --git a/internal/services/climate.go b/internal/services/climate.go index be68c74..221f5ed 100644 --- a/internal/services/climate.go +++ b/internal/services/climate.go @@ -1,8 +1,8 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" - "github.com/Xevion/gome-assistant/types" + ws "github.com/Xevion/go-ha/internal/websocket" + "github.com/Xevion/go-ha/types" ) /* Structs */ diff --git a/internal/services/cover.go b/internal/services/cover.go index 6c1962b..a19ca81 100644 --- a/internal/services/cover.go +++ b/internal/services/cover.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) /* Structs */ diff --git a/internal/services/event.go b/internal/services/event.go index 5007c84..fa892e6 100644 --- a/internal/services/event.go +++ b/internal/services/event.go @@ -1,8 +1,8 @@ package services import ( - "github.com/Xevion/gome-assistant/internal" - ws "github.com/Xevion/gome-assistant/internal/websocket" + "github.com/Xevion/go-ha/internal" + ws "github.com/Xevion/go-ha/internal/websocket" ) type Event struct { diff --git a/internal/services/home_assistant.go b/internal/services/home_assistant.go index 36bc5e6..5467ba1 100644 --- a/internal/services/home_assistant.go +++ b/internal/services/home_assistant.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) type HomeAssistant struct { diff --git a/internal/services/input_boolean.go b/internal/services/input_boolean.go index ee45511..385b350 100644 --- a/internal/services/input_boolean.go +++ b/internal/services/input_boolean.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) /* Structs */ diff --git a/internal/services/input_button.go b/internal/services/input_button.go index 03ab378..8aa999b 100644 --- a/internal/services/input_button.go +++ b/internal/services/input_button.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) /* Structs */ diff --git a/internal/services/input_datetime.go b/internal/services/input_datetime.go index 7c01e36..45b22c6 100644 --- a/internal/services/input_datetime.go +++ b/internal/services/input_datetime.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) /* Structs */ diff --git a/internal/services/input_number.go b/internal/services/input_number.go index 19b1e03..72224d2 100644 --- a/internal/services/input_number.go +++ b/internal/services/input_number.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) /* Structs */ diff --git a/internal/services/input_text.go b/internal/services/input_text.go index 7eda7ad..82bf01d 100644 --- a/internal/services/input_text.go +++ b/internal/services/input_text.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) /* Structs */ diff --git a/internal/services/light.go b/internal/services/light.go index 87b850f..923f4ca 100644 --- a/internal/services/light.go +++ b/internal/services/light.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) /* Structs */ diff --git a/internal/services/lock.go b/internal/services/lock.go index c5a1add..bc51116 100644 --- a/internal/services/lock.go +++ b/internal/services/lock.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) /* Structs */ diff --git a/internal/services/media_player.go b/internal/services/media_player.go index 48a067a..018cc16 100644 --- a/internal/services/media_player.go +++ b/internal/services/media_player.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) /* Structs */ diff --git a/internal/services/notify.go b/internal/services/notify.go index 8b8f72d..053a83a 100644 --- a/internal/services/notify.go +++ b/internal/services/notify.go @@ -1,8 +1,8 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" - "github.com/Xevion/gome-assistant/types" + ws "github.com/Xevion/go-ha/internal/websocket" + "github.com/Xevion/go-ha/types" ) type Notify struct { diff --git a/internal/services/number.go b/internal/services/number.go index 5e2ae92..c617372 100644 --- a/internal/services/number.go +++ b/internal/services/number.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) type Number struct { diff --git a/internal/services/scene.go b/internal/services/scene.go index 32722c5..ec2923a 100644 --- a/internal/services/scene.go +++ b/internal/services/scene.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) /* Structs */ diff --git a/internal/services/script.go b/internal/services/script.go index bebbc0c..f0903a5 100644 --- a/internal/services/script.go +++ b/internal/services/script.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) /* Structs */ diff --git a/internal/services/services.go b/internal/services/services.go index 5486b53..f6539bd 100644 --- a/internal/services/services.go +++ b/internal/services/services.go @@ -1,8 +1,8 @@ package services import ( - "github.com/Xevion/gome-assistant/internal" - ws "github.com/Xevion/gome-assistant/internal/websocket" + "github.com/Xevion/go-ha/internal" + ws "github.com/Xevion/go-ha/internal/websocket" ) func BuildService[ diff --git a/internal/services/switch.go b/internal/services/switch.go index 3443ada..84af3b2 100644 --- a/internal/services/switch.go +++ b/internal/services/switch.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) /* Structs */ diff --git a/internal/services/timer.go b/internal/services/timer.go index c5bcf8a..6dd9c83 100644 --- a/internal/services/timer.go +++ b/internal/services/timer.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) /* Structs */ diff --git a/internal/services/tts.go b/internal/services/tts.go index 42ccb11..a701394 100644 --- a/internal/services/tts.go +++ b/internal/services/tts.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) /* Structs */ diff --git a/internal/services/vacuum.go b/internal/services/vacuum.go index 3bdac9f..cb3f448 100644 --- a/internal/services/vacuum.go +++ b/internal/services/vacuum.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) /* Structs */ diff --git a/internal/services/zwavejs.go b/internal/services/zwavejs.go index ca20f3c..0571f7b 100644 --- a/internal/services/zwavejs.go +++ b/internal/services/zwavejs.go @@ -1,7 +1,7 @@ package services import ( - ws "github.com/Xevion/gome-assistant/internal/websocket" + ws "github.com/Xevion/go-ha/internal/websocket" ) /* Structs */ diff --git a/internal/websocket/websocket.go b/internal/websocket/websocket.go index 4571c5d..835796b 100644 --- a/internal/websocket/websocket.go +++ b/internal/websocket/websocket.go @@ -16,7 +16,7 @@ import ( "github.com/gorilla/websocket" - "github.com/Xevion/gome-assistant/internal" + "github.com/Xevion/go-ha/internal" ) var ErrInvalidToken = errors.New("invalid authentication token") diff --git a/interval.go b/interval.go index e6a9caa..311eda3 100644 --- a/interval.go +++ b/interval.go @@ -5,8 +5,8 @@ import ( "log/slog" "time" - "github.com/Xevion/gome-assistant/internal" - "github.com/Xevion/gome-assistant/internal/parse" + "github.com/Xevion/go-ha/internal" + "github.com/Xevion/go-ha/internal/parse" ) type IntervalCallback func(*Service, State) diff --git a/schedule.go b/schedule.go index 24a990d..602a1cd 100644 --- a/schedule.go +++ b/schedule.go @@ -5,8 +5,8 @@ import ( "log/slog" "time" - "github.com/Xevion/gome-assistant/internal" - "github.com/Xevion/gome-assistant/internal/parse" + "github.com/Xevion/go-ha/internal" + "github.com/Xevion/go-ha/internal/parse" "github.com/golang-module/carbon" ) diff --git a/service.go b/service.go index a5c7c48..bd46ec6 100644 --- a/service.go +++ b/service.go @@ -1,8 +1,8 @@ package gomeassistant import ( - "github.com/Xevion/gome-assistant/internal/services" - ws "github.com/Xevion/gome-assistant/internal/websocket" + "github.com/Xevion/go-ha/internal/services" + ws "github.com/Xevion/go-ha/internal/websocket" ) type Service struct { diff --git a/state.go b/state.go index 5c00d9d..183e8c7 100644 --- a/state.go +++ b/state.go @@ -8,7 +8,7 @@ import ( "github.com/golang-module/carbon" - internal "github.com/Xevion/gome-assistant/internal" + internal "github.com/Xevion/go-ha/internal" ) type State interface {