drop mode from thermostat ui
This commit is contained in:
@@ -358,27 +358,6 @@
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.mode-display {
|
||||
background: #f8f9fa;
|
||||
border-radius: 8px;
|
||||
padding: 0.75rem;
|
||||
text-align: center;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.mode-label {
|
||||
font-size: 0.75rem;
|
||||
color: #666;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.mode-value {
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
color: #667eea;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.temp-controls {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
@@ -568,11 +547,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mode-display">
|
||||
<div class="mode-label">Modus</div>
|
||||
<div class="mode-value" id="state-{{ device.device_id }}-mode">OFF</div>
|
||||
</div>
|
||||
|
||||
<div class="temp-controls">
|
||||
<button class="temp-button" onclick="adjustTarget('{{ device.device_id }}', -1.0)">
|
||||
-1.0
|
||||
@@ -707,7 +681,6 @@
|
||||
let eventSource = null;
|
||||
let currentState = {};
|
||||
let thermostatTargets = {};
|
||||
let thermostatModes = {};
|
||||
|
||||
// Initialize device states
|
||||
{% for room in rooms %}
|
||||
@@ -716,7 +689,6 @@
|
||||
currentState['{{ device.device_id }}'] = 'off';
|
||||
{% elif device.type == "thermostat" %}
|
||||
thermostatTargets['{{ device.device_id }}'] = 21.0;
|
||||
thermostatModes['{{ device.device_id }}'] = 'off';
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
@@ -792,11 +764,10 @@
|
||||
// Adjust thermostat target temperature
|
||||
async function adjustTarget(deviceId, delta) {
|
||||
const currentTarget = thermostatTargets[deviceId] || 21.0;
|
||||
const currentMode = thermostatModes[deviceId] || 'off';
|
||||
const newTarget = Math.max(5.0, Math.min(30.0, currentTarget + delta));
|
||||
|
||||
try {
|
||||
const response = await fetch(api(`/devices/${deviceId}/set`), {
|
||||
const response = await fetch('/api/device/set', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -804,7 +775,6 @@
|
||||
body: JSON.stringify({
|
||||
type: 'thermostat',
|
||||
payload: {
|
||||
mode: currentMode,
|
||||
target: newTarget
|
||||
}
|
||||
})
|
||||
@@ -869,7 +839,6 @@
|
||||
function updateThermostatUI(deviceId, current, target, mode) {
|
||||
const currentSpan = document.getElementById(`state-${deviceId}-current`);
|
||||
const targetSpan = document.getElementById(`state-${deviceId}-target`);
|
||||
const modeSpan = document.getElementById(`state-${deviceId}-mode`);
|
||||
|
||||
if (current !== undefined && currentSpan) {
|
||||
currentSpan.textContent = current.toFixed(1);
|
||||
@@ -881,13 +850,6 @@
|
||||
}
|
||||
thermostatTargets[deviceId] = target;
|
||||
}
|
||||
|
||||
if (mode !== undefined) {
|
||||
if (modeSpan) {
|
||||
modeSpan.textContent = mode.toUpperCase();
|
||||
}
|
||||
thermostatModes[deviceId] = mode;
|
||||
}
|
||||
}
|
||||
|
||||
// Add event to list
|
||||
@@ -945,18 +907,14 @@
|
||||
}
|
||||
|
||||
// Check if it's a thermostat
|
||||
if (data.payload.mode !== undefined || data.payload.target !== undefined || data.payload.current !== undefined) {
|
||||
if (data.payload.mode !== undefined) {
|
||||
thermostatModes[data.device_id] = data.payload.mode;
|
||||
}
|
||||
if (data.payload.target !== undefined || data.payload.current !== undefined) {
|
||||
if (data.payload.target !== undefined) {
|
||||
thermostatTargets[data.device_id] = data.payload.target;
|
||||
}
|
||||
updateThermostatUI(
|
||||
data.device_id,
|
||||
data.payload.current,
|
||||
data.payload.target,
|
||||
data.payload.mode
|
||||
data.payload.target
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1073,11 +1031,10 @@
|
||||
// It's a light
|
||||
currentState[deviceId] = state.power;
|
||||
updateDeviceUI(deviceId, state.power, state.brightness);
|
||||
} else if (state.mode !== undefined || state.target !== undefined) {
|
||||
} else if (state.target !== undefined) {
|
||||
// It's a thermostat
|
||||
if (state.mode) thermostatModes[deviceId] = state.mode;
|
||||
if (state.target) thermostatTargets[deviceId] = state.target;
|
||||
updateThermostatUI(deviceId, state.current, state.target, state.mode);
|
||||
updateThermostatUI(deviceId, state.current, state.target);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user