There are switches that do power monitoring and enable you also turn on and off the power.
If I want to monitor the power usage of a fridge, then I don’t want to have the ability to turn on and off the device remotely. To do so introduces a lot of risks.
So it would be a feature to be able to “lock” a switch on which prevents it from being turned off.
One option would be to put in an automation that repeatedly says, turn on, but that’s a bit hacky.
I have mine set up to require a PIN if the global lock input boolean is on. This way I can switch all restrictions off (this is protected by a PIN too) if I’m doing a lot of fiddling with locked controls.
You can apply it to a whole card or to a row:
- card:
entity: switch.rumpus_dehumidifier
name: Rumpus Dehumidifier Power Monitor
condition:
entity: input_boolean.unlock_restrictions
value: 'off'
restrictions:
pin:
code: 1234 # not my PIN :)
row: true
type: custom:restriction-card
FWIW, there’s another way to lock a switch on if the switch is running Tasmota.
The PowerOnState command defines how the device behaves on startup.
Control relay state after powering up the device.
0 / OFF = keep relay(s) OFF after power up
1 / ON = turn relay(s) ON after power up
2 / TOGGLE = toggle relay(s) from last saved state
3 = switch relay(s) to their last saved state (default) 4 = turn relay(s) ON and disable further relay control
5 = after a PulseTime period turn relay(s) ON (acts as inverted PulseTime mode)
Option 4 blocks commands to control the switch’s relay. This would be useful for a switch whose sole purpose is for monitoring power consumption of a refrigerator but should never be turned off.
I use the combination of conditional, vertikal stack (not necessary) and tile cards. The tile cards offer to disable the tap-actions, so you can have a “read-only” switch.
If the input_boolean unlock_restriction_power_garden is off, the tile card with no action is displayed (in a vertikal stack). If it’s on, the other tile card with standard tap-actions behavior is visible.