Skip to content

Commit 62d37d3

Browse files
authored
Support controller.toggle_rf command (#1238)
* Support `controller.toggle_rf` command * bump schema to 43 * lint * lint
1 parent 75d1bbc commit 62d37d3

File tree

7 files changed

+28
-5
lines changed

7 files changed

+28
-5
lines changed

test/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def version_data_fixture() -> dict[str, Any]:
246246
"serverVersion": "test_server_version",
247247
"homeId": "test_home_id",
248248
"minSchemaVersion": 0,
249-
"maxSchemaVersion": 42,
249+
"maxSchemaVersion": 43,
250250
}
251251

252252

test/model/test_controller.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,6 +1876,22 @@ async def test_get_rf_region(controller, uuid4, mock_command):
18761876
}
18771877

18781878

1879+
async def test_toggle_rf(controller, uuid4, mock_command):
1880+
"""Test toggle RF."""
1881+
ack_commands = mock_command(
1882+
{"command": "controller.toggle_rf"},
1883+
{"success": True},
1884+
)
1885+
assert await controller.async_toggle_rf(True)
1886+
1887+
assert len(ack_commands) == 1
1888+
assert ack_commands[0] == {
1889+
"command": "controller.toggle_rf",
1890+
"enable": True,
1891+
"messageId": uuid4,
1892+
}
1893+
1894+
18791895
async def test_get_known_lifeline_routes(
18801896
multisensor_6, ring_keypad, wallmote_central_scene, uuid4, mock_command
18811897
):

test/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ async def test_additional_user_agent_components(client_session, url):
463463
{
464464
"command": "initialize",
465465
"messageId": "initialize",
466-
"schemaVersion": 42,
466+
"schemaVersion": 43,
467467
"additionalUserAgentComponents": {
468468
"zwave-js-server-python": __version__,
469469
"foo": "bar",

test/test_dump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async def test_dump_additional_user_agent_components(
106106
{
107107
"command": "initialize",
108108
"messageId": "initialize",
109-
"schemaVersion": 42,
109+
"schemaVersion": 43,
110110
"additionalUserAgentComponents": {
111111
"zwave-js-server-python": __version__,
112112
"foo": "bar",

test/test_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_dump_state(
5858
assert captured.out == (
5959
"{'type': 'version', 'driverVersion': 'test_driver_version', "
6060
"'serverVersion': 'test_server_version', 'homeId': 'test_home_id', "
61-
"'minSchemaVersion': 0, 'maxSchemaVersion': 42}\n"
61+
"'minSchemaVersion': 0, 'maxSchemaVersion': 43}\n"
6262
"{'type': 'result', 'success': True, 'result': {}, 'messageId': 'initialize'}\n"
6363
"test_result\n"
6464
)

zwave_js_server/const/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# minimal server schema version we can handle
1414
MIN_SERVER_SCHEMA_VERSION = 41
1515
# max server schema version we can handle (and our code is compatible with)
16-
MAX_SERVER_SCHEMA_VERSION = 42
16+
MAX_SERVER_SCHEMA_VERSION = 43
1717

1818
VALUE_UNKNOWN = "unknown"
1919

zwave_js_server/model/controller/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,13 @@ async def async_set_rf_region(self, rf_region: RFRegion) -> bool:
805805
)
806806
return cast(bool, data["success"])
807807

808+
async def async_toggle_rf(self, enable: bool) -> bool:
809+
"""Send toggleRF command to Controller."""
810+
data = await self.client.async_send_command(
811+
{"command": "controller.toggle_rf", "enable": enable}, require_schema=43
812+
)
813+
return cast(bool, data["success"])
814+
808815
async def async_get_known_lifeline_routes(
809816
self,
810817
) -> dict[Node, ControllerLifelineRoutes]:

0 commit comments

Comments
 (0)