Documentation
¶
Index ¶
- Constants
- type BaseRequest
- type BaseRequestInput
- type Device
- type DeviceInfo
- type DeviceName
- type ExecuteRequest
- type ExecuteRequestCommands
- type ExecuteRequestExecution
- type ExecuteRequestInput
- type ExecuteRequestPayload
- type ExecuteResponse
- type ExecuteResponseCommands
- type ExecuteResponsePayload
- type OtherDeviceID
- type QueryRequest
- type QueryRequestInput
- type QueryRequestPayload
- type QueryRequestPayloadDevice
- type QueryResponse
- type QueryResponsePayload
- type SyncRequest
- type SyncRequestInput
- type SyncResponse
- type SyncResponsePayload
Constants ¶
const ( // SyncIntent https://developers.google.com/assistant/smarthome/reference/intent/sync SyncIntent = "action.devices.SYNC" // QueryIntent https://developers.google.com/assistant/smarthome/reference/intent/query QueryIntent = "action.devices.QUERY" // ExecuteIntent https://developers.google.com/assistant/smarthome/reference/intent/execute ExecuteIntent = "action.devices.EXECUTE" // DisconnectIntent https://developers.google.com/assistant/smarthome/reference/intent/disconnect DisconnectIntent = "action.devices.DISCONNECT" )
const ( // StatusSuccess confirm that the command succeeded. StatusSuccess = "SUCCESS" // StatusPending command is enqueued but expected to succeed. StatusPending = "PENDING" // StatusOffline target device is in offline state or unreachable. StatusOffline = "OFFLINE" // StatusExceptions There is an issue or alert associated with a command. The command could succeed or fail. This status type is typically set when you want to send additional information about another connected device. StatusExceptions = "EXCEPTIONS" // StatusError Target device is unable to perform the command. StatusError = "ERROR" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseRequest ¶
type BaseRequest struct { // ID of the corresponding request. RequestID string `json:"requestId" binding:"required"` Inputs []BaseRequestInput `json:"inputs" binding:"required"` }
BaseRequest is common for all intents
type BaseRequestInput ¶
type BaseRequestInput struct {
Intent string `json:"intent" binding:"required"`
}
BaseRequestInput ...
type Device ¶
type Device struct { // The ID of the device in the developer's cloud. This must be unique for the user and for the developer, as in cases of sharing we may use this to dedupe multiple views of the same device. It should be immutable for the device; if it changes, the Assistant will treat it as a new device. ID string `json:"id" binding:"required"` // The hardware type of device. Type string `json:"type" binding:"required"` // List of traits this device has. This defines the commands, attributes, and states that the device supports. Traits []string `json:"traits" binding:"required"` // Names of this device. Name DeviceName `json:"name" binding:"required"` // Indicates whether this device will have its states updated by the Real Time Feed. (true to use the Real Time Feed for reporting state, and false to use the polling model.) WillReportState bool `json:"willReportState" binding:"required"` // Provides the current room of the device in the user's home to simplify setup. RoomHint string `json:"roomHint,omitempty"` // Contains fields describing the device for use in one-off logic if needed (e.g. 'broken firmware version X of light Y requires adjusting color', or 'security flaw requires notifying all users of firmware Z'). DeviceInfo DeviceInfo `json:"deviceInfo"` // Aligned with per-trait attributes described in each trait schema reference. Attributes map[string]interface{} `json:"attributes,omitempty"` // This is a special object defined by the developer which will be attached to future QUERY and EXECUTE requests. Developers can use this object to store additional information about the device to improve performance or routing within their cloud, such as the global region of the device. Data in this object has a few constraints: No Personally Identifiable Information. Data should change rarely, akin to other attributes -- so this should not contain real-time state. The total object is limited to 512 bytes per device. CustomData map[string]interface{} `json:"customData,omitempty"` // List of alternate IDs used to identify a cloud synced device for local execution. OtherDeviceIDs []OtherDeviceID `json:"otherDeviceIds,omitempty"` }
Device metadata.
type DeviceInfo ¶
type DeviceInfo struct { // Especially useful when the developer is a hub for other devices. Google may provide a standard list of manufacturers here so that e.g. TP-Link and Smartthings both describe 'osram' the same way. Manufacturer string `json:"manufacturer,omitempty" bson:"manufacturer,omitempty"` // The model or SKU identifier of the particular device. Model string `json:"model,omitempty" bson:"model,omitempty"` // Specific version number attached to the hardware if available. HwVersion string `json:"hwVersion,omitempty" bson:"hwVersion,omitempty"` // Specific version number attached to the software/firmware, if available. SwVersion string `json:"swVersion,omitempty" bson:"swVersion,omitempty"` }
DeviceInfo contains fields describing the device for use in one-off logic if needed (e.g. 'broken firmware version X of light Y requires adjusting color', or 'security flaw requires notifying all users of firmware Z').
type DeviceName ¶
type DeviceName struct { // Primary name of the device, generally provided by the user. This is also the name the Assistant will prefer to describe the device in responses. Name string `json:"name" binding:"required" bson:"name"` // List of names provided by the developer rather than the user, often manufacturer names, SKUs, etc. DefaultNames []string `json:"defaultNames,omitempty" bson:"defaultNames,omitempty"` // Additional names provided by the user for the device. Nicknames []string `json:"nicknames,omitempty" bson:"nicknames,omitempty"` }
DeviceName names of this device.
type ExecuteRequest ¶
type ExecuteRequest struct { // ID of the request. RequestID string `json:"requestId" binding:"required"` //List of inputs matching the intent request. Inputs []ExecuteRequestInput `json:"inputs" binding:"required"` }
ExecuteRequest ...
type ExecuteRequestCommands ¶
type ExecuteRequestCommands struct { // List of target devices. Devices []QueryRequestPayloadDevice `json:"devices" binding:"required"` // List of commands to execute on target devices. Execution []ExecuteRequestExecution `json:"execution" binding:"required"` }
ExecuteRequestCommands ...
type ExecuteRequestExecution ¶
type ExecuteRequestExecution struct { // The command to execute, usually with accompanying parameters. Command string `json:"command" binding:"required"` // Aligned with the parameters for each command. Params map[string]interface{} `json:"params,omitempty"` }
ExecuteRequestExecution ...
type ExecuteRequestInput ¶
type ExecuteRequestInput struct { // Intent request type. // // (Constant value: "action.devices.EXECUTE") Intent string `json:"intent" binding:"required,eq=action.devices.EXECUTE"` // EXECUTE request payload. Payload ExecuteRequestPayload `json:"payload" binding:"required"` }
ExecuteRequestInput type and payload associated with the intent request.
type ExecuteRequestPayload ¶
type ExecuteRequestPayload struct { // List of device target and command pairs. Commands []ExecuteRequestCommands `json:"commands" binding:"required"` }
ExecuteRequestPayload ...
type ExecuteResponse ¶
type ExecuteResponse struct { // ID of the corresponding request. RequestID string `json:"requestId" binding:"required"` // Intent response payload. Payload ExecuteResponsePayload `json:"payload" binding:"required"` }
ExecuteResponse ...
type ExecuteResponseCommands ¶
type ExecuteResponseCommands struct { // List of device IDs corresponding to this status. IDs []string `json:"ids" binding:"required"` // Result of the execute operation, must be one of Status... Status string `json:"status" binding:"required,oneof=SUCCESS PENDING OFFLINE EXCEPTIONS ERROR"` // Aligned with per-trait states described in each trait schema reference. These are the states after execution, if available. States map[string]interface{} `json:"debugString,omitempty"` // Expanding ERROR state if needed from the preset error codes, which will map to the errors presented to users. ErrorCode string `json:"errorCode,omitempty"` }
ExecuteResponseCommands ...
type ExecuteResponsePayload ¶
type ExecuteResponsePayload struct { // An error code for the entire transaction for auth failures and developer system unavailability. For individual device errors, use the errorCode within the device object. ErrorCode string `json:"errorCode,omitempty"` // Detailed error which will never be presented to users but may be logged or used during development. DebugString string `json:"debugString,omitempty"` // Each object contains one or more devices with response details. N.B. These may not be grouped the same way as in the request. For example, the request might turn 7 lights on, with 3 lights succeeding and 4 failing, thus with two groups in the response. Commands []ExecuteResponseCommands `json:"commands" binding:"required"` }
ExecuteResponsePayload ...
type OtherDeviceID ¶
type OtherDeviceID struct { // The agent's ID. Generally, this is the project ID in the Actions console. AgentID string `json:"agentId,omitempty" bson:"agentId,omitempty"` // Device ID defined by the agent. The device ID must be unique. DeviceID string `json:"deviceId" bson:"deviceId"` }
OtherDeviceID Alternate device ID.
type QueryRequest ¶
type QueryRequest struct { // ID of the request. RequestID string `json:"requestId" binding:"required"` // List of inputs matching the intent request. Inputs []QueryRequestInput `json:"inputs" binding:"required"` }
QueryRequest ...
type QueryRequestInput ¶
type QueryRequestInput struct { // Intent request type // // (Constant value: "action.devices.QUERY") Intent string `json:"intent" binding:"required,eq=action.devices.QUERY"` // QUERY request payload. Payload QueryRequestPayload `json:"payload" binding:"required"` }
QueryRequestInput type and payload associated with the intent request.
type QueryRequestPayload ¶
type QueryRequestPayload struct { // List of target devices. Devices []QueryRequestPayloadDevice `json:"devices" binding:"required"` }
QueryRequestPayload ...
type QueryRequestPayloadDevice ¶
type QueryRequestPayloadDevice struct { // Device ID, as per the ID provided in SYNC. ID string `json:"id" binding:"required"` // If the opaque customData object is provided in SYNC, it's sent here. CustomData map[string]interface{} `json:"customData,omitempty"` }
QueryRequestPayloadDevice device targets to query.
type QueryResponse ¶
type QueryResponse struct { // ID of the corresponding request. RequestID string `json:"requestId" binding:"required"` // Intent response payload. Payload QueryResponsePayload `json:"payload" binding:"required"` }
QueryResponse ...
type QueryResponsePayload ¶
type QueryResponsePayload struct { // An error code for the entire transaction for auth failures and developer system unavailability. For individual device errors use the errorCode within the device object. ErrorCode string `json:"errorCode,omitempty"` // Detailed error which will never be presented to users but may be logged or used during development. DebugString string `json:"debugString,omitempty"` // https://developers.google.com/assistant/smarthome/reference/intent/query#response // // Must contain // // online - Indicates if the device is online (that is, reachable) or not. // // status - Result of the query operation. // // And other strictly related to specific device data Devices map[string]interface{} `json:"devices" binding:"required"` }
QueryResponsePayload ...
type SyncRequest ¶
type SyncRequest struct { // ID of the request. RequestID string `json:"requestId" binding:"required"` // List of inputs matching the intent request. Inputs []SyncRequestInput `json:"inputs" binding:"required"` }
SyncRequest ...
type SyncRequestInput ¶
type SyncRequestInput struct { // Intent request type. // // (Constant value: "action.devices.SYNC") Intent string `json:"intent" binding:"required,eq=action.devices.SYNC"` }
SyncRequestInput ...
type SyncResponse ¶
type SyncResponse struct { // ID of the corresponding request. RequestID string `json:"requestId" binding:"required"` // Intent response payload. Payload SyncResponsePayload `json:"payload" binding:"required"` }
SyncResponse ...
type SyncResponsePayload ¶
type SyncResponsePayload struct { // Reflects the unique (and immutable) user ID on the agent's platform. The string is opaque to Google, so if there's an immutable form vs a mutable form on the agent side, use the immutable form (e.g. an account number rather than email). AgentUserID string `json:"agentUserId" binding:"required"` // List of devices owned by the user. Zero or more devices are returned (zero devices meaning the user has no devices, or has disconnected them all). Devices []Device `json:"devices" binding:"required"` // For systematic errors on SYNC ErrorCode string `json:"errorCode,omitempty"` // Detailed error which will never be presented to users but may be logged or used during development. DebugString string `json:"debugString,omitempty"` }
SyncResponsePayload ...