sensoren
This commit is contained in:
@@ -426,6 +426,58 @@
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Temperature & Humidity Sensor Styles */
|
||||
.temp-humidity-display {
|
||||
padding: 1rem;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border-radius: 12px;
|
||||
color: white;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
.temp-humidity-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0.75rem 0;
|
||||
}
|
||||
|
||||
.temp-humidity-row:not(:last-child) {
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.temp-humidity-label {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.temp-humidity-value {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.5px;
|
||||
}
|
||||
|
||||
.temp-humidity-battery {
|
||||
font-size: 0.75rem;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
text-align: center;
|
||||
padding: 0.5rem;
|
||||
margin-top: 0.5rem;
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.temp-humidity-info {
|
||||
font-size: 0.75rem;
|
||||
color: #999;
|
||||
margin-top: 1rem;
|
||||
padding: 0.5rem;
|
||||
background: #f8f9fa;
|
||||
border-radius: 4px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.events {
|
||||
margin-top: 2rem;
|
||||
background: white;
|
||||
@@ -607,6 +659,28 @@
|
||||
🔒 Nur-Lesen Gerät • Keine Steuerung möglich
|
||||
</div>
|
||||
|
||||
{% elif device.type == "temp_humidity" or device.type == "temp_humidity_sensor" %}
|
||||
<div class="temp-humidity-display">
|
||||
<div class="temp-humidity-row">
|
||||
<span class="temp-humidity-label">🌡️ Temperatur:</span>
|
||||
<span class="temp-humidity-value" id="th-{{ device.device_id }}-t">--</span>
|
||||
<span style="font-size: 1.25rem; font-weight: 600;">°C</span>
|
||||
</div>
|
||||
<div class="temp-humidity-row">
|
||||
<span class="temp-humidity-label">💧 Luftfeuchte:</span>
|
||||
<span class="temp-humidity-value" id="th-{{ device.device_id }}-h">--</span>
|
||||
<span style="font-size: 1.25rem; font-weight: 600;">%</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="temp-humidity-battery" id="th-{{ device.device_id }}-battery" style="display: none;">
|
||||
🔋 <span id="th-{{ device.device_id }}-battery-value">--</span>%
|
||||
</div>
|
||||
|
||||
<div class="temp-humidity-info">
|
||||
🔒 Nur-Lesen Gerät • Keine Steuerung möglich
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
@@ -922,6 +996,39 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Update temperature & humidity sensor UI
|
||||
function updateTempHumidityUI(deviceId, payload) {
|
||||
const tempSpan = document.getElementById(`th-${deviceId}-t`);
|
||||
const humiditySpan = document.getElementById(`th-${deviceId}-h`);
|
||||
const batteryDiv = document.getElementById(`th-${deviceId}-battery`);
|
||||
const batteryValueSpan = document.getElementById(`th-${deviceId}-battery-value`);
|
||||
|
||||
if (!tempSpan || !humiditySpan) {
|
||||
console.warn(`No temp/humidity elements found for device ${deviceId}`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Update temperature (rounded to 1 decimal)
|
||||
if (payload.temperature !== undefined && payload.temperature !== null) {
|
||||
tempSpan.textContent = payload.temperature.toFixed(1);
|
||||
}
|
||||
|
||||
// Update humidity (rounded to 0-1 decimals)
|
||||
if (payload.humidity !== undefined && payload.humidity !== null) {
|
||||
// Round to 1 decimal if has decimals, otherwise integer
|
||||
const humidity = payload.humidity;
|
||||
humiditySpan.textContent = (humidity % 1 === 0) ? humidity.toFixed(0) : humidity.toFixed(1);
|
||||
}
|
||||
|
||||
// Update battery if present
|
||||
if (payload.battery !== undefined && payload.battery !== null && batteryDiv && batteryValueSpan) {
|
||||
batteryValueSpan.textContent = payload.battery;
|
||||
batteryDiv.style.display = 'block';
|
||||
} else if (batteryDiv) {
|
||||
batteryDiv.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// Add event to list
|
||||
function addEvent(event) {
|
||||
const eventList = document.getElementById('event-list');
|
||||
@@ -992,6 +1099,11 @@
|
||||
if (data.payload.contact !== undefined) {
|
||||
updateContactUI(data.device_id, data.payload.contact);
|
||||
}
|
||||
|
||||
// Check if it's a temp/humidity sensor
|
||||
if (data.payload.temperature !== undefined || data.payload.humidity !== undefined) {
|
||||
updateTempHumidityUI(data.device_id, data.payload);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1113,6 +1225,9 @@
|
||||
} else if (state.contact !== undefined) {
|
||||
// It's a contact sensor
|
||||
updateContactUI(deviceId, state.contact);
|
||||
} else if (state.temperature !== undefined || state.humidity !== undefined) {
|
||||
// It's a temp/humidity sensor
|
||||
updateTempHumidityUI(deviceId, state);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user