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.