-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(agent,device): merge code into agent to simplify logic
- Loading branch information
Showing
10 changed files
with
108 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2023 Joshua Rich <[email protected]> | ||
// | ||
// This software is released under the MIT License. | ||
// https://opensource.org/licenses/MIT | ||
|
||
package agent | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/joshuar/go-hass-agent/internal/agent/ui" | ||
) | ||
|
||
// AgentConfig represents the methods that the agent uses to interact with | ||
// its config. It is effectively a CRUD interface to wherever the configuration | ||
// is stored. | ||
// | ||
//go:generate moq -out mockAgentConfig_test.go . AgentConfig | ||
type AgentConfig interface { | ||
Get(string, interface{}) error | ||
Set(string, interface{}) error | ||
Delete(string) error | ||
StoragePath(string) (string, error) | ||
} | ||
|
||
// AgentUI are the methods required for the agent to display its windows, tray | ||
// and notifications | ||
// | ||
//go:generate moq -out mockAgentUI_test.go . AgentUI | ||
type AgentUI interface { | ||
DisplayNotification(string, string) | ||
DisplayTrayIcon(context.Context, ui.Agent) | ||
DisplayRegistrationWindow(context.Context, ui.Agent, chan struct{}) | ||
Run() | ||
} | ||
|
||
//go:generate moq -out mockDevice.go . Device | ||
type Device interface { | ||
DeviceName() string | ||
DeviceID() string | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) 2023 Joshua Rich <[email protected]> | ||
// | ||
// This software is released under the MIT License. | ||
// https://opensource.org/licenses/MIT | ||
|
||
package device | ||
|
||
import "context" | ||
|
||
// SensorTracker is the interface through which a device can update its sensors. | ||
type SensorTracker interface { | ||
// UpdateSensors will take any number of sensor updates and pass them on to | ||
// the sensor tracker, which will handle updating its internal database and | ||
// Home Assistant. | ||
UpdateSensors(context.Context, ...interface{}) error | ||
} |