Skip to content

Instantly share code, notes, and snippets.

@haade-administrator
Last active December 2, 2023 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haade-administrator/85e9ec76c36469806bf47ceb726d6632 to your computer and use it in GitHub Desktop.
Save haade-administrator/85e9ec76c36469806bf47ceb726d6632 to your computer and use it in GitHub Desktop.
Automate Sonoff SNZB-01P switch with blueprint for Home Assistant
blueprint:
name: ZHA - Sonoff SNZB-01P
description: 'Perform actions with the Sonoff SNZB-01P Button.
You can set functions for single press, double press and hold. This allows you to assign,
e.g., a scene or anything else.'
domain: automation
input:
remote:
name: Remote
description: Sonoff Button to use
selector:
device:
integration: zha
manufacturer: eWeLink
model: SNZB-01P
single_press:
name: Single press
description: Action to run on single press
default: []
selector:
action: {}
double_press:
name: Double press
description: Action to run on double press
default: []
selector:
action: {}
hold:
name: Hold
description: Action to run on hold
default: []
selector:
action: {}
source_url: https://gist.github.com/haade-administrator/85e9ec76c36469806bf47ceb726d6632
mode: restart
max_exceeded: silent
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input 'remote'
action:
- variables:
command: '{{ trigger.event.data.command }}'
cluster_id: '{{ trigger.event.data.cluster_id }}'
endpoint_id: '{{ trigger.event.data.endpoint_id }}'
- choose:
- conditions:
- '{{ command == "toggle" }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 1 }}'
sequence: !input 'single_press'
- conditions:
- '{{ command == "on" }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 1 }}'
sequence: !input 'double_press'
- conditions:
- '{{ command == "off" }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 1 }}'
sequence: !input 'hold'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment