thermostat working
This commit is contained in:
@@ -523,6 +523,7 @@
|
||||
let eventSource = null;
|
||||
let currentState = {};
|
||||
let thermostatTargets = {};
|
||||
let thermostatModes = {};
|
||||
|
||||
// Initialize device states
|
||||
{% for room in rooms %}
|
||||
@@ -531,6 +532,7 @@
|
||||
currentState['{{ device.device_id }}'] = 'off';
|
||||
{% elif device.type == "thermostat" %}
|
||||
thermostatTargets['{{ device.device_id }}'] = 21.0;
|
||||
thermostatModes['{{ device.device_id }}'] = 'off';
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
@@ -606,6 +608,7 @@
|
||||
// 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 {
|
||||
@@ -617,6 +620,7 @@
|
||||
body: JSON.stringify({
|
||||
type: 'thermostat',
|
||||
payload: {
|
||||
mode: currentMode,
|
||||
target: newTarget
|
||||
}
|
||||
})
|
||||
@@ -725,8 +729,11 @@
|
||||
thermostatTargets[deviceId] = target;
|
||||
}
|
||||
|
||||
if (mode !== undefined && modeSpan) {
|
||||
modeSpan.textContent = mode.toUpperCase();
|
||||
if (mode !== undefined) {
|
||||
if (modeSpan) {
|
||||
modeSpan.textContent = mode.toUpperCase();
|
||||
}
|
||||
thermostatModes[deviceId] = mode;
|
||||
|
||||
// Update mode button states
|
||||
['off', 'heat', 'auto'].forEach(m => {
|
||||
|
||||
Reference in New Issue
Block a user