Skip to content

Instantly share code, notes, and snippets.

@tetele
Last active August 12, 2022 12:23
Show Gist options
  • Save tetele/66b620677bcf0f09caa38e5d940fd6b7 to your computer and use it in GitHub Desktop.
Save tetele/66b620677bcf0f09caa38e5d940fd6b7 to your computer and use it in GitHub Desktop.
Immax NEO remote control 07087-2 ZHA custom quirk

ZHA custom quirk and automation blueprints for Immax NEO remote control 07087-2

ZHA custom quirk which exposes button actions in automations for the Zigbee remote control. There are 7 triggers that will be exposed when using the quirk:

  • short press ON
  • short press OFF
  • short press +
  • short press -
  • long press and hold +
  • long press and hold -
  • release + or - after holding them

The remote is also known as TS1001 by _TYZB01_7qf81wty

Installation

  1. Add _TYZB01_7qf81wty_TS1001.py to your custom quirks folder using the custom_quirks_path configuration variable.
  2. Restart HA
  3. (possibly optional) Re-add your remote(s) in ZHA
  4. At this point you can create manual automations using the 7 triggers mentioned
    • Install blueprint for binding actions directly to the 7 triggers Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.
    • Install blueprint for controlling dimmable lights with the remote control Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Credits

The blueprints are heavily inspired from this one, which unfortunately stopped working after HA 2022.4.

"""Immax NEO 07087-2 remote control"""
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
# Alarms,
Basic,
PowerConfiguration,
Identify,
Groups,
Scenes,
OnOff,
LevelControl,
Time,
Ota,
)
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
BUTTON,
COMMAND,
COMMAND_ON,
COMMAND_OFF,
COMMAND_MOVE,
COMMAND_STEP,
COMMAND_STOP,
DEVICE_TYPE,
DIM_DOWN,
DIM_UP,
ENDPOINTS,
INPUT_CLUSTERS,
LONG_PRESS,
LONG_RELEASE,
MODEL,
MODELS_INFO,
OUTPUT_CLUSTERS,
PARAMS,
PROFILE_ID,
SHORT_PRESS,
TURN_ON,
TURN_OFF,
)
from zhaquirks.tuya import (
TuyaDimmerSwitch,
TuyaOnOff,
)
class ImmaxNeo07087_2(TuyaDimmerSwitch):
"""Immax NEO 07087-2 remote control with triggers."""
signature = {
MODELS_INFO: [("_TYZB01_7qf81wty", "TS1001")],
ENDPOINTS: {
# Endpoint id=1
# in=[basic:0x0000, power:0x0001, identify:0x0003, groups:0x0004, lightlink:0x1000]
# out=[ota:0x0019, time:0x000A, identify:0x0003, groups:0x0004, scenes:0x0005, on_off:0x0006, level:0x0008, lightlink:0x1000]
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMER_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id, # 0x0000
PowerConfiguration.cluster_id, # 0x0001
Identify.cluster_id, # 0x0003
Groups.cluster_id, # 0x0004
LightLink.cluster_id, # 0x1000
],
OUTPUT_CLUSTERS: [
Ota.cluster_id, # 0x0019
Time.cluster_id, # 0x000a
Identify.cluster_id, # 0x0003
Groups.cluster_id, # 0x0004
Scenes.cluster_id, # 0x0005
OnOff.cluster_id, # 0x0006
LevelControl.cluster_id, # 0x0008
LightLink.cluster_id, # 0x1000
],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMER_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id, # 0x0000
PowerConfiguration.cluster_id, # 0x0001
Identify.cluster_id, # 0x0003
Groups.cluster_id, # 0x0004
LightLink.cluster_id, # 0x1000
],
OUTPUT_CLUSTERS: [
Ota.cluster_id, # 0x0019
Time.cluster_id, # 0x000a
Identify.cluster_id, # 0x0003
Groups.cluster_id, # 0x0004
Scenes.cluster_id, # 0x0005
TuyaOnOff,
LevelControl.cluster_id, # 0x0008
LightLink.cluster_id, # 0x1000
],
},
},
}
device_automation_triggers = {
(SHORT_PRESS, TURN_ON): {
COMMAND: COMMAND_ON,
},
(SHORT_PRESS, TURN_OFF): {
COMMAND: COMMAND_OFF,
},
(SHORT_PRESS, DIM_UP): {
COMMAND: COMMAND_STEP,
PARAMS: {
"step_mode": 0,
"step_size": 51,
"transition_time": 10,
},
},
(SHORT_PRESS, DIM_DOWN): {
COMMAND: COMMAND_STEP,
PARAMS: {
"step_mode": 1,
"step_size": 51,
"transition_time": 10,
},
},
(LONG_PRESS, DIM_UP): {
COMMAND: COMMAND_MOVE,
PARAMS: {
"move_mode": 0,
"rate": 51,
},
},
(LONG_PRESS, DIM_DOWN): {
COMMAND: COMMAND_MOVE,
PARAMS: {
"move_mode": 1,
"rate": 51,
},
},
(LONG_RELEASE, BUTTON): {
COMMAND: COMMAND_STOP,
}
}
blueprint:
name: Immax V2 Zigbee Remote
description: Automate the Immax NEO 07087-2 Zigbee Remote Control
domain: automation
input:
immax_v2_remote:
name: Immax V2 Remote
selector:
device:
integration: zha
manufacturer: _TYZB01_7qf81wty
model: TS1001
on_action:
name: Press ON
description: Action to run when ON is pressed
default: []
selector:
action: {}
off_action:
name: Press OFF
description: Action to run when OFF is pressed
default: []
selector:
action: {}
plus_action:
name: Press +
description: Action to run when + is pressed
default: []
selector:
action: {}
minus_action:
name: Press -
description: Action to run when - is pressed
default: []
selector:
action: {}
hold_plus_action:
name: Hold +
description: Action to run when + is held pressed
default: []
selector:
action: {}
hold_minus_action:
name: Hold -
description: Action to run when - is held pressed
default: []
selector:
action: {}
release_action:
name: Release + or - after holding
description: Action to run when + or - are released after being held pressed
default: []
selector:
action: {}
mode: single
max_exceeded: silent
trigger:
- platform: device
domain: zha
device_id: !input "immax_v2_remote"
type: remote_button_short_press
subtype: turn_on
variables:
action: "press_on"
- platform: device
domain: zha
device_id: !input "immax_v2_remote"
type: remote_button_short_press
subtype: turn_off
variables:
action: "press_off"
- platform: device
domain: zha
device_id: !input "immax_v2_remote"
type: remote_button_short_press
subtype: dim_up
variables:
action: "press_plus"
- platform: device
domain: zha
device_id: !input "immax_v2_remote"
type: remote_button_short_press
subtype: dim_down
variables:
action: "press_minus"
- platform: device
domain: zha
device_id: !input "immax_v2_remote"
type: remote_button_long_press
subtype: dim_up
variables:
action: "hold_plus"
- platform: device
domain: zha
device_id: !input "immax_v2_remote"
type: remote_button_long_press
subtype: dim_down
variables:
action: "hold_minus"
- platform: device
domain: zha
device_id: !input "immax_v2_remote"
type: remote_button_long_release
subtype: button
variables:
action: "release_button"
variables:
on_action: !input "on_action"
off_action: !input "off_action"
plus_action: !input "plus_action"
minus_action: !input "minus_action"
hold_plus_action: !input "hold_plus_action"
hold_minus_action: !input "hold_minus_action"
release_action: !input "release_action"
action:
- choose:
- conditions:
- '{{ action == "press_on" }}'
sequence: !input "on_action"
- conditions:
- '{{ action == "press_off" }}'
sequence: !input "off_action"
- conditions:
- '{{ action == "press_plus" }}'
sequence: !input "plus_action"
- conditions:
- '{{ action == "press_minus" }}'
sequence: !input "minus_action"
- conditions:
- '{{ action == "hold_plus" }}'
sequence: !input "hold_plus_action"
- conditions:
- '{{ action == "hold_minus" }}'
sequence: !input "hold_minus_action"
- conditions:
- '{{ action == "release_button" }}'
sequence: !input "release_action"
blueprint:
name: Immax V2 Zigbee Remote dimmable light control
description: Control a dimmable light with an Immax NEO 07087-2 Zigbee Remote Control
domain: automation
input:
immax_v2_remote:
name: Immax V2 Remote
selector:
device:
integration: zha
manufacturer: _TYZB01_7qf81wty
model: TS1001
target_light:
name: Target light
description: The dimmable light you want to control with the remote
selector:
entity:
domain: light
dim_step:
name: Dimming step
description: The amount with which you want the brightness to increase/decrease when adjusting it with the remote control
selector:
number:
min: 1
max: 99
unit_of_measurement: "%"
default: 5
dim_step_delay:
name: Dimming step delay
description: The time that should pass between dimming steps when holding the + or - button on the remote
selector:
number:
min: 10
max: 999
unit_of_measurement: "ms"
default: 50
mode: restart
max_exceeded: silent
trigger:
- platform: device
domain: zha
device_id: !input "immax_v2_remote"
type: remote_button_short_press
subtype: turn_on
variables:
action: "turn_on"
expected_result: "toggle_state"
- platform: device
domain: zha
device_id: !input "immax_v2_remote"
type: remote_button_short_press
subtype: turn_off
variables:
action: "turn_off"
expected_result: "toggle_state"
- platform: device
domain: zha
device_id: !input "immax_v2_remote"
type: remote_button_short_press
subtype: dim_up
variables:
action: "press_plus"
expected_result: "adjust_brightness"
repeat_only_once: true
direction: 1
- platform: device
domain: zha
device_id: !input "immax_v2_remote"
type: remote_button_short_press
subtype: dim_down
variables:
action: "press_minus"
expected_result: "adjust_brightness"
repeat_only_once: true
direction: -1
- platform: device
domain: zha
device_id: !input "immax_v2_remote"
type: remote_button_long_press
subtype: dim_up
variables:
action: "hold_plus"
expected_result: "adjust_brightness"
repeat_only_once: false
direction: 1
- platform: device
domain: zha
device_id: !input "immax_v2_remote"
type: remote_button_long_press
subtype: dim_down
variables:
action: "hold_minus"
expected_result: "adjust_brightness"
repeat_only_once: false
direction: -1
variables:
dim_step: !input "dim_step"
dim_step_delay_ms: !input "dim_step_delay"
action:
- choose:
- conditions:
- '{{ expected_result == "adjust_brightness" }}'
sequence:
- repeat:
until:
- condition: template
value_template: >-
{{ repeat_only_once or wait.trigger is not none or repeat.index > 100 }}
sequence:
- service: light.turn_on
data:
brightness_step_pct: "{{ direction * dim_step }}"
target:
entity_id: !input "target_light"
- wait_for_trigger:
- device_id: !input "immax_v2_remote"
domain: zha
platform: device
type: remote_button_long_release
subtype: button
timeout: "{{ '0:00:00.' ~ ('%03d' % dim_step_delay_ms) }}"
- conditions:
- '{{ expected_result == "toggle_state" }}'
sequence:
- service: light.{{ action }}
target:
entity_id: !input "target_light"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment