IoT-Smartthings(一)

Getting Start with Autimations

一. 准备

  1. 下载postman或者使用web端postman
  2. 通过自己的三星账户创建私人访问令牌
    网址:
https://account.smartthings.com/tokens

二. 使用postman向smartthings发送请求,获取自己账户内智能设备的id。

  1. 在postman中创建一个http request请求,
  2. 在网址
https://developer-preview.smartthings.com/api/public/#tag/Devices

中获取api网址:

https://api.smartthings.com/v1/devices

在这里插入图片描述

3.在postman的Authorization中选择Bearer Token,将私人访问令牌填入
在这里插入图片描述
4.点击send按钮

在这里插入图片描述
5.获得json格式的消息,从消息中获取deviceid

三. 创建rule

  1. 从api网页中获取创建rules的网址
https://api.smartthings.com/rules?locationId=xxxx
  1. 访问方式改为POST
  2. 设置Authorization(与二.3相同)
  3. 在Body中选择raw,添加需要创建的rule

在这里插入图片描述
以turn on a switch at sunset为例

{
    "name": "Turn on a switch at sunset",
    "actions": [
        {
            "every": {
                "specific": {
                    "reference": "Sunset",
                    "offset": {
                        "value": {
                            "integer": 0
                        },
                        "unit": "Minute"
                    }
                },
                "actions": [
                    {
                        "command": {
                            "devices": ["your-device-id"],
                            "commands": [ {
                                "component": "main",
                                "capability": "switch",
                                "command": "on"
                            }]
                        }
                    }    
                ]
            }
        }    
    ]
}

5.点击send
6.得到返回的消息

四.手动触发rule的执行

1.与之前相似的操作
post 网址:https://api.smartthings.com/rules/execute/:ruleId?locationId={your-location-id}
需要设置ruleid:
在这里插入图片描述

设置Authorization

2.获得执行结果:

{
    "executionId": "xxx",
    "id": "xxx",
    "behaviorType": "Rule",
    "result": "Success"
}

Final:

虽然显示success,但我的switch并没有打开,但log中能查看到该rule已激活。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个问题通常出现在使用 Maven 或 Gradle 进行项目构建时,其中某些模块之间存在循环依赖,同时又在注解处理器中使用了这些模块,导致注解处理器无法正确处理这些模块。 解决这个问题的方法是将循环依赖的模块排除在注解处理器之外,具体的做法如下: 1. 对于 Maven 项目,在 pom.xml 文件中为注解处理器配置 exclusions,如下所示: ```xml <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <annotationProcessors> <annotationProcessor>your.annotation.processor.ClassName</annotationProcessor> </annotationProcessors> <excludes> <exclude>iot-api-data-manage</exclude> <exclude>iot-data-buz</exclude> <exclude>iot-data-domain</exclude> </excludes> </configuration> </plugin> </plugins> </build> ``` 2. 对于 Gradle 项目,在 build.gradle 文件中为注解处理器配置 options,如下所示: ```groovy compileJava { options.annotationProcessorPath = configurations.annotationProcessor options.compilerArgs += ['-proc:only'] options.compilerArgs += ['-Ajavax.annotation.processing.SupportedAnnotationTypes=your.annotation.processor.ClassName'] options.compilerArgs += ['-Aproc:exclude=iot-api-data-manage,iot-data-buz,iot-data-domain'] } ``` 在配置文件中,注解处理器的名称和循环依赖的模块名称需要根据实际情况进行修改。排除循环依赖的模块后,重新编译项目即可。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值