9 months ago
How to rewire Zigbee2MQTT Switches to Be Displayed as Lights in Home Assistant
If you're running Zigbee2MQTT (Z2M) version 2.0+ as a Home Assistant (HASS) addon and want to display your switches as lights in HASS, here's how I rewired my Aqara H1 light switches (no neutral, one single rocker, one double rocker) to achieve this.
ÂWhy Display Switches as Lights?
Displaying switches as lights in HASS makes them more intuitive to manage. For example, you can control them via light groups, use dimmer-style UI controls, or integrate them into "light" automations seamlessly.
ÂMy Setup
Devices
HASS Addon
Zigbee2MQTT running version 2.0+
ÂHere’s the configuration I used to expose my switches as lights.
ÂSingle Rocker Configuration
The following configuration is for the Aqara H1 Single Rocker (Cinema Lightning Bolt Light):
ÂDouble Rocker Configuration
The following configuration is for the Aqara H1 Double Rocker (Office Light Switch):
ÂExplanation
friendly_name: This is the name of your device as it appears in Zigbee2MQTT and Home Assistant.
type: light: Changes the entity type in Home Assistant from switch to light
schema: json: Defines the message payload format for Zigbee2MQTT.
Topics:
state_topic specifies where the current state is published.
command_topic specifies where to send commands to control the device.
Templates:
value_template extracts the current state from the JSON payload.
command_template formats commands sent to the device.
Payloads: payload_on and payload_off define the ON and OFF states.
Testing
Make sure to stop the Zigbee2MQTT addon before editing the configuration.yaml
ÂWhen you save the config, you can start the addon again.
ÂI made these scripts for quickly starting/stopping the addon:
ÂStart
Stop
You can find the addon slug in the URL when you open the addon in home assistant.
ÂFinal Thoughts
With these configurations, my Aqara H1 switches now act like native light entities in Home Assistant. This makes automation smoother and more intuitive. If you're dealing with other Zigbee switches, this process can easily be adapted.
ÂHappy automating!
Â