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
|
* Low threshold: Warn when pressure drops below this value
|
||||||
* High alarm: Toggle high alarm
|
* High alarm: Toggle high alarm
|
||||||
* High threshold: Warn when pressure exceeds above this value
|
* 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.
|
0 to disable this alarm.
|
||||||
* Show widget: Enable/disable widget visibility
|
* Show widget: Enable/disable widget visibility
|
||||||
* Buzz on alarm: Enable/disable buzzer on alarm
|
* Buzz on alarm: Enable/disable buzzer on alarm
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@
|
||||||
"min": 950,
|
"min": 950,
|
||||||
"highalarm": false,
|
"highalarm": false,
|
||||||
"max": 1030,
|
"max": 1030,
|
||||||
"changeIn3h": 2,
|
"drop3halarm": 2,
|
||||||
|
"raise3halarm": 0,
|
||||||
"show": true,
|
"show": true,
|
||||||
"interval": 15
|
"interval": 15
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,15 +53,25 @@
|
||||||
step: 10,
|
step: 10,
|
||||||
onchange: x => save("max", x),
|
onchange: x => save("max", x),
|
||||||
},
|
},
|
||||||
"Change alarm": {
|
"Drop alarm": {
|
||||||
value: settings.changeIn3h,
|
value: settings.drop3halarm,
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 10,
|
max: 10,
|
||||||
step: 1,
|
step: 1,
|
||||||
format: x => {
|
format: x => {
|
||||||
return x != 0 ? x + ' hPa/3h' : 'off';
|
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": {
|
"Show widget": {
|
||||||
value: settings.show,
|
value: settings.show,
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,9 @@
|
||||||
|
|
||||||
if (!alreadyWarned) {
|
if (!alreadyWarned) {
|
||||||
// 3h change detection
|
// 3h change detection
|
||||||
const threeHourChange = setting("changeIn3h");
|
const drop3halarm = setting("drop3halarm");
|
||||||
if (threeHourChange > 0) {
|
const raise3halarm = setting("raise3halarm");
|
||||||
|
if (drop3halarm > 0 || raise3halarm > 0) {
|
||||||
// we need at least 30min of data for reliable detection
|
// we need at least 30min of data for reliable detection
|
||||||
if (history3[0]["ts"] > ts - (30 * 60)) {
|
if (history3[0]["ts"] > ts - (30 * 60)) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -91,10 +92,23 @@
|
||||||
const oldestAvgPressure = (history3[0]["p"] + history3[1]["p"] + history3[2]["p"]) / 3;
|
const oldestAvgPressure = (history3[0]["p"] + history3[1]["p"] + history3[2]["p"]) / 3;
|
||||||
if (oldestAvgPressure != undefined && oldestAvgPressure > 0) {
|
if (oldestAvgPressure != undefined && oldestAvgPressure > 0) {
|
||||||
const diff = oldestAvgPressure - avrPressure;
|
const diff = oldestAvgPressure - avrPressure;
|
||||||
if (Math.abs(diff) > threeHourChange) {
|
|
||||||
|
// drop alarm
|
||||||
|
if (drop3halarm > 0 && oldestAvgPressure > avrPressure) {
|
||||||
|
if (Math.abs(diff) > drop3halarm) {
|
||||||
showAlarm((Math.round(Math.abs(diff) * 10) / 10) + " hPa/3h from " +
|
showAlarm((Math.round(Math.abs(diff) * 10) / 10) + " hPa/3h from " +
|
||||||
Math.round(oldestAvgPressure) + " to " + Math.round(avrPressure) + " hPa",
|
Math.round(oldestAvgPressure) + " to " + Math.round(avrPressure) + " hPa",
|
||||||
"Pressure " + (diff > 0 ? "drop" : "raise"));
|
"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