Documentation ¶
Index ¶
- Constants
- type Color
- type CommandRequest
- type CustomDataRequest
- type Device
- type DeviceRequest
- type DisconnectResponse
- type EmptyResponse
- type ExecuteCommands
- type ExecutePayload
- type ExecuteResponse
- type ExecuteStates
- type ExecuteStatus
- type ExecutionRequest
- type FullfillementRequest
- type Fullfillment
- type InputRequest
- type LocalState
- type MessageHandler
- type ParamsRequest
- type PayloadRequest
- type QueryDevice
- type QueryPayload
- type QueryResponse
- type SyncCustomData
- type SyncDeviceInfo
- type SyncDevices
- type SyncName
- type SyncOtherDeviceIds
- type SyncPayload
- type SyncResponse
Constants ¶
View Source
const ( Success ExecuteStatus = "SUCCESS" // SUCCESS Confirm that the command succeeded. Pending = "PENDING" // PENDING Command is enqueued but expected to succeed. Offline = "OFFLINE" // OFFLINE Target device is in offline state or unreachable. Exceptions = "EXCEPTIONS" // EXCEPTIONS 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. Error = "ERROR" // ERROR Target device is unable to perform the command. )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandRequest ¶
type CommandRequest struct { Devices []DeviceRequest `json:"devices,omitempty"` Execution []ExecutionRequest `json:"execution,omitempty"` }
type CustomDataRequest ¶
type Device ¶
type Device struct { Topic string State LocalState }
type DeviceRequest ¶
type DeviceRequest struct { ID string `json:"id,omitempty"` CustomData *CustomDataRequest `json:"customData,omitempty"` }
type DisconnectResponse ¶
type DisconnectResponse struct { }
type EmptyResponse ¶
type EmptyResponse struct { }
type ExecuteCommands ¶
type ExecuteCommands struct { Ids []string `json:"ids,omitempty"` // Required. List of device IDs corresponding to this status. Status ExecuteStatus `json:"status,omitempty"` // Required. Result of the execute operation. States ExecuteStates `json:"states,omitempty"` // Aligned with per-trait states described in each trait schema reference. These are the states after execution, if available. ErrorCode string `json:"errorCode,omitempty"` // Expanding ERROR state if needed from the preset error codes, which will map to the errors presented to users. }
type ExecutePayload ¶
type ExecutePayload struct { Commands []ExecuteCommands `json:"commands,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. ErrorCode string `json:"errorCode,omitempty"` // 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. DebugString string `json:"debugString,omitempty"` // Detailed error which will never be presented to users but may be logged or used during development. }
type ExecuteResponse ¶
type ExecuteResponse struct { RequestID string `json:"requestId"` // Required. ID of the corresponding request. Payload ExecutePayload `json:"payload"` // Required. Intent response payload. }
type ExecuteStates ¶
type ExecuteStates struct { Online bool `json:"online,omitempty"` // Indicates if the device is online (that is, reachable) or not. // action.devices.traits.OnOff On bool `json:"on,omitempty"` // action.devices.traits.Volume CurrentVolume int `json:"currentVolume,omitempty"` IsMuted bool `json:"isMuted,omitempty"` // action.devices.traits.TransportControl ActivityState string `json:"activityState,omitempty"` // Supported values: INACTIVE, STANDBY, ACTIVE PlaybackState string `json:"playbackState,omitempty"` // Supported values: PAUSED, PLAYING, FAST_FORWARDING, REWINDING, BUFFERING, STOPPED }
type ExecuteStatus ¶
type ExecuteStatus string
type ExecutionRequest ¶
type ExecutionRequest struct { Command string `json:"command,omitempty"` Params ParamsRequest `json:"params,omitempty"` }
type FullfillementRequest ¶
type FullfillementRequest struct { RequestID string `json:"requestId,omitempty"` Inputs []InputRequest `json:"inputs,omitempty"` }
type Fullfillment ¶
type Fullfillment struct {
// contains filtered or unexported fields
}
func NewFullfillment ¶
func NewFullfillment(handler MessageHandler, deviceConfigs map[string]config.DeviceConfig, executionTemplates map[string]string) (*Fullfillment, error)
func (*Fullfillment) Handler ¶
func (f *Fullfillment) Handler(w http.ResponseWriter, r *http.Request)
type InputRequest ¶
type InputRequest struct { Intent string `json:"intent,omitempty"` Payload PayloadRequest `json:"payload,omitempty"` }
type LocalState ¶
type MessageHandler ¶
type ParamsRequest ¶
type PayloadRequest ¶
type PayloadRequest struct { AgentUserID string `json:"agentUserId,omitempty"` Devices []DeviceRequest `json:"devices,omitempty"` Commands []CommandRequest `json:"commands,omitempty"` }
type QueryDevice ¶
type QueryDevice struct { Online bool `json:"online,omitempty"` // Required. Indicates if the device is online (that is, reachable) or not. Status string `json:"status,omitempty"` // Required. Result of the query operation. Supported values: SUCCESS Confirm that the query succeeded. OFFLINE Target device is in offline state or unreachable. EXCEPTIONS There is an issue or alert associated with a query. The query could succeed or fail. This status type is typically set when you want to send additional information about another connected device. ERROR Unable to query the target device. ErrorCode string `json:"errorCode,omitempty"` // Expanding ERROR state if needed from the preset error codes, which will map to the errors presented to users. On bool `json:"on,omitempty"` Brightness int `json:"brightness,omitempty"` Color *Color `json:"color,omitempty"` }
type QueryPayload ¶
type QueryPayload struct { Devices map[string]QueryDevice `json:"devices,omitempty"` // Required. Map of devices. Maps developer device ID to object of state properties. ErrorCode string `json:"errorCode,omitempty"` // 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. DebugString string `json:"debugString,omitempty"` // Detailed error which will never be presented to users but may be logged or used during development. }
type QueryResponse ¶
type QueryResponse struct { RequestID string `json:"requestId,omitempty"` // Required. ID of the corresponding request. Payload QueryPayload `json:"payload,omitempty"` // Required. Intent response payload. }
type SyncCustomData ¶
type SyncDeviceInfo ¶
type SyncDeviceInfo struct { Manufacturer string `json:"manufacturer,omitempty"` // 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. Model string `json:"model,omitempty"` // The model or SKU identifier of the particular device. HwVersion string `json:"hwVersion,omitempty"` // Specific version number attached to the hardware if available. SwVersion string `json:"swVersion,omitempty"` // Specific version number attached to the software/firmware, if available. }
type SyncDevices ¶
type SyncDevices struct { ID string `json:"id"` // Required. 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. Type string `json:"type"` // Required. The hardware type of device. Traits []string `json:"traits"` // Required. List of traits this device has. This defines the commands, attributes, and states that the device supports. Name SyncName `json:"name"` // Required. Names of this device. WillReportState bool `json:"willReportState"` // 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.) RoomHint string `json:"roomHint,omitempty"` // Provides the current room of the device in the user's home to simplify setup. NotificationSupportedByAgent bool `json:"notificationSupportedByAgent,omitempty"` // (Default: false) Indicates whether notifications are enabled for the device. DeviceInfo *SyncDeviceInfo `json:"deviceInfo,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'). OtherDeviceIds []*SyncOtherDeviceIds `json:"otherDeviceIds,omitempty"` // List of alternate IDs used to identify a cloud synced device for local execution. CustomData *SyncCustomData `json:"customData,omitempty"` // Object defined by the developer which will be attached to future QUERY and EXECUTE requests, maximum of 512 bytes per device. Use this object to store additional information about the device your cloud service may need, such as the global region of the device. Data in this object has a few constraints: No sensitive information, including but not limited to Personally Identifiable Information. Attributes *config.SyncAttributes `json:"attributes,omitempty"` // Aligned with per-trait attributes described in each trait schema reference. }
type SyncName ¶
type SyncName struct { DefaultNames []string `json:"defaultNames,omitempty"` // List of names provided by the developer rather than the user, often manufacturer names, SKUs, etc. Name string `json:"name"` // Required. 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. Nicknames []string `json:"nicknames,omitempty"` // Additional names provided by the user for the device. }
type SyncOtherDeviceIds ¶
type SyncPayload ¶
type SyncPayload struct { AgentUserID string `json:"agentUserId"` // Required. 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). Devices []SyncDevices `json:"devices"` // 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). ErrorCode string `json:"errorCode,omitempty"` // For systematic errors on SYNC DebugString string `json:"debugString,omitempty"` // Detailed error which will never be presented to users but may be logged or used during development. }
type SyncResponse ¶
type SyncResponse struct { RequestID string `json:"requestId"` // Required. ID of the corresponding request. Payload SyncPayload `json:"payload"` // Required. Intent response payload. }
Click to show internal directories.
Click to hide internal directories.