diff --git a/plugins/air_bags.py b/plugins/air_bags.py new file mode 100644 index 0000000..1d62df5 --- /dev/null +++ b/plugins/air_bags.py @@ -0,0 +1,28 @@ +"AirBags" +import time + +from daemon import DaemonPlugin + +class AirBags(DaemonPlugin): + "Checks AirBags and sends relevant warnings" + last_message = None + start = None + + def initialize(self): + "Initialize plugin" + self.start = time.monotonic() + + def check(self, data): + "Checks if the air bags are deployed" + if "AirBags-Deploy" not in data: + return + + if data["AirBags-Deploy"]: + if self.last_message is None: + self.emit("switchPlugin", { "plugin": "accident" }) + message = ("Airbags were released. Calling ambulance in 20 " + "seconds. Tap screen to cancel.") + self.speak(message) + self.last_message = time.monotonic() + else: + self.last_message = None