window contact first try
This commit is contained in:
@@ -386,7 +386,45 @@
|
||||
transform: scale(0.95);
|
||||
}
|
||||
|
||||
|
||||
/* Contact Sensor Styles */
|
||||
.contact-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 1rem;
|
||||
background: #f8f9fa;
|
||||
border-radius: 8px;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
.contact-badge {
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 6px;
|
||||
font-weight: 600;
|
||||
font-size: 0.875rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.contact-badge.open {
|
||||
background: #dc3545;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.contact-badge.closed {
|
||||
background: #28a745;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.contact-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;
|
||||
@@ -483,6 +521,8 @@
|
||||
{% if device.features.brightness %}• Dimmbar{% endif %}
|
||||
{% elif device.type == "thermostat" %}
|
||||
Thermostat
|
||||
{% elif device.type == "contact" or device.type == "contact_sensor" %}
|
||||
Contact Sensor • Read-Only
|
||||
{% else %}
|
||||
{{ device.type or "Unknown" }}
|
||||
{% endif %}
|
||||
@@ -555,6 +595,18 @@
|
||||
+1.0
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{% elif device.type == "contact" or device.type == "contact_sensor" %}
|
||||
<div class="contact-status">
|
||||
<span class="contact-badge closed" id="state-{{ device.device_id }}">
|
||||
Geschlossen
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="contact-info">
|
||||
🔒 Nur-Lesen Gerät • Keine Steuerung möglich
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
@@ -852,6 +904,24 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Update contact sensor UI
|
||||
function updateContactUI(deviceId, contactState) {
|
||||
const badge = document.getElementById(`state-${deviceId}`);
|
||||
if (!badge) {
|
||||
console.warn(`No contact badge found for device ${deviceId}`);
|
||||
return;
|
||||
}
|
||||
|
||||
// contactState is either "open" or "closed"
|
||||
if (contactState === "open") {
|
||||
badge.textContent = "Geöffnet";
|
||||
badge.className = "contact-badge open";
|
||||
} else if (contactState === "closed") {
|
||||
badge.textContent = "Geschlossen";
|
||||
badge.className = "contact-badge closed";
|
||||
}
|
||||
}
|
||||
|
||||
// Add event to list
|
||||
function addEvent(event) {
|
||||
const eventList = document.getElementById('event-list');
|
||||
@@ -917,6 +987,11 @@
|
||||
data.payload.target
|
||||
);
|
||||
}
|
||||
|
||||
// Check if it's a contact sensor
|
||||
if (data.payload.contact !== undefined) {
|
||||
updateContactUI(data.device_id, data.payload.contact);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1035,6 +1110,9 @@
|
||||
// It's a thermostat
|
||||
if (state.target) thermostatTargets[deviceId] = state.target;
|
||||
updateThermostatUI(deviceId, state.current, state.target);
|
||||
} else if (state.contact !== undefined) {
|
||||
// It's a contact sensor
|
||||
updateContactUI(deviceId, state.contact);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user