Documentation
¶
Index ¶
- Variables
- type API
- type ProviderService
- func (s *ProviderService) Disconnect(ctx context.Context, agentID string) error
- func (s *ProviderService) Execute(ctx context.Context, req *action.ExecuteRequest) (*action.ExecuteResponse, error)
- func (s *ProviderService) Query(ctx context.Context, req *action.QueryRequest) (*action.QueryResponse, error)
- func (s *ProviderService) RegisterProvider(agentID string, provider action.Provider)
- func (s *ProviderService) Sync(ctx context.Context, agentID string) (*action.SyncResponse, error)
- func (s *ProviderService) UnregisterProvider(agentID string)
- type RemoteProvider
- func (m *RemoteProvider) Disconnect(context.Context, string) error
- func (m *RemoteProvider) Execute(ctx context.Context, req *action.ExecuteRequest) (*action.ExecuteResponse, error)
- func (m *RemoteProvider) Query(ctx context.Context, req *action.QueryRequest) (*action.QueryResponse, error)
- func (m *RemoteProvider) Sync(ctx context.Context, _ string) (*action.SyncResponse, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnsupportedCommandResponseReceived is returned if the matched up response isn't a command response type ErrUnsupportedCommandResponseReceived = errors.New("unsupported command response received") // ErrCommandTimeout is returned if the command isn't received in time ErrCommandTimeout = errors.New("command request timed out") // ErrRequestMissing is returned if the targetted request isn't pending ErrRequestMissing = errors.New("request missing") // ErrContextTimeout is returned if the command context times out ErrContextTimeout = errors.New("context timed out") // ErrCommandFailed is returned if we received a proper response but the far end couldn't process it ErrCommandFailed = errors.New("command failed") )
var ( // ErrAgentNotFound is returned if the Google Assistant requested an action for a valid user who is not // registered with the system at the moment. ErrAgentNotFound = errors.New("agent not found") )
var ( // ErrNoAgentRegistered is returned when a message is received on a stream which has not registered an agent. ErrNoAgentRegistered = status.New(codes.InvalidArgument, "no agent registered") )
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API holds the implementation of the Google Home Service gRPC API
func (*API) StateSync ¶
func (a *API) StateSync(stream googlehome.GoogleHomeService_StateSyncServer) error
StateSync contains the bidirectional stream of requests coming in from a connected client.
type ProviderService ¶
type ProviderService struct {
// contains filtered or unexported fields
}
ProviderService satisfies the Google Smart Home Action Provider contract. This is called by the Google Assistant when users trigger requests against the HomeGraph. This maintains a map of the supported agent IDs and their registered handlers. Any request received that does not have a registered agent ID will fail.
func NewProviderService ¶
func NewProviderService(logger *zap.Logger) *ProviderService
NewProviderService creates a new intent-handling ProviderService to register with the Google Assistant handling framework.
func (*ProviderService) Disconnect ¶
func (s *ProviderService) Disconnect(ctx context.Context, agentID string) error
Disconnect processes the Google Assistant request to remove updates from the specified agent ID.
func (*ProviderService) Execute ¶
func (s *ProviderService) Execute(ctx context.Context, req *action.ExecuteRequest) (*action.ExecuteResponse, error)
Execute processes the Google Assistant request to change the state of the specified devices for the specified agent.
func (*ProviderService) Query ¶
func (s *ProviderService) Query(ctx context.Context, req *action.QueryRequest) (*action.QueryResponse, error)
Query processes the Google Assistent request for a state refresh for the specified devices for the specified agent.
func (*ProviderService) RegisterProvider ¶
func (s *ProviderService) RegisterProvider(agentID string, provider action.Provider)
RegisterProvider adds a new agent ID to the set being handled.
func (*ProviderService) Sync ¶
func (s *ProviderService) Sync(ctx context.Context, agentID string) (*action.SyncResponse, error)
Sync processes the Google Assistent request to retrieve the set of devices for the specified agent ID.
func (*ProviderService) UnregisterProvider ¶
func (s *ProviderService) UnregisterProvider(agentID string)
UnregisterProvider removes the registered agent ID from the set of handled providers.
type RemoteProvider ¶
type RemoteProvider struct {
// contains filtered or unexported fields
}
RemoteProvider implements a Google Assistent provider that relays requests over a GoogleHomeService streaming RPC.
func NewRemoteProvider ¶
func NewRemoteProvider(logger *zap.Logger, agentID string, stream googlehome.GoogleHomeService_StateSyncServer) *RemoteProvider
NewRemoteProvider creates a new provider backed by a GoogleHomeService streaming RPC.
func (*RemoteProvider) Disconnect ¶
func (m *RemoteProvider) Disconnect(context.Context, string) error
Disconnect removes this agent ID provider.
func (*RemoteProvider) Execute ¶
func (m *RemoteProvider) Execute(ctx context.Context, req *action.ExecuteRequest) (*action.ExecuteResponse, error)
Execute makes the specified devices change state.
func (*RemoteProvider) Query ¶
func (m *RemoteProvider) Query(ctx context.Context, req *action.QueryRequest) (*action.QueryResponse, error)
Query retrieves the requested device data
func (*RemoteProvider) Sync ¶
func (m *RemoteProvider) Sync(ctx context.Context, _ string) (*action.SyncResponse, error)
Sync returns the set of known devices.