Repository navigation
Plug lock per device: switch, ask first, or measure only - #191
Open
coasting24 wants to merge 1 commit into
Open
coasting24 wants to merge 1 commit into
coasting24 wants to merge 1 commit into
Conversation
Some smart plugs only measure (a fridge, a freezer, a server). A "Plug" setting in the card settings of every switch and every device card with a switchable plug: switch (default), ask first (a confirmation before every switch action) or measure only (no switch button, the card never switches, timer chips and the power action hidden). It applies wherever the panel switches that plug; a device card and its switch: the stricter one wins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What does this change?
A Plug setting in the card settings (⋯) of every switch and every device card with a switchable plug:
The setting applies wherever HaCasa switches that plug: the plug card, the switch card, the device and switch popups, and a single socket of a power strip. When the same switch shows up as a device card and as a switch, the stricter of the two settings wins.
Implementation
plugMode()andguardPlug()incards.js: one place that wraps a switch action. It returnsnull(locked), a confirm popup (ask first) or the action itself, and every switch path goes through it.confirmpopup, no new popup type.plugincards[<id>]. Missing means the current behaviour, so no migration is needed.This only guards HaCasa itself. Automations, voice assistants and other dashboards can still switch the plug.
Why?
Some smart plugs are only there to measure: a fridge, a freezer, a server or an aquarium pump. Switching one of them off by accident can do real damage, and today a single tap does it: on the card (when "Tap" is set to switch) or on the big "Plug off" button in the device popup, which is always shown and never asks.
Checklist
dist/hacasa-nova.jsnot committed (it is rebuilt with each release)npm run i18n:checkpassest()with an English translation (German added too)dev/index.html) and in Home Assistant: locked, the dishwasher popup only shows "Stop programme"; ask first, the coffee maker asks beforeswitch.toggleis called; used in a real Home Assistant on iPad and Mac🤖 Generated with Claude Code