Allow configuration of drop and raise alarm independently
parent
273c1b8928
commit
1e7b9f1b65
|
|
@ -11,7 +11,9 @@ Get a notification when the pressure reaches defined thresholds.
|
|||
* Low threshold: Warn when pressure drops below this value
|
||||
* High alarm: Toggle high alarm
|
||||
* High threshold: Warn when pressure exceeds above this value
|
||||
* Change alarm: Warn when pressure changes more than this value in the recent 3 hours (having at least 30 min of data)
|
||||
* Drop alarm: Warn when pressure drops more than this value in the recent 3 hours (having at least 30 min of data)
|
||||
0 to disable this alarm.
|
||||
* Raise alarm: Warn when pressure raises more than this value in the recent 3 hours (having at least 30 min of data)
|
||||
0 to disable this alarm.
|
||||
* Show widget: Enable/disable widget visibility
|
||||
* Buzz on alarm: Enable/disable buzzer on alarm
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
"min": 950,
|
||||
"highalarm": false,
|
||||
"max": 1030,
|
||||
"changeIn3h": 2,
|
||||
"drop3halarm": 2,
|
||||
"raise3halarm": 0,
|
||||
"show": true,
|
||||
"interval": 15
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,15 +53,25 @@
|
|||
step: 10,
|
||||
onchange: x => save("max", x),
|
||||
},
|
||||
"Change alarm": {
|
||||
value: settings.changeIn3h,
|
||||
"Drop alarm": {
|
||||
value: settings.drop3halarm,
|
||||
min: 0,
|
||||
max: 10,
|
||||
step: 1,
|
||||
format: x => {
|
||||
return x != 0 ? x + ' hPa/3h' : 'off';
|
||||
},
|
||||
onchange: x => save("changeIn3h", x)
|
||||
onchange: x => save("drop3halarm", x)
|
||||
},
|
||||
"Raise alarm": {
|
||||
value: settings.raise3halarm,
|
||||
min: 0,
|
||||
max: 10,
|
||||
step: 1,
|
||||
format: x => {
|
||||
return x != 0 ? x + ' hPa/3h' : 'off';
|
||||
},
|
||||
onchange: x => save("raise3halarm", x)
|
||||
},
|
||||
"Show widget": {
|
||||
value: settings.show,
|
||||
|
|
|
|||
|
|
@ -80,8 +80,9 @@
|
|||
|
||||
if (!alreadyWarned) {
|
||||
// 3h change detection
|
||||
const threeHourChange = setting("changeIn3h");
|
||||
if (threeHourChange > 0) {
|
||||
const drop3halarm = setting("drop3halarm");
|
||||
const raise3halarm = setting("raise3halarm");
|
||||
if (drop3halarm > 0 || raise3halarm > 0) {
|
||||
// we need at least 30min of data for reliable detection
|
||||
if (history3[0]["ts"] > ts - (30 * 60)) {
|
||||
return;
|
||||
|
|
@ -91,10 +92,23 @@
|
|||
const oldestAvgPressure = (history3[0]["p"] + history3[1]["p"] + history3[2]["p"]) / 3;
|
||||
if (oldestAvgPressure != undefined && oldestAvgPressure > 0) {
|
||||
const diff = oldestAvgPressure - avrPressure;
|
||||
if (Math.abs(diff) > threeHourChange) {
|
||||
showAlarm((Math.round(Math.abs(diff) * 10) / 10) + " hPa/3h from " +
|
||||
Math.round(oldestAvgPressure) + " to " + Math.round(avrPressure) + " hPa",
|
||||
"Pressure " + (diff > 0 ? "drop" : "raise"));
|
||||
|
||||
// drop alarm
|
||||
if (drop3halarm > 0 && oldestAvgPressure > avrPressure) {
|
||||
if (Math.abs(diff) > drop3halarm) {
|
||||
showAlarm((Math.round(Math.abs(diff) * 10) / 10) + " hPa/3h from " +
|
||||
Math.round(oldestAvgPressure) + " to " + Math.round(avrPressure) + " hPa",
|
||||
"Pressure drop"));
|
||||
}
|
||||
}
|
||||
|
||||
// raise alarm
|
||||
if (raise3halarm > 0 && oldestAvgPressure < avrPressure) {
|
||||
if (Math.abs(diff) > raise3halarm) {
|
||||
showAlarm((Math.round(Math.abs(diff) * 10) / 10) + " hPa/3h from " +
|
||||
Math.round(oldestAvgPressure) + " to " + Math.round(avrPressure) + " hPa",
|
||||
"Pressure raise"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue