1、背景
由于Thingsboard平台国内只支持短信服务,那我们运维人员去及时接收邮箱肯定是没有短信来的方便的,在这基础上,需要自己从规则链入手,自定义一个支持阿里云短信服务的规则节点。
2、阿里云短信服务开通
进入阿里云官网,搜索短信服务即可
测试用,直接免费注册一个即可
进去之后直接根据步骤一步一步操作,48小时内即可申请成功!
详细教程可以查看:阿里云短信服务开通和配置说明(带图)_阿里云短信服务新增资质是干什么的-CSDN博客
3、从源码入手自定义规则节点
在项目中找到,"rule-engine→rule-engine-components"
在 sms包中先把文件和包建好
3.1 定义ExternalSmsType(枚举类)和SendSms(接口)
新增类都要加thingsboard的专属类头,不然文件不起作用,后面就不加了 ,请自行添加!!
这个枚举类主要是用来定义各个sms服务厂商名字
/**
* Copyright © 2016-2023 The Thingsboard Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.thingsboard.rule.engine.sms.external;
/**
* 扩展外部的sms厂商,为之后可以拓展更多的SMS服务做准备
* 比如说 华为云、腾讯云等。
*/
public enum ExternalSmsType {
ALI_SMS,
TENCENT_SMS,
HUAWEI_SMS,
QIN