Page 64 - 《软件学报》2021年第12期
P. 64
软件学报 ISSN 1000-9825, CODEN RUXUEW E-mail: jos@iscas.ac.cn
Journal of Software,2021,32(12):3728−3750 [doi: 10.13328/j.cnki.jos.006098] http://www.jos.org.cn
©中国科学院软件研究所版权所有. Tel: +86-10-62562563
∗
SSRules:让智能家居自动化规则更易于编写和检查
1,2
1,2
1,2
1,2
王 博 , 张 昱 , 耿佳宁 , 李向阳
1
(中国科学技术大学 计算机科学与技术学院 下一代移动计算与数据创新实验室,安徽 合肥 230027)
2 (中国科学院 无线光电通信重点实验室,安徽 合肥 230027)
通讯作者: 张昱, E-mail: yuzhang@ustc.edu.cn
摘 要: 智能家居赋予家庭设备以智能,受到用户的广泛欢迎.由于用户需求不同,服务提供商采用“触发-动作”编
程(TAP)模式以支持用户定制规则.然而,现在 TAP 编程和智能家居执行引擎中流行的 Event-State 时序范式极易出
错,且难以修改规则和追踪运行错误.对TAP缺陷的原因进行系统分析之后,提出一种编写和修改难度较低、且能够
检测规则运行异常的方案,记为 SSRules.SSRules 允许用户以一种改进的 State-State 时序范式输入规则,并基于 Z3
定理证明器将其翻译为 Event-State 时序范式,且为开源智能家居系统 Home Assistant 所接受的规则输入.考虑到智
能家居需要实时掌握设备的动态,SSRules 引入了运行时子系统获取实体状态信息,并对规则执行有效性检查.最后,
基于 Unity3D 开发了智能家居模拟器 HA-Simulator.测试结果表明:SSRules 与传统方法相比表达简洁,规则数目平
均减少 60%左右,且能够及时检测瞬时异常并记录原因,更易被用户理解和使用.
关键词: 智能家居;触发-动作编程;终端用户编程;运行时系统;缺陷检测
中图法分类号: TP311
中文引用格式: 王博,张昱,耿佳宁,李向阳.SSRules:让智能家居自动化规则更易于编写和检查.软件学报,2021,32(12):
3728−3750. http://www.jos.org.cn/1000-9825/6098.htm
英文引用格式: Wang B, Zhang Y, Geng JN, Li XY. SSRules: Make it easier to write and check automation rules for smart home
systems. Ruan Jian Xue Bao/Journal of Software, 2021,32(12):3728−3750 (in Chinese). http://www.jos.org.cn/1000-9825/6098.htm
SSRules: Make it Easier to Write and Check Automation Rules for Smart Home Systems
1,2
1,2
1,2
WANG Bo , ZHANG Yu , GENG Jia-Ning , LI Xiang-Yang 1,2
1 (LINKE, School of Computer Science and Technology, University of Science and Technology of China, Hefei 230027, China)
2 (Key Laboratory of Wireless-Optical Communications, Chinese Academy of Sciences, Hefei 230027, China)
Abstract: Smart home systems make home devices smart and are widely welcomed by users. Due to different user needs, service
providers use “trigger-action” programming (TAP) mode to support user-tailored rules. However, the Event-State paradigm, which is now
popular in TAP programming and smart home rule engines, is highly error-prone, and the modification of the rules and the tracking of
errors are difficult. After systematic analysis of the causes of TAP defects, a scheme with low difficulty in writing and modification and
being able to detect abnormal rule operation is proposed, denoted as SSRules. SSRules allows users to enter rules written in improved
State-State paradigm, and SSRules can translate them into rules written in Event-State paradigm and acceptable by the open-source smart
home system Home Assistant based on the Z3 Theorem Prover. Considering that smart homes need to master the dynamics of the device
in real-time, SSRules introduces a runtime subsystem to obtain state information and perform rule execution validity checks. Finally, a
smart home simulator HA-Simulator is developed in Unity3D. Tests on it show that SSRules is more concise than traditional methods, the
number of rules is reduced by around 60% on average. It can detect transient anomalies promptly and record the cause, which is easier for
users to understand and use.
∗ 基金项目: 国家重点研发计划(2018YFB0803400); 国家自然科学基金(61772487); 安徽省自然科学基金(1808085MF198)
Foundation item: National Key Research and Development Program of China (2018YFB0803400); National Natural Science
Foundation of China (61772487); Anhui Provincial Natural Science Foundation (1808085MF198)
收稿时间: 2020-02-21; 修改时间: 2020-04-28; 采用时间: 2020-06-16