diff --git a/apps/ui/templates/garage.html b/apps/ui/templates/garage.html index 638063a..1d705c7 100644 --- a/apps/ui/templates/garage.html +++ b/apps/ui/templates/garage.html @@ -407,7 +407,10 @@ const toggleSwitch = document.createElement('button'); toggleSwitch.className = `toggle-switch ${currentPower ? 'on' : ''}`; - toggleSwitch.onclick = () => toggleOutlet(device.device_id, currentPower ? 'off' : 'on'); + toggleSwitch.onclick = () => { + const currentState = deviceStates[device.device_id]?.power === 'on'; + toggleOutlet(device.device_id, currentState ? 'off' : 'on'); + }; const label = document.createElement('div'); label.className = 'toggle-label';