Documentation
¶
Index ¶
- type Aligenie
- type Application
- type Header
- type Home
- type Request
- type RequestPayload
- type Response
- type ResponsePayload
- type ResponsePayloadDevice
- func (T *ResponsePayloadDevice) Info(deviceName, brand, model, icon, zone string)
- func (T *ResponsePayloadDevice) Light(deviceId, powerState, color, brightness, colorTemperature string)
- func (T *ResponsePayloadDevice) Outlet(deviceId, powerState string)
- func (T *ResponsePayloadDevice) Switch(deviceId, powerState string)
- type ResponseProperties
- type ResponseWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aligenie ¶
type Aligenie struct {
AppIdAttr string // 属性id
// contains filtered or unexported fields
}
aligenie
func (*Aligenie) ServeHTTP ¶
func (T *Aligenie) ServeHTTP(w http.ResponseWriter, r *http.Request)
服务处理
w http.ResponseWriter http响应 r *http.Request http请求
func (*Aligenie) SetApp ¶
func (T *Aligenie) SetApp(id string, app *Application)
设置APP
id string id名称 app *Application app配置
type Application ¶
type Application struct {
HandleFunc http.HandlerFunc // 处理函数
ValidReqTimestamp int // 有效时间,秒为单位
}
程序
type Header ¶
type Header struct {
MessageId string `json:"messageId"` //1,用于跟踪请求,是不重复的消息id
//查询类(与AliGenie.Iot.Device.Query对应)
//支持的查询属性方法 操作方法说明 返回值说明
//Query 查询所有标准属性 详情见各个属性
//QueryColor 查询颜色 Red、Yellow、Blue、White、Black等值(AliGenie以这些值为准,厂家适配)
//QueryPowerState 查询电源开关 on(打开)、off(关闭)
//QueryTemperature 查询温度 返回数值(AliGenie默认的单位为摄氏度,厂家适配该单位)
//QueryHumidity 查询湿度 返回数值
//QueryWindSpeed 查询风速 返回值参考 设备控制 中章节 1.8.1 风速值对应表
//QueryBrightness 查询亮度 返回数值
//QueryFog 查询雾量 返回数值
//QueryMode 查询模式 返回值枚举参考例子模式切换中的例子
//QueryPM25 查询pm2.5 含量 返回数值
//QueryDirection 查询方向 返回 left,right,forward,back,up,down
//QueryAngle 查询角度 返回数值,单位度
Name string `json:"name"` //1,操作类型名称
//AliGenie.Iot.Device.Discovery 设备发现
//AliGenie.Iot.Device.Control 设备控制
//AliGenie.Iot.Device.Query 设备属性查询
Namespace string `json:"namespace"` //1,消息命名空间
PayLoadVersion int `json:"payLoadVersion"` //1,payload 的版本,目前版本为 1
}
type Home ¶
type Home struct {
Response *Response // 响应
Request *Request // 请求
App *Application // app
}
家
type Request ¶
type Request struct {
Header Header `json:"header"`
Payload RequestPayload `json:"payload"`
}
type RequestPayload ¶
type RequestPayload struct {
AccessToken string `json:"accessToken"` //1,token
DeviceId string `json:"deviceId"` //1,设备id
DeviceType string `json:"deviceType"` //1,设备类型,http://doc-bot.tmall.com/docs/doc.htm?spm=0.0.0.0.yEvk7c&treeId=393&articleId=108271&docType=1
Attribute string `json:"attribute"` //1,属性,http://doc-bot.tmall.com/docs/doc.htm?spm=0.0.0.0.wzijJu&treeId=393&articleId=108268&docType=1
//最值 说明
//max 对应最大值
//min 对应最小值
Value string `json:"value"` //1,值,开关的值
Extensions map[string]string `json:"extensions"` //0,扩展,产品扩展属性,为空返回null或者不返回该字段
}
type Response ¶
type Response struct {
Properties []*ResponseProperties `json:"properties,omitempty"`
Header Header `json:"header"`
Payload ResponsePayload `json:"payload"`
// contains filtered or unexported fields
}
func (*Response) Discovery ¶
func (T *Response) Discovery(product *ResponsePayloadDevice, devices ...*ResponsePayloadDevice)
设备发现
product *ResponsePayloadDevice 分类 devices *ResponsePayloadDevice... 产品
func (*Response) Query ¶
func (T *Response) Query(properties []*ResponseProperties)
设备状态查询
properties []ResponseProperties 属性值
type ResponsePayload ¶
type ResponsePayload struct {
//产品与设备列表
Devices []*ResponsePayloadDevice `json:"devices,omitempty"` //1,用户设备列表
//控制设备
DeviceId string `json:"deviceId,omitempty"` //1,设备ID
//错误
ErrorCode string `json:"errorCode,omitempty"` //0,错误代码
Message string `json:"message,omitempty"` //0,描述
}
type ResponsePayloadDevice ¶
type ResponsePayloadDevice struct {
DeviceId string `json:"deviceId"` //1,设备id
DeviceName string `json:"deviceName"` //1,设备名称,https://open.bot.tmall.com/oauth/api/aliaslist
DeviceType string `json:"deviceType"` //1,设备类型,具体参考AliGenie支持的品类列表
Zone string `json:"zone,omitempty"` //0,位置, https://open.bot.tmall.com/oauth/api/placelist
Brand string `json:"brand"` //1,品牌
Model string `json:"model"` //1,型号
Icon string `json:"icon"` //1,产品icon(https协议的url链接),像素最好160*160 以免在app显示模糊
//[{"name": "powerstate","value": "off"}]
Properties []ResponseProperties `json:"properties"` //1,性能,返回当前设备支持的属性状态列表,产品支持的属性列表参考 设备控制与设备状态查询页
//TurnOn和TurnOf
Actions []string `json:"actions"` //1,开关值,产品支持的操作
//parentId这个是key,存放着父设备ID
Extensions map[string]string `json:"extensions,omitempty"` //0,扩展,产品扩展属性,为空返回null或者不返回该字段
}
func (*ResponsePayloadDevice) Info ¶
func (T *ResponsePayloadDevice) Info(deviceName, brand, model, icon, zone string)
产品信息
deviceName 设备名称 brand, model, icon ,zone string 品牌,型号,图标,位置
func (*ResponsePayloadDevice) Light ¶
func (T *ResponsePayloadDevice) Light(deviceId, powerState, color, brightness, colorTemperature string)
灯
deviceId 设备id powerState 电源状态 on(打开),off(关闭) color 颜色 参考颜色对应表 http://doc-bot.tmall.com/docs/doc.htm?spm=0.0.0.0.wzijJu&treeId=393&articleId=108268&docType=1 brightness 亮度 数值 colorTemperature 色温 数值
func (*ResponsePayloadDevice) Outlet ¶
func (T *ResponsePayloadDevice) Outlet(deviceId, powerState string)
插座
deviceId 设备id powerState string 电源状态 on(打开),off(关闭)
func (*ResponsePayloadDevice) Switch ¶
func (T *ResponsePayloadDevice) Switch(deviceId, powerState string)
开关
deviceId 设备id powerState string 电源状态 on(打开),off(关闭)
type ResponseProperties ¶
type ResponseWriter ¶
type ResponseWriter interface {
Error(errStr, code string)
Discovery(product ResponsePayloadDevice, devices []ResponsePayloadDevice)
Control()
Query(properties []ResponseProperties)
WriteTo(w io.Writer) (n int64, err error)
}
Click to show internal directories.
Click to hide internal directories.