Skip to content

Instantly share code, notes, and snippets.

@CrazyCoder
Created September 1, 2026 16:40
Show Gist options
  • Select an option

  • Save CrazyCoder/42f95292486a604982400f9972c12b3b to your computer and use it in GitHub Desktop.

Select an option

Save CrazyCoder/42f95292486a604982400f9972c12b3b to your computer and use it in GitHub Desktop.
Sengled light switch (Zigbee2MQTT) - Home Assistant blueprint for the Sengled E1E-G7F smart light switch / dimmer
blueprint:
name: Sengled light switch (Zigbee2MQTT)
description: 'Control anything using Sengled E1E-G7F smart light switch / dimmer.
Customizable actions for each press.
Supported actions: on, on_double, on_long, up, up_long, down, down_long, off, off_double, off_long.
Note: up/down actions always trigger before up_long/down_long. This is not the case for on/off actions.
'
domain: automation
input:
controller_device:
name: Sengled Light Switch
description: Select the Sengled E1E-G7F smart light switch device
selector:
device:
filter:
- integration: mqtt
manufacturer: Sengled
model: Smart switch
automation_mode:
name: Automation mode
description: >-
Leave this alone unless an action in this automation runs for longer
than about a second. The device sends several events for one gesture,
about a second apart, and with 'restart' a later event cancels the
action that an earlier event started. A long action belongs in a script
that you call with 'script.turn_on', which no mode can interrupt.
default: queued
selector:
select:
mode: dropdown
options:
- single
- restart
- queued
- parallel
on_press:
name: On press
description: Action to run
default: []
selector:
action: {}
on_double_press:
name: On double press
description: Action to run
default: []
selector:
action: {}
on_long_press:
name: On long press
description: Action to run
default: []
selector:
action: {}
up_press:
name: Up press
description: Action to run
default: []
selector:
action: {}
up_long_press:
name: Up long press
description: Action to run
default: []
selector:
action: {}
down_press:
name: Down press
description: Action to run
default: []
selector:
action: {}
down_long_press:
name: Down long press
description: Action to run
default: []
selector:
action: {}
off_press:
name: Off press
description: Action to run
default: []
selector:
action: {}
off_double_press:
name: Off double press
description: Action to run
default: []
selector:
action: {}
off_long_press:
name: Off long press
description: Action to run
default: []
selector:
action: {}
source_url: https://gist.github.com/CrazyCoder/42f95292486a604982400f9972c12b3b
mode: !input automation_mode
max_exceeded: silent
trigger:
- trigger: device
id: 'on'
domain: mqtt
device_id: !input controller_device
type: action
subtype: 'on'
- trigger: device
id: on_double
domain: mqtt
device_id: !input controller_device
type: action
subtype: on_double
- trigger: device
id: on_long
domain: mqtt
device_id: !input controller_device
type: action
subtype: on_long
- trigger: device
id: up
domain: mqtt
device_id: !input controller_device
type: action
subtype: up
- trigger: device
id: up_long
domain: mqtt
device_id: !input controller_device
type: action
subtype: up_long
- trigger: device
id: down
domain: mqtt
device_id: !input controller_device
type: action
subtype: down
- trigger: device
id: down_long
domain: mqtt
device_id: !input controller_device
type: action
subtype: down_long
- trigger: device
id: 'off'
domain: mqtt
device_id: !input controller_device
type: action
subtype: 'off'
- trigger: device
id: off_double
domain: mqtt
device_id: !input controller_device
type: action
subtype: off_double
- trigger: device
id: off_long
domain: mqtt
device_id: !input controller_device
type: action
subtype: off_long
action:
- choose:
- conditions:
- condition: trigger
id: 'on'
sequence: !input on_press
- conditions:
- condition: trigger
id: on_double
sequence: !input on_double_press
- conditions:
- condition: trigger
id: on_long
sequence: !input on_long_press
- conditions:
- condition: trigger
id: up
sequence: !input up_press
- conditions:
- condition: trigger
id: up_long
sequence: !input up_long_press
- conditions:
- condition: trigger
id: down
sequence: !input down_press
- conditions:
- condition: trigger
id: down_long
sequence: !input down_long_press
- conditions:
- condition: trigger
id: 'off'
sequence: !input off_press
- conditions:
- condition: trigger
id: off_double
sequence: !input off_double_press
- conditions:
- condition: trigger
id: off_long
sequence: !input off_long_press
@CrazyCoder

CrazyCoder commented Sep 1, 2026

Copy link
Copy Markdown
Author

This gist is new. The blueprint file used to declare the Aqara wireless switch gist as its source_url, which was a copy and paste error. Home Assistant fetches source_url when you press Re-import blueprint. A re-import would therefore have replaced this blueprint with the Aqara one, and broken every automation built on it. The source_url now points here.

The blueprint also has a new automation_mode input. The default is queued, which is what the blueprint used before, so an existing automation keeps its behaviour.

Change it only if an action in one branch runs for longer than about a second. One gesture produces several events, and up and down always arrive before up_long and down_long. With restart a later event cancels the action that an earlier event started.

For a long action, call a script with action: script.turn_on and a target:. Home Assistant runs it in its own task, outside the caller's cancellation scope, so no mode can cancel it. script.turn_off still stops it when you want to abort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment