Skip to content

Instantly share code, notes, and snippets.

@CrazyCoder
Last active February 18, 2024 10:42
Show Gist options
  • Save CrazyCoder/04c35375d9ef0ad0e0af69c126638834 to your computer and use it in GitHub Desktop.
Save CrazyCoder/04c35375d9ef0ad0e0af69c126638834 to your computer and use it in GitHub Desktop.
Sengled light switch (Zigbee2MQTT)
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:
action_sensor:
name: Sengled Action Sensor
description: Zigbee2mqtt action sensor for Sengled E1E-G7F
selector:
entity:
integration: mqtt
domain: sensor
multiple: false
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/04c35375d9ef0ad0e0af69c126638834
mode: restart
max_exceeded: silent
trigger:
platform: state
entity_id: !input action_sensor
condition:
- condition: template
value_template: '{{ trigger.to_state.state in ("on","on_double","on_long","up","up_long","down","down_long","off","off_double","off_long") }}'
action:
- variables:
command: '{{ trigger.to_state.state }}'
- choose:
- conditions:
- '{{ command == ''on'' }}'
sequence: !input on_press
- conditions:
- '{{ command == ''on_double'' }}'
sequence: !input on_double_press
- conditions:
- '{{ command == ''on_long'' }}'
sequence: !input on_long_press
- conditions:
- '{{ command == ''up'' }}'
sequence: !input up_press
- conditions:
- '{{ command == ''up_long'' }}'
sequence: !input up_long_press
- conditions:
- '{{ command == ''down'' }}'
sequence: !input down_press
- conditions:
- '{{ command == ''down_long'' }}'
sequence: !input down_long_press
- conditions:
- '{{ command == ''off'' }}'
sequence: !input off_press
- conditions:
- '{{ command == ''off_double'' }}'
sequence: !input off_double_press
- conditions:
- '{{ command == ''off_long'' }}'
sequence: !input off_long_press
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment