Skip to content

Instantly share code, notes, and snippets.

@julienma
Last active January 22, 2026 12:57
Show Gist options
  • Select an option

  • Save julienma/f0b91992d2c89ca3852a77dc2ddc34eb to your computer and use it in GitHub Desktop.

Select an option

Save julienma/f0b91992d2c89ca3852a77dc2ddc34eb to your computer and use it in GitHub Desktop.
Home Assistant blueprint for Sonoff MINI-ZB2GS & MINI-ZB2GS-L detached relay mode
blueprint:
name: Sonoff MINI-ZB2GS / MINI-ZB2GS-L detached relay mode
description: >
Use the Zigbee2MQTT device trigger payload (toggle_l1 / toggle_l2).
If relay is OFF: turn relay ON, wait briefly, then turn target ON.
If relay is ON: toggle target.
domain: automation
author: Adapted for MINI-ZB2GS
input:
zb2gs_device:
name: MINI-ZB2GS device
description: SONOFF MINI-ZB2GS / MINI-ZB2GS-L in Zigbee2MQTT
selector:
device:
filter:
- manufacturer: SONOFF
model: Zigbee dual-channel smart switch
- manufacturer: SONOFF
model: MINI-ZB2GS
- manufacturer: SONOFF
model: MINI-ZB2GS-L
multiple: false
switch_l1:
name: Relay switch entity L1
description: Relay entity for channel L1
selector:
entity:
filter:
domain: switch
multiple: false
switch_l2:
name: Relay switch entity L2
description: Relay entity for channel L2
selector:
entity:
filter:
domain: switch
multiple: false
target_l1:
name: Target(s) controlled by L1
selector:
target:
entity:
domain:
- light
- switch
target_l2:
name: Target(s) controlled by L2
selector:
target:
entity:
domain:
- light
- switch
triggers:
- domain: mqtt
device_id: !input zb2gs_device
type: action
subtype: toggle_l1
trigger: device
- domain: mqtt
device_id: !input zb2gs_device
type: action
subtype: toggle_l2
trigger: device
variables:
action: "{{ trigger.payload | default('', true) }}"
relay_l1: !input switch_l1
relay_l2: !input switch_l2
actions:
- choose:
# -------- L1 --------
- conditions:
- condition: template
value_template: "{{ action == 'toggle_l1' }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ is_state(relay_l1, 'off') }}"
sequence:
- service: switch.turn_on
target:
entity_id: !input switch_l1
- delay: "00:00:00.200"
- service: homeassistant.turn_on
target: !input target_l1
default:
- service: homeassistant.toggle
target: !input target_l1
# -------- L2 --------
- conditions:
- condition: template
value_template: "{{ action == 'toggle_l2' }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ is_state(relay_l2, 'off') }}"
sequence:
- service: switch.turn_on
target:
entity_id: !input switch_l2
- delay: "00:00:00.200"
- service: homeassistant.turn_on
target: !input target_l2
default:
- service: homeassistant.toggle
target: !input target_l2
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment