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