Skip to content

Commit

Permalink
Swap Direction enum (#2965)
Browse files Browse the repository at this point in the history
* Invert use of `Server_to_Client` and `Client_to_Server`

* Bump minimum zigpy version
  • Loading branch information
puddly authored Feb 4, 2024
1 parent 97d2734 commit 1f29b72
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ readme = "README.md"
license = {text = "Apache License Version 2.0"}
requires-python = ">=3.8"
dependencies = [
"zigpy>=0.60.3",
"zigpy>=0.62.0",
]

[tool.setuptools.packages.find]
Expand Down
6 changes: 3 additions & 3 deletions tests/test_tuya_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def test_tuya_cluster_request(
):
"""Test cluster specific request."""

hdr = zcl_f.ZCLHeader.general(1, cmd_id, direction=zcl_f.Direction.Client_to_Server)
hdr = zcl_f.ZCLHeader.general(1, cmd_id, direction=zcl_f.Direction.Server_to_Client)
hdr.frame_control.disable_default_response = False

with mock.patch.object(TuyaCluster, handler_name) as handler:
Expand All @@ -266,7 +266,7 @@ def test_tuya_cluster_request(
def test_tuya_cluster_request_unk_command(default_rsp_mock, TuyaCluster):
"""Test cluster specific request handler -- no handler."""

hdr = zcl_f.ZCLHeader.general(1, 0xFE, direction=zcl_f.Direction.Client_to_Server)
hdr = zcl_f.ZCLHeader.general(1, 0xFE, direction=zcl_f.Direction.Server_to_Client)
hdr.frame_control.disable_default_response = False

TuyaCluster.handle_cluster_request(hdr, (mock.sentinel.args,))
Expand All @@ -278,7 +278,7 @@ def test_tuya_cluster_request_unk_command(default_rsp_mock, TuyaCluster):
def test_tuya_cluster_request_no_handler(default_rsp_mock, TuyaCluster):
"""Test cluster specific request handler -- no handler."""

hdr = zcl_f.ZCLHeader.general(1, 0xFE, direction=zcl_f.Direction.Client_to_Server)
hdr = zcl_f.ZCLHeader.general(1, 0xFE, direction=zcl_f.Direction.Server_to_Client)
hdr.frame_control.disable_default_response = False

new_client_commands = TuyaCluster.client_commands.copy()
Expand Down
2 changes: 1 addition & 1 deletion zhaquirks/adeo/color_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class AdeoManufacturerCluster(EventableCluster):
0x00: foundation.ZCLCommandDef(
"preset",
{"param1": t.uint8_t, "param2": t.uint8_t},
direction=foundation.Direction.Server_to_Client,
direction=foundation.Direction.Client_to_Server,
is_manufacturer_specific=True,
)
}
Expand Down
10 changes: 5 additions & 5 deletions zhaquirks/inovelli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class Inovelli_VZM31SN_Cluster(CustomCluster):
0x00: foundation.ZCLCommandDef(
"button_event",
{"button_pressed": t.uint8_t, "press_type": t.uint8_t},
direction=foundation.Direction.Server_to_Client,
direction=foundation.Direction.Client_to_Server,
is_manufacturer_specific=True,
),
0x01: foundation.ZCLCommandDef(
Expand All @@ -174,13 +174,13 @@ class Inovelli_VZM31SN_Cluster(CustomCluster):
"led_level": t.uint8_t,
"led_duration": t.uint8_t,
},
direction=foundation.Direction.Server_to_Client,
direction=foundation.Direction.Client_to_Server,
is_manufacturer_specific=True,
),
0x02: foundation.ZCLCommandDef(
"reset_energy_meter",
{},
direction=foundation.Direction.Server_to_Client,
direction=foundation.Direction.Client_to_Server,
is_manufacturer_specific=True,
),
0x03: foundation.ZCLCommandDef(
Expand All @@ -192,15 +192,15 @@ class Inovelli_VZM31SN_Cluster(CustomCluster):
"led_level": t.uint8_t,
"led_duration": t.uint8_t,
},
direction=foundation.Direction.Server_to_Client,
direction=foundation.Direction.Client_to_Server,
is_manufacturer_specific=True,
),
0x24: foundation.ZCLCommandDef(
"led_effect_complete",
{
"notification_type": t.uint8_t,
},
direction=foundation.Direction.Server_to_Client,
direction=foundation.Direction.Client_to_Server,
is_manufacturer_specific=True,
),
}
Expand Down
2 changes: 1 addition & 1 deletion zhaquirks/legrand/cable_outlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ServerCommandDefs(BaseCommandDefs):
set_pilot_wire_mode = ZCLCommandDef(
id=0x00,
schema={"mode": PilotWireMode},
direction=Direction.Server_to_Client,
direction=Direction.Client_to_Server,
is_manufacturer_specific=True,
)

Expand Down
2 changes: 1 addition & 1 deletion zhaquirks/philips/rdm001.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class PhilipsRemoteCluster(CustomCluster):
"param6": t.uint8_t,
},
is_manufacturer_specific=True,
direction=foundation.Direction.Server_to_Client,
direction=foundation.Direction.Client_to_Server,
)
}
BUTTONS = {
Expand Down
2 changes: 1 addition & 1 deletion zhaquirks/sengled/e1e_g7f.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class SengledE1EG7FManufacturerSpecificCluster(CustomCluster):
"param3": t.uint8_t,
"param4": t.uint8_t,
},
direction=foundation.Direction.Server_to_Client,
direction=foundation.Direction.Client_to_Server,
is_manufacturer_specific=True,
)
}
Expand Down
2 changes: 1 addition & 1 deletion zhaquirks/siglis/zigfred.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ZigfredCluster(CustomCluster):
ZIGFRED_CLUSTER_COMMAND_BUTTON_EVENT: foundation.ZCLCommandDef(
"button_event",
{"param1": t.uint32_t},
direction=foundation.Direction.Server_to_Client,
direction=foundation.Direction.Client_to_Server,
is_manufacturer_specific=True,
),
}
Expand Down
2 changes: 1 addition & 1 deletion zhaquirks/tuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,7 @@ def handle_cluster_request(
"""Handle cluster specific request."""

try:
if hdr.direction == foundation.Direction.Client_to_Server:
if hdr.direction == foundation.Direction.Server_to_Client:
# server_cluster -> client_cluster cluster specific command
handler_name = f"handle_{self.client_commands[hdr.command_id].name}"
else:
Expand Down

0 comments on commit 1f29b72

Please sign in to comment.