This kind of devices handles JSON payloads in the MQTT, so this is a working configuration to have, in this case, 4 switches in HA to controll each one of the 4 channel of the device.
Prerequisites:
- Have a Zigbee dongle
- Install Zigbee2MQTT library (as an HA addon or in the Pi o wherever)
- Have the Zigbee device paired
- Test that the MQTT messages are working
Since the payloads that handle this device are:
{
"linkquality":128,
"state":"OFF",
"state_l1":"OFF",
"state_l2":"ON",
"state_l3":"OFF",
"state_l4":"OFF"
}
We need to be able to have a switch that will control each property of that JSON (all but the signal strength for this matter), and also to be able to update the state of each switch if it changes (from the HA itself, or from other MQTT trigger or even the device switch gets pushed).
So in the configuration.yaml you should add:
switch:
- platform: mqtt
name: "mqttGang1l1"
state_topic: "zigbee2mqtt/THE_DEVICE_NAME" # Topic to read the current state
command_topic: "zigbee2mqtt/THE_DEVICE_NAME/set" # Topic to publish commands
qos: 1
retain: false # or false if you want to wait for changes
optimistic: false # assume that message was received by the device
value_template: "{{ value_json.state_l1 }}"
payload_on: '{"state_l1": "ON"}'
payload_off: '{"state_l1": "OFF"}'
state_on: 'ON'
state_off: 'OFF'
- platform: mqtt
name: "mqttGang1l2"
state_topic: "zigbee2mqtt/THE_DEVICE_NAME" # Topic to read the current state
command_topic: "zigbee2mqtt/THE_DEVICE_NAME/set" # Topic to publish commands
qos: 1
retain: false # or false if you want to wait for changes
optimistic: false # assume that message was received by the device
value_template: "{{ value_json.state_l2 }}"
payload_on: '{"state_l2": "ON"}'
payload_off: '{"state_l2": "OFF"}'
state_on: 'ON'
state_off: 'OFF'
- platform: mqtt
name: "mqttGang1l3"
state_topic: "zigbee2mqtt/THE_DEVICE_NAME" # Topic to read the current state
command_topic: "zigbee2mqtt/THE_DEVICE_NAME/set" # Topic to publish commands
qos: 1
retain: false # or false if you want to wait for changes
optimistic: false # assume that message was received by the device
value_template: "{{ value_json.state_l3 }}"
payload_on: '{"state_l3": "ON"}'
payload_off: '{"state_l3": "OFF"}'
state_on: 'ON'
state_off: 'OFF'
- platform: mqtt
name: "mqttGang1l4"
state_topic: "zigbee2mqtt/THE_DEVICE_NAME" # Topic to read the current state
command_topic: "zigbee2mqtt/THE_DEVICE_NAME/set" # Topic to publish commands
qos: 1
retain: false # or false if you want to wait for changes
optimistic: false # assume that message was received by the device
value_template: "{{ value_json.state_l4 }}"
payload_on: '{"state_l4": "ON"}'
payload_off: '{"state_l4": "OFF"}'
state_on: 'ON'
state_off: 'OFF'