Skip to content

Instantly share code, notes, and snippets.

@PiotrKrzyzek
Last active April 28, 2024 19:22
Show Gist options
  • Save PiotrKrzyzek/bbe831c42f4fa2f833f0c4fcfc6ea8d6 to your computer and use it in GitHub Desktop.
Save PiotrKrzyzek/bbe831c42f4fa2f833f0c4fcfc6ea8d6 to your computer and use it in GitHub Desktop.
Home Assistant Blueprint For Tuya 4-gang Zigbee Integration via ZHA
blueprint:
name: ZHA - Tuya 4-Button Scene Switch
description: Automate your Tuya 4-Button Scene Switch via ZHA.
domain: automation
input:
switch:
name: Tuya Zigbee Switch
description: Tuya 4-Button Scene Switch to use
selector:
device:
integration: zha
model: TS0044
single_press_1:
name: Single Press - Button 1
description: Action to run on button 1 (upper-left) single press
default: []
selector:
action: {}
long_press_1:
name: Hold - Button 1
description: Action to run on button 1 (upper-left) single press
default: []
selector:
action: {}
double_press_1:
name: Double Press - Button 1
description: Action to run on button 1 (upper-left) single press
default: []
selector:
action: {}
single_press_2:
name: Single Press - Button 2
description: Action to run on button 2 (lower-right) single press
default: []
selector:
action: {}
long_press_2:
name: Hold - Button 2
description: Action to run on button 2 (upper-right) single press
default: []
selector:
action: {}
double_press_2:
name: Double Press - Button 2
description: Action to run on button 2 (upper-right) single press
default: []
selector:
action: {}
single_press_3:
name: Single Press - Button 3
description: Action to run on button 3 (lower-left) single press
default: []
selector:
action: {}
long_press_3:
name: Hold - Button 3
description: Action to run on button 3 (lower-left) long press
default: []
selector:
action: {}
double_press_3:
name: Double Press - Button 3
description: Action to run on button 3 (lower-left) long press
default: []
selector:
action: {}
single_press_4:
name: Single Press - Button 4
description: Action to run on button 4 (lower-right) single press
default: []
selector:
action: {}
long_press_4:
name: Hold - Button 4
description: Action to run on button 4 (lower-right) long press
default: []
selector:
action: {}
double_press_4:
name: Double Press - Button 4
description: Action to run on button 4 (lower-right) long press
default: []
selector:
action: {}
source_url: https://gist.githubusercontent.com/PiotrKrzyzek/bbe831c42f4fa2f833f0c4fcfc6ea8d6/raw/d6720efdf486db3524b7d55432a8815f46ff6726/tuya_4gang_zha_blueprint.yaml
mode: parallel
max_exceeded: silent
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input switch
action:
- variables:
command: '{{ trigger.event.data.command }}'
cluster_id: '{{ trigger.event.data.cluster_id }}'
endpoint_id: '{{ trigger.event.data.endpoint_id }}'
- choose:
- conditions:
- '{{ command == ''remote_button_short_press'' }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 1 }}'
sequence: !input single_press_1
- conditions:
- '{{ command == ''remote_button_short_press'' }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 2 }}'
sequence: !input single_press_2
- conditions:
- '{{ command == ''remote_button_short_press'' }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 3 }}'
sequence: !input single_press_3
- conditions:
- '{{ command == ''remote_button_short_press'' }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 4 }}'
sequence: !input single_press_4
- conditions:
- '{{ command == ''remote_button_double_press'' }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 1 }}'
sequence: !input double_press_1
- conditions:
- '{{ command == ''remote_button_double_press'' }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 2 }}'
sequence: !input double_press_2
- conditions:
- '{{ command == ''remote_button_double_press'' }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 3 }}'
sequence: !input double_press_3
- conditions:
- '{{ command == ''remote_button_double_press'' }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 4 }}'
sequence: !input double_press_4
- conditions:
- '{{ command == ''remote_button_long_press'' }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 1 }}'
sequence: !input long_press_1
- conditions:
- '{{ command == ''remote_button_long_press'' }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 2 }}'
sequence: !input long_press_2
- conditions:
- '{{ command == ''remote_button_long_press'' }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 3 }}'
sequence: !input long_press_3
- conditions:
- '{{ command == ''remote_button_long_press'' }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 4 }}'
sequence: !input long_press_4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment