官方服务是由AIoT创新工厂基于平台能力提供的一系列服务,供ISV使用开发应用,后续会逐步引入更多官方服务。

1、消息推送服务

消息推送服务是基于平台已有的各个品类下的消息模板,由ISV调用发送接口进行多端消息推送的官方服务。该服务包含消息模板列表接口、消息模板详情接口、消息发送接口,ISV只有应用勾选了消息推送服务该应用才能使用调用该部分接口。

1.1、开发依赖

下载平台提供的sdk jar(aligenie-java-sdk-iotapplicationforopen-1.1.1.jar),同时加入以下maven依赖包,目前平台暂只支持基于java开发调用官方服务。

  1. <dependency>
  2. <groupId>com.aliyun</groupId>
  3. <artifactId>aliyun-java-sdk-core</artifactId>
  4. <optional>true</optional>
  5. <version>[4.5.1,5.0.0)</version>
  6. </dependency>
  7. <dependency>
  8. <groupId>com.alibaba</groupId>
  9. <artifactId>fastjson</artifactId>
  10. <version>1.2.62</version>
  11. </dependency>
  12. <dependency>
  13. <groupId>commons-collections</groupId>
  14. <artifactId>commons-collections</artifactId>
  15. <version>3.2.2</version>
  16. </dependency>
  17. <dependency>
  18. <groupId>commons-beanutils</groupId>
  19. <artifactId>commons-beanutils</artifactId>
  20. <version>1.9.3</version>
  21. </dependency>

调用示例如下,其中regionId为固定值「cn-zhangjiakou」,IotApplicationComponent建议封装为spring bean或者单例提供。

  1. MsgTemplateRequest msgTemplateRequest = new MsgTemplateRequest();
  2. msgTemplateRequest.setAccountId("xxxxx");
  3. msgTemplateRequest.setTemplateId("xxxxxxxxx");
  4. DefaultProfile profile = DefaultProfile.getProfile("cn-zhangjiakou", "xxxxx", "xxxxx");
  5. IAcsClient client = new DefaultAcsClient(profile);
  6. IotApplicationComponent iotApplicationComponent = new IotApplicationComponent();
  7. BaseResult<MsgTemplateResponse> result = iotApplicationComponent.getMessageTemplate(client, msgTemplateRequest);

1.2、 消息模板(列表)接口

API名称

  1. IotApplicationComponent.getMessageTemplateList

API入参


名称 参数类型/SDK类型 是否必须 文档可见 默认值 示例值 更多限制 描述
devType String 必须 是 light 品类英文名称
accountId Long 必须 是 188 平台id
applicationId String 必须 是 sa23f 应用id
pageSize Integer 必须 是 1 分页每页页数
pageNum Integer 必须 是 50 当前页数

API出参


名称 参数类型/SDK类型 是否必须 文档可见 示例值 描述
retValue MessageTemplatePageDTO 是 是 结果对象
└ totalCount Integer 是 是
└ pageCount Integer 是 是
└ pageSize Integer 是 是
└ currentPage Integer 是 是
└ msgTemplateInfoList List 是 是
└ id String 是 是 4000279001 消息模板id
└ templateName String 是 是 布防报警 模板名称
└ openTemplateId String 是 是 模板唯一标识
└ openTemplateVersion String 是 是 wqer== 模板版本号(模板内容有可能进行调整,调整后即为新模板内容,openTemplateId也会变化)
retCode String 是 是 0 结果码
retMessage String 否 是 错误信息
常见错误码 错误信息
150001 Account用户和API使用者不匹配
150004 淘宝用户未注册平台账号
150006 请求ip未被授权
150102 消息模板列表页每页页数参数需在50到100

1.3、 消息模板详情接口

API名称

  1. IotApplicationComponent.getMessageTemplate

API入参


名称 参数类型/SDK类型 是否必须 文档可见 默认值 示例值 更多限制 描述
openTemplateId String 必须 是 light 模板唯一标识
accountId String 必须 是 188 平台id
applicationId String 必须 是 fa23 应用id

API出参

名称 参数类型/SDK类型 是否必须 文档可见 示例值 描述
retValue MessageTemplateDetailDto 是 是 结果对象
└ appBoxTemplate AppBoxTemplate 是 是 消息模板内容
└ appMessage AppMessage 否 是 APP消息
└ title String 否 是 标题
└ content String 否 是 内容
└ fatigueRule FatigueRule 否 是 疲劳度控制
└ type String 否 是 EXPRESSION:单日允许次数、NUMERIC:间隔时间段允许推送次数
└ frequency String 否 是 推送次数,当type为EXPRESSION时,一天内允许推送次数;当type为NUMERIC时,间隔时间段允许推送次数
└ interval String 否 是 当type为NUMERIC时有效,指定时间段「时间段」推送一条
└ unit_type String 否 是 当type为NUMERIC时有效,指定时间段「单位」推送一条。MILLSECONDS:毫秒,SECONDS:秒,MINUTES:分钟,HOURS:小时,DAY:天
└ appDeskTemplate AppDeskTemplate 否 是
└ appMessage AppMessage 否 是 APP消息
└ title String 否 是 标题
└ content String 否 是 内容
└ fatigueRule FatigueRule 否 是 疲劳度控制
└ type String 否 是 EXPRESSION:单日允许次数、NUMERIC:间隔时间段允许推送次数
└ frequency String 否 是 推送次数,当type为EXPRESSION时,一天内允许推送次数;当type为NUMERIC时,间隔时间段允许推送次数
└ interval String 否 是 当type为NUMERIC时有效,指定时间段「时间段」推送一条
└ unitType String 否 是 当type为NUMERIC时有效,指定时间段「单位」推送一条。MILLSECONDS:毫秒,SECONDS:秒,MINUTES:分钟,HOURS:小时,DAY:天
└ pushPeriodList List 否 是 允许推送时间
└ startTime String 否 是 06:00:00 允许推送-开始时间
└ endTime String 否 是 14:00:00 允许推送-结束时间
└ ttsImmediateTemplate TtsImmediateTemplate 否 是 tts消息模板
└ ttsMessage String 否 是 tts内容
└ fatigueRule FatigueRule 否 是 疲劳度控制
└ type String 否 是 EXPRESSION:单日允许次数、NUMERIC:间隔时间段允许推送次数
└ frequency String 否 是 推送次数,当type为EXPRESSION时,一天内允许推送次数;当type为NUMERIC时,间隔时间段允许推送次数
└ interval String 否 是 当type为NUMERIC时有效,指定时间段「时间段」推送一条
└ unitType String 否 是 当type为NUMERIC时有效,指定时间段「单位」推送一条。MILLSECONDS:毫秒,SECONDS:秒,MINUTES:分钟,HOURS:小时,DAY:天
└ pushPeriodList List 否 是 允许推送时间
└ startTime String 否 是 06:00:00 允许推送-开始时间
└ endTime String 否 是 14:00:00 允许推送-结束时间
retCode String 是 是 0 结果码
retMessage String 否 是 错误信息
  1. {
  2. "result": {
  3. "retCode": "200",
  4. "retValue": {
  5. "appBoxTemplate": {
  6. "appMessage": {
  7. "title": "app消息盒子标题",
  8. "content": "app消息盒子内容"
  9. },
  10. "fatigueRule": {
  11. "type": "EXPRESSION",
  12. "frequency": "1",
  13. "interval": "3",
  14. "unitType": "SECONDS"
  15. }
  16. },
  17. "appDeskTemplate": {
  18. "appMessage": {
  19. "title": "APP弹窗标题",
  20. "content": "APP弹窗标题内容"
  21. },
  22. "fatigueRule": {
  23. "type": "EXPRESSION",
  24. "frequency": "1",
  25. "interval": "3",
  26. "unitType": "SECONDS"
  27. },
  28. "pushPeriodList": [
  29. {
  30. "startTime": "06:00:00",
  31. "endTime": "14:00:00"
  32. }
  33. ]
  34. },
  35. "ttsImmediateTemplate": {
  36. "ttsMessage": "这是tts内容",
  37. "fatigueRule": {
  38. "type": "EXPRESSION",
  39. "frequency": "1",
  40. "interval": "3",
  41. "unitType": "SECONDS"
  42. },
  43. "pushPeriodList": [
  44. {
  45. "startTime": "06:00:00",
  46. "endTime": "14:00:00"
  47. }
  48. ]
  49. }
  50. },
  51. "message": ""
  52. }
  53. }
常见错误码 错误信息
150001 Account用户和API使用者不匹配
150004 淘宝用户未注册平台账号
150006 请求ip未被授权
150104 消息模板id非法
150101 消息模板功能不可用

1.4、 发送消息接口

该发送消息接口为基于模板发送消息,收到一次设备上报数据,对应允许发送一次消息,否则发送失效。

API名称

  1. IotApplicationComponent.sendMessageByTemplateId

API入参


名称 参数类型/SDK类型 是否必须 文档可见 默认值 示例值 更多限制 描述
openTemplateId String 必须 是 light 模板唯一标识
openUserId String 必须 是 wqer== 开放用户id
accountId String 必须 是 188 平台id
deviceId String 必须 是 设备id
applicationId String 必须 是 应用id
productId String 否 是 产品pid
productKey String 必须 是 产品pk
params Map 否 是 发送模板需要的参数
time Long 必须 是 设备上报时附带的时间戳
messageId String 必须 是 平台消息分发时消息id

API出参

名称 参数类型/SDK类型 是否必须 文档可见 示例值 描述
retValue Boolean 是 是 是否发送成功
retCode String 是 是 0 结果码
retMessage String 否 是 错误信息
常见错误码 错误信息
150001 Account用户和API使用者不匹配
150004 淘宝用户未注册平台账号
150006 请求ip未被授权
150100 消息未在规定时间段内发送或上报消息已被消费请勿重试
150103 消息入参productId无效
508012 产品暂不支持发送
508013 暂不支持发送该用户
508015 模板不匹配,请使用正确的模板推送消息

2、食谱服务

食谱服务是平台提供智能食谱服务,云端录入食谱内容,并支持将预设好的烹饪指令自动下发到设备端执行的官方服务。

2.1、 平台录入食谱内容

添加食谱集
image.png
添加食谱(内容)
image.png
食谱(内容)编辑
image.png
image.png

录入食谱步骤
image.png
image.png

2.2、 产品物模型支持

对接食谱的IoT产品对物模型属性有一定要求,具体参见文档(第2点 补充文档一列):https://www.aligenie.com/doc/357554/gc2pco

2.3、 协议对接

蓝牙协议文档:https://www.aligenie.com/doc/357554/kw56sz
WIFI协议文档:https://www.aligenie.com/doc/357554/mltmvr

2.4、 食谱H5页面调用

接口文档参见:https://www.aligenie.com/doc/357554/xem5m5

2.5、 食谱Api接口

如果ISV需要以接口形式对食谱进行操作,可参考文档 https://www.aligenie.com/doc/357554/xkpsvo#OOaH7 进行操作。

2.6、 附录

食谱支持品类 https://www.aligenie.com/doc/357554/hiku59
食谱支持标签 https://www.aligenie.com/doc/357554/xum3re