Add air_bags plugin

This commit is contained in:
Ceda EI 2020-12-31 06:03:52 +05:30
parent 8c48beb3b7
commit ff73d81d2d
1 changed files with 28 additions and 0 deletions

28
plugins/air_bags.py Normal file
View File

@ -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