Add configurable alarm thresholds
This commit is contained in:
@@ -206,3 +206,36 @@ nav button {
|
|||||||
color: #300;
|
color: #300;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.settings-list {
|
||||||
|
background: #222;
|
||||||
|
border: 1px solid #333;
|
||||||
|
border-radius: 14px;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-list label {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16px;
|
||||||
|
padding: 12px 0;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
border-bottom: 1px solid #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-list label:last-of-type {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-list input {
|
||||||
|
width: 90px;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid #555;
|
||||||
|
background: #111;
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|||||||
@@ -76,6 +76,31 @@
|
|||||||
<div>WiFi Override <strong id="sysWifiOverride">--</strong></div>
|
<div>WiFi Override <strong id="sysWifiOverride">--</strong></div>
|
||||||
</div>
|
</div>
|
||||||
<button onclick="enableWifi()">Enable WiFi 10 min</button>
|
<button onclick="enableWifi()">Enable WiFi 10 min</button>
|
||||||
|
|
||||||
|
<h2>Alarm Settings</h2>
|
||||||
|
<div class="settings-list">
|
||||||
|
<label>
|
||||||
|
Rear Seat Warning °F
|
||||||
|
<input id="rearWarningInput" type="number" value="85">
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
Rear Seat Critical °F
|
||||||
|
<input id="rearCriticalInput" type="number" value="95">
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
Fridge Warm °F
|
||||||
|
<input id="fridgeWarmInput" type="number" value="45">
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
Battery Low %
|
||||||
|
<input id="batteryLowInput" type="number" value="20">
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<button onclick="saveAlarmSettings()">Save Alarm Settings</button>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
@@ -92,6 +117,13 @@ let relayState = {};
|
|||||||
let activeAlarmKey = null;
|
let activeAlarmKey = null;
|
||||||
let acknowledgedAlarms = new Set();
|
let acknowledgedAlarms = new Set();
|
||||||
|
|
||||||
|
let alarmConfig = {
|
||||||
|
rear_seat_warning: 85,
|
||||||
|
rear_seat_critical: 95,
|
||||||
|
fridge_warm: 45,
|
||||||
|
battery_low: 20
|
||||||
|
};
|
||||||
|
|
||||||
function showScreen(id) {
|
function showScreen(id) {
|
||||||
document.querySelectorAll('.screen').forEach(screen => {
|
document.querySelectorAll('.screen').forEach(screen => {
|
||||||
screen.classList.remove('active');
|
screen.classList.remove('active');
|
||||||
@@ -106,13 +138,13 @@ function onOff(value) {
|
|||||||
function checkAlarms(data) {
|
function checkAlarms(data) {
|
||||||
const alarms = [];
|
const alarms = [];
|
||||||
|
|
||||||
if (data.temps.rear_seat >= 95) {
|
if (data.temps.rear_seat >= alarmConfig.rear_seat_critical) {
|
||||||
alarms.push({
|
alarms.push({
|
||||||
key: 'rear_seat_critical',
|
key: 'rear_seat_critical',
|
||||||
title: 'REAR SEAT TEMP CRITICAL',
|
title: 'REAR SEAT TEMP CRITICAL',
|
||||||
message: `${data.temps.rear_seat}°F detected near car seat area`
|
message: `${data.temps.rear_seat}°F detected near car seat area`
|
||||||
});
|
});
|
||||||
} else if (data.temps.rear_seat >= 85) {
|
} else if (data.temps.rear_seat >= alarmConfig.rear_seat_warning) {
|
||||||
alarms.push({
|
alarms.push({
|
||||||
key: 'rear_seat_warning',
|
key: 'rear_seat_warning',
|
||||||
title: 'REAR SEAT TEMP HIGH',
|
title: 'REAR SEAT TEMP HIGH',
|
||||||
@@ -120,7 +152,7 @@ function checkAlarms(data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.temps.fridge_zone_1 >= 45) {
|
if (data.temps.fridge_zone_1 >= alarmConfig.fridge_warm) {
|
||||||
alarms.push({
|
alarms.push({
|
||||||
key: 'fridge_zone_1_warm',
|
key: 'fridge_zone_1_warm',
|
||||||
title: 'FRIDGE ZONE 1 WARM',
|
title: 'FRIDGE ZONE 1 WARM',
|
||||||
@@ -128,7 +160,7 @@ function checkAlarms(data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.temps.fridge_zone_2 >= 45) {
|
if (data.temps.fridge_zone_2 >= alarmConfig.fridge_warm) {
|
||||||
alarms.push({
|
alarms.push({
|
||||||
key: 'fridge_zone_2_warm',
|
key: 'fridge_zone_2_warm',
|
||||||
title: 'FRIDGE ZONE 2 WARM',
|
title: 'FRIDGE ZONE 2 WARM',
|
||||||
@@ -136,7 +168,7 @@ function checkAlarms(data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.battery.soc <= 20) {
|
if (data.battery.soc <= alarmConfig.battery_low) {
|
||||||
alarms.push({
|
alarms.push({
|
||||||
key: 'battery_low',
|
key: 'battery_low',
|
||||||
title: 'BATTERY LOW',
|
title: 'BATTERY LOW',
|
||||||
@@ -167,6 +199,33 @@ function acknowledgeAlarm() {
|
|||||||
document.getElementById('alarmOverlay').classList.add('hidden');
|
document.getElementById('alarmOverlay').classList.add('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadAlarmSettings() {
|
||||||
|
const saved = localStorage.getItem('alarmConfig');
|
||||||
|
|
||||||
|
if (saved) {
|
||||||
|
alarmConfig = JSON.parse(saved);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('rearWarningInput').value = alarmConfig.rear_seat_warning;
|
||||||
|
document.getElementById('rearCriticalInput').value = alarmConfig.rear_seat_critical;
|
||||||
|
document.getElementById('fridgeWarmInput').value = alarmConfig.fridge_warm;
|
||||||
|
document.getElementById('batteryLowInput').value = alarmConfig.battery_low;
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveAlarmSettings() {
|
||||||
|
alarmConfig = {
|
||||||
|
rear_seat_warning: Number(document.getElementById('rearWarningInput').value),
|
||||||
|
rear_seat_critical: Number(document.getElementById('rearCriticalInput').value),
|
||||||
|
fridge_warm: Number(document.getElementById('fridgeWarmInput').value),
|
||||||
|
battery_low: Number(document.getElementById('batteryLowInput').value)
|
||||||
|
};
|
||||||
|
|
||||||
|
localStorage.setItem('alarmConfig', JSON.stringify(alarmConfig));
|
||||||
|
|
||||||
|
acknowledgedAlarms.clear();
|
||||||
|
alert('Alarm settings saved');
|
||||||
|
}
|
||||||
|
|
||||||
async function loadStatus() {
|
async function loadStatus() {
|
||||||
const res = await fetch('/status');
|
const res = await fetch('/status');
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
@@ -227,6 +286,7 @@ async function enableWifi() {
|
|||||||
loadStatus();
|
loadStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadAlarmSettings();
|
||||||
loadStatus();
|
loadStatus();
|
||||||
setInterval(loadStatus, 2000);
|
setInterval(loadStatus, 2000);
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user