Automatic Trigger Generation for Rule-based Smart Homes ACM SIGPLAN PLAS, Vienna, Austria 10-24-2016 Chandrakana Nandi, Michael D. Ernst UW Seattle, USA
2
3
Common architecture OR 4
How to control your home? 5
How to control your home? Automation rules: when I come home then turn lights on 6
How to control your home? Automation rules are easy and useful Ur+ CHI 2014, 2016 Ur+ HUPS 2014 Dey+ Pervasive 2006 7
How to control your home? Writing correct automation rules is hard Huang+ Ubicomp 2015 8
How to control your home? rule “start laundry” when Item laundry _ machine changed mental model actual rule then if (laundry_machine == FULL) { sendCommand(laundry _ machine, “ON”) } end Writing correct automation rules is hard Huang+ Ubicomp 2015 9
Effects of wrong rules ● Likely unexpected behavior ● Security vulnerabilities 10
Overview ● Background on automation rules ● Problem statement ● Solution ● Algorithm and tool development ● Experiments 11
Overview ● Background on automation rules ● Problem statement ● Solution ● Algorithm and tool development ● Experiments 12
Rule Example rule "Away rule" when Item State_Away changed or Item State_Sleeping changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 13
Rule Example rule "Away rule" when Item State_Away changed or Item State_Sleeping changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 14
Rule Example rule "Away rule" when Item State_Away changed trigger block or Item State_Sleeping changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 15
Rule Example rule "Away rule" when trigger item Item State_Away changed trigger block or Item State_Sleeping changed then trigger item if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 16
Rule Example rule "Away rule" when Item State_Away changed or Item State_Sleeping changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { action block postUpdate (State_Sleeping, OFF) } } end 17
State_Away = ON rule "Away rule" when Item State_Away changed or Item State_Sleeping changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } State_Sleeping = ON end 18
Overview ● Background on automation rules ● Problem statement ● Solution ● Algorithm and tool development ● Experiments 19
Possible mistakes in rules 20
Wrong trigger block rule "Away rule" when Item State_Roomheater changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 21
Wrong trigger block rule "Away rule" when Item State_Away changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 22
Wrong trigger block rule "Away rule" when Item trigger_1 changed Item trigger_2 changed Item trigger_n changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 23
Conflicts rule “rule 2” rule “rule 1” when when Item past_midnight changed Item owner_entering_home changed then then if (past_midnight == true) { if (owner_entering_home == true) { sendCommand (hall_light, “OFF”) sendCommand (hall_light, “ON”) } } end end (owner_entering_home == true && past_midnight == true) 24
● Wrong trigger blocks ● Conflicts 25
● Wrong trigger blocks ● Conflicts 26
Why is it bad? 27
rule "Away rule" when Item State_Away changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end !(State_Away = ON && State_Sleeping = ON) 28
rule "Away rule" when Item State_Away changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 29
rule "Away rule" when Item State_Away changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 30
rule "Away rule" when Item State_Away changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 31
rule "Away rule" when Item State_Away changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 32
rule "Away rule" when Item State_Away changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 33
rule "Away rule" when Item State_Away changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 34
rule "Away rule" when Item State_Away changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 35
rule "Away rule" when Item State_Away changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 36
rule "Away rule" when Item State_Away changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 37
Both states can be set to true! 38
rule "Visitor notification system rule" when Item State_Sleeping changed then if (State_Sleeping.state == ON) { postUpdate (Notification_System , OFF) } else { postUpdate (Notification_System , ON) } end 39
Example Attack rule "Away rule" rule "Visitor notification system rule" when when Item State_Away changed Item State_Sleeping changed then then if (State_Away.state == ON) { if (State_Sleeping.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (Notification_System , OFF) postUpdate (State_Sleeping, OFF) } else { } postUpdate (Notification_System , ON) } } end end Wrongly deactivates notification system 40
Overview ● Background on automation rules ● Problem statement ● Solution ● Algorithm and tool development ● Experiments 41
Solution rule "Away rule" when Item State_Away changed then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 42
Solution rule "Away rule" when Item State_Away changed or Item State_Sleeping changed // Fix then if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 43
Overview ● Background on automation rules ● Problem statement ● Solution ● Algorithm and tool development ● Experiments 44
TrigGen: automatically infer triggers from actions using static analysis Idea: live items must be triggers 45
Idea: live items must be triggers Items that are read from before being written to, at the beginning of the action block 46
rule "Away rule" when Item State_Away changed then State_Notify = ON if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 47
● Identify all items in the rule "Away rule" when action block AST Item State_Away changed then ○ potential triggers State_Notify = ON if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 48
● Identify all items in the rule "Away rule" when action block AST Item State_Away changed then ○ potential triggers State_Notify = ON if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) } } end 49
● Identify all items in the rule "Away rule" when action block AST Item State_Away changed then ○ potential triggers State_Notify = ON if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) ● eliminate those that are } } not live end ○ redundant triggers ■ State_Notify 50
● Identify all items in the rule "Away rule" when action block AST Item State_Away changed then ○ potential triggers State_Notify = ON if (State_Away.state == ON) { if (State_Sleeping.state != OFF) { postUpdate (State_Sleeping, OFF) ● eliminate those that are } } not live end ○ redundant triggers ■ State_Notify ● State_Away, State_Sleeping: live 51
Recommend
More recommend