To keep the lights controllable if Home Assistant fails, commands from wall switches must be handled locally—inside the relay, controller, or Zigbee device link. Home Assistant should be used for automations, schedules, and remote control, but not as a required intermediary between the user and the light.
What Exactly Must Survive a Failure
First, define the fault-tolerance boundary. For lighting, the practical goal usually looks like this:
- the wall button or switch works while Home Assistant is stopped;
- the light can be turned on and off when the server, database, or integration is unavailable;
- after the controller restarts, the relay enters a predefined safe state;
- automations may temporarily stop working, but manual control remains available.
A power outage is a separate issue. If the lamp, relay, or switch has no power, software architecture cannot help. A UPS can be used for network equipment and the controller, but it does not replace local load control.
Preferred Design: The Switch Controls the Relay Directly
The most reliable option is a relay with a dedicated input for a wall button or switch. The device itself processes the physical input, while Home Assistant only reads the state and sends additional commands.
The logical chain should work as follows:
- The wall button is connected to the relay’s control input.
- The relay changes the output state itself when the input changes.
- The lamp is connected to the relay’s load output.
- Home Assistant connects to the relay through a local protocol and does not participate in processing the button press.
A design in which the wall switch exists only as a sensor and the light is turned on by an automation such as “sensor changed—send a command to the relay” is not suitable. When Home Assistant stops, that chain is broken.
Work involving mains voltage must be performed by a qualified professional. Before purchasing a relay, verify the wiring layout, the presence of a neutral conductor in the wall box, the permitted load power, and the device’s compatibility with the specific type of lamps.
Step 1. Identify the Type of Wall Control
A momentary button closes the contact only while it is being pressed. A standard maintained wall switch retains its position. The controller must support the corresponding input mode. Mode names vary by manufacturer: pulse input, edge-triggered switching, push-button mode, or maintained switch mode.
Do not select a mode based only on a similar-sounding name. Check the documentation for the specific device and confirm that changes to the physical input are processed locally, without the cloud or an external automation.
Step 2. Verify Standalone Operation Before Connecting Home Assistant
After installation, do not add the device to Home Assistant immediately. Apply power and verify that the wall button turns the lamp on and off several times. Then power-cycle the relay and repeat the test.
If the button does not work without Home Assistant, the architecture already fails to meet the requirement. Adding a backup automation is pointless because both automations would depend on the same server.
Step 3. Configure Behavior After Power Is Restored
Relays typically support one of several behaviors: always off, always on, restore the previous state, or follow the physical input. The exact options depend on the firmware and model.
For most rooms, the off state is safer. Corridors, utility rooms, or staircases may have different requirements. Choose the mode in advance and verify it by actually removing and restoring power.
Step 4. Add the Device to Home Assistant
After confirming standalone operation, connect the relay through a supported local integration. Home Assistant should display the relay state and, where supported, the physical input state.
Home Assistant automations can turn lights off on a schedule, account for occupancy, or create scenes. The physical button must still continue to control the relay independently of the server.
Zigbee Option: Bind the Switch Directly to a Lamp or Group
Zigbee provides a binding mechanism that allows a source device to send commands directly to a target device or group. For lighting, this makes it possible to link a wireless button to one or more lamps without processing every press in Home Assistant.
A practical sequence for Zigbee2MQTT:
- Add the switch and lamp to the same Zigbee network.
- Confirm that the lamp responds correctly to normal commands.
- Open the bindings section for the switch device in the Zigbee2MQTT interface.
- Select the lamp or a previously created group as the binding target.
- Create a binding for the supported lighting control cluster.
- Stop Home Assistant and the automation process, then test a single press, turning the light off, and brightness adjustment if it is used.
The available bindings depend on the capabilities of the specific Zigbee devices. Not every button supports sending commands directly, and some models only report events to the coordinator. Before purchasing, check the device page in the documentation for the Zigbee stack you use.
For multiple lamps, binding to a Zigbee group is preferable. It reduces the risk of state desynchronization compared with sending separate commands to each lamp sequentially. However, group operation must also be tested while Home Assistant is stopped.
Limitation of the Zigbee Design
Direct Zigbee binding removes the dependency on Home Assistant, but it does not make the system independent of device power or the state of the Zigbee network. Do not combine server failure, coordinator shutdown, loss of power to router devices, and a depleted button battery into a single test. Test each failure separately.
ESPHome Option: Local Automation Inside the Controller
If the relay is built around a compatible microcontroller, button handling can be placed in the ESPHome configuration. The controller then switches the output itself, while Home Assistant connects to an already functional entity.
The following is a template for a momentary button. Do not copy the pin values without checking the schematic for the specific board.
switch:
- platform: gpio
id: light_relay
name: "Light Relay"
pin: <RELAY_GPIO>
restore_mode: RESTORE_DEFAULT_OFF
binary_sensor:
platform: gpio
id: wall_button
pin:
number:
mode:
input: true
pullup: true
inverted: true
on_press:
switch.toggle: light_relay
In this example, the switch.toggle action is executed by the device itself. A maintained wall switch requires different input logic. Do not reuse a momentary-button configuration for a maintained switch without checking its behavior in both positions and after a restart.
After flashing the device, perform four checks:
- Stop Home Assistant while keeping the controller and lamp powered.
- Press the button several times and confirm that the relay switches.
- Disable Wi-Fi or the access point and repeat the test.
- Power-cycle the controller and verify the configured output restore mode.
The exact board parameters, GPIO assignments, and electrical input characteristics depend on the hardware. Use the manufacturer’s schematic for these details. There is no universally safe GPIO number.
What Does Not Count as Backup Control
- A second automation in Home Assistant. It runs in the same process and fails with it.
- A separate dashboard. The interface does not help if the server or integration is unavailable.
- The manufacturer’s mobile app through the cloud. It depends on internet access, the cloud service, and the user account.
- MQTT without separate infrastructure. If the broker runs on the same host, its failure may occur together with the Home Assistant failure.
- A UPS without local logic. A UPS extends server uptime but does not remove the software dependency between the switch and the automation.
Step-by-Step Fault-Tolerance Test
Run the test after completing the setup and after significant changes to firmware, integrations, or the Zigbee network.
- Record the initial state: which lamps are on and which are off.
- Shut down Home Assistant cleanly.
- Test each wall switch separately.
- Test turning the light on, turning it off, and holding the button if brightness control is used.
- Disconnect the local network or Wi-Fi without removing power from the relay, then repeat the wired-input test.
- Restore the network, start Home Assistant, and confirm that the actual light state is displayed correctly.
- Remove and restore power to the controller, then compare the result with the selected restore policy.
| Scenario | Expected Result |
|---|---|
| Home Assistant is stopped | Wall switches continue to control the lights |
| The local network is unavailable | The relay’s wired input continues to work |
| Automations are disabled | Manual control remains unchanged |
| The controller is restarted | The output enters the predefined state |
| Home Assistant is started again | The interface shows the relay’s actual state |
Final Checklist
- There is no mandatory Home Assistant automation between the wall switch and the lamp.
- The physical input is processed by the relay or local firmware.
- Direct binding is configured and tested for a wireless Zigbee switch.
- A safe output state has been selected for power restoration.
- The device has been tested while Home Assistant is not running.
- Wired control has been tested while the local network is disconnected.
- After the server is restored, the light state synchronizes correctly.
- The wiring diagram, device model, and backup control method are documented.