Compare commits

...

2 Commits

Author SHA1 Message Date
Ceda EI 777d79aec8 Update sample config 2020-12-22 13:45:28 +05:30
Ceda EI 282c96a9e4 Add fuel_check plugin 2020-12-21 18:13:05 +05:30
3 changed files with 29 additions and 2 deletions

View File

@ -1 +1,2 @@
plugins = []
from . import fuel_check
plugins = [fuel_check]

26
plugins/fuel_check.py Normal file
View File

@ -0,0 +1,26 @@
import time
start = time.monotonic()
last_message = None
threshold = 5
def check(data, emit):
"Checks if the fuel ratio is below a certain threshold"
global last_message
if "FuelRatio" not in data:
return
ratio = data["FuelRatio"]
if ratio <= threshold:
if last_message is None:
emit("switchPlugin", {
"plugin": "warning",
"data": {
"title": "Low Fuel",
"description": f"Only {int(ratio)}% fuel left. Please refill the tank."
},
"time": 5000
})
last_message = time.monotonic()
else:
last_message = None

View File

@ -1,3 +1,3 @@
OSD_URL = "http://localhost:5050/send/"
OSD_URL = "http://localhost:5050/send"
CAR_API_URL = "http://localhost:5000/all/"
DELAY = 0