Add air_bags plugin
This commit is contained in:
parent
8c48beb3b7
commit
ff73d81d2d
|
@ -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
|
Loading…
Reference in New Issue