Skip to content

Plug lock per device: switch, ask first, or measure only - #191

Open
coasting24 wants to merge 1 commit into
damianeickhoff:mainfrom
coasting24:plug-lock
Open

coasting24 wants to merge 1 commit into
damianeickhoff:mainfrom
coasting24:plug-lock

Conversation

@coasting24

Copy link
Copy Markdown
Contributor

What does this change?

A Plug setting in the card settings (⋯) of every switch and every device card with a switchable plug:

  • switch (default): as before
  • ask first: every switch action opens a confirmation ("Really switch off?") and only switches after "Yes"
  • measure only: the switch button disappears from the popup, the card never switches (a tap then opens the details, whatever "Tap" says), and the timer chips and the power action on appliance cards are hidden. Power, history and running/done stay as they are.

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() and guardPlug() in cards.js: one place that wraps a switch action. It returns null (locked), a confirm popup (ask first) or the action itself, and every switch path goes through it.
  • Uses the existing confirm popup, no new popup type.
  • New setting key plug in cards[<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.js not committed (it is rebuilt with each release)
  • npm run i18n:check passes
  • New user-visible text goes through t() with an English translation (German added too)
  • Tested in the dev page (dev/index.html) and in Home Assistant: locked, the dishwasher popup only shows "Stop programme"; ask first, the coffee maker asks before switch.toggle is called; used in a real Home Assistant on iPad and Mac
  • Screenshots added for visual changes

🤖 Generated with Claude Code

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>
@coasting24

Copy link
Copy Markdown
Contributor Author

Screenshot of the new setting in the card settings (⋯) of a plug, panel in English:

Image

“Measure only” is set here: the popup of this plug no longer shows a switch button, and a tap on the card opens the details.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant