Skip to content

Instantly share code, notes, and snippets.

@fholzer
Created August 29, 2023 22:29
Show Gist options
  • Save fholzer/f485009437d2cd50ef4265ca72e54490 to your computer and use it in GitHub Desktop.
Save fholzer/f485009437d2cd50ef4265ca72e54490 to your computer and use it in GitHub Desktop.
PhilipsRemoteCluster diff
colordiff -wub p-init.py p-rdm001.py
--- p-init.py 2023-08-29 23:58:18.662019044 +0200
+++ p-rdm001.py 2023-08-29 23:58:17.972036079 +0200
@@ -21,27 +21,29 @@
class PhilipsRemoteCluster(CustomCluster):
"""Philips remote cluster."""
- cluster_id = 0xFC00
+ cluster_id = 64512
name = "PhilipsRemoteCluster"
ep_attribute = "philips_remote_cluster"
client_commands = {
- 0x0000: foundation.ZCLCommandDef(
+ 0x00: foundation.ZCLCommandDef(
"notification",
{
- "button": t.uint8_t,
+ "param1": t.uint8_t,
"param2": t.uint24_t,
- "press_type": t.uint8_t,
+ "param3": t.uint8_t,
"param4": t.uint8_t,
- "duration": t.uint16_t,
+ "param5": t.uint8_t,
+ "param6": t.uint8_t,
},
- False,
is_manufacturer_specific=True,
+ direction=foundation.Direction.Server_to_Client,
)
}
- BUTTONS = {1: "on", 2: "up", 3: "down", 4: "off"}
- PRESS_TYPES = {0: "press", 1: "hold", 2: "short_release", 3: "long_release"}
-
- button_press_queue = ButtonPressQueue()
+ BUTTONS = {
+ 1: "left",
+ 2: "right",
+ }
+ PRESS_TYPES = {0: "press", 1: "hold", 2: "press_release", 3: "hold_release"}
def handle_cluster_request(
self,
@@ -54,8 +56,7 @@
):
"""Handle the cluster command."""
_LOGGER.debug(
- "%s - handle_cluster_request tsn: [%s] command id: %s - args: [%s]",
- self.__class__.__name__,
+ "PhilipsRemoteCluster - handle_cluster_request tsn: [%s] command id: %s - args: [%s]",
hdr.tsn,
hdr.command_id,
args,
@@ -63,43 +64,13 @@
button = self.BUTTONS.get(args[0], args[0])
press_type = self.PRESS_TYPES.get(args[2], args[2])
- duration = args[4]
event_args = {
BUTTON: button,
PRESS_TYPE: press_type,
COMMAND_ID: hdr.command_id,
- "duration": duration,
ARGS: args,
}
- def send_press_event(click_count):
- _LOGGER.debug(
- "%s - send_press_event click_count: [%s]",
- self.__class__.__name__,
- click_count,
- )
- press_type = None
- if click_count == 1:
- press_type = "press"
- elif click_count == 2:
- press_type = "double_press"
- elif click_count == 3:
- press_type = "triple_press"
- elif click_count == 4:
- press_type = "quadruple_press"
- elif click_count > 4:
- press_type = "quintuple_press"
-
- if press_type:
- # Override PRESS_TYPE
- event_args[PRESS_TYPE] = press_type
- action = f"{button}_{press_type}"
- self.listener_event(ZHA_SEND_EVENT, action, event_args)
-
- # Derive Multiple Presses
- if press_type == "press":
- self.button_press_queue.press(send_press_event, button)
- else:
action = f"{button}_{press_type}"
self.listener_event(ZHA_SEND_EVENT, action, event_args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment