27 lines
694 B
Python
27 lines
694 B
Python
|
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
|