diff --git a/src/alga/cli_power.py b/src/alga/cli_power.py index 0646fe1..ffff49b 100644 --- a/src/alga/cli_power.py +++ b/src/alga/cli_power.py @@ -4,7 +4,7 @@ from alga import client, config -app = Typer(no_args_is_help=True, help="Turn TV on and off") +app = Typer(no_args_is_help=True, help="Turn TV (or screen) on and off") @app.command() @@ -20,3 +20,17 @@ def on() -> None: cfg = config.get() send_magic_packet(cfg["mac"]) + + +@app.command() +def screen_off() -> None: + """Turn TV screen off""" + + client.request("ssap://com.webos.service.tvpower/power/turnOffScreen") + + +@app.command() +def screen_on() -> None: + """Turn TV screen on""" + + client.request("ssap://com.webos.service.tvpower/power/turnOnScreen") diff --git a/tests/test_cli_power.py b/tests/test_cli_power.py index 75c2a4d..74d2017 100644 --- a/tests/test_cli_power.py +++ b/tests/test_cli_power.py @@ -17,6 +17,26 @@ def test_off(mock_request: mock.MagicMock) -> None: assert result.stdout == "" +def test_screen_off(mock_request: mock.MagicMock) -> None: + result = runner.invoke(app, ["power", "screen-off"]) + + mock_request.assert_called_once_with( + "ssap://com.webos.service.tvpower/power/turnOffScreen" + ) + assert result.exit_code == 0 + assert result.stdout == "" + + +def test_screen_on(mock_request: mock.MagicMock) -> None: + result = runner.invoke(app, ["power", "screen-on"]) + + mock_request.assert_called_once_with( + "ssap://com.webos.service.tvpower/power/turnOnScreen" + ) + assert result.exit_code == 0 + assert result.stdout == "" + + @mock.patch("alga.config.get") @mock.patch("alga.cli_power.send_magic_packet") def test_on( diff --git a/usage.md b/usage.md index ca621a9..80c89dd 100644 --- a/usage.md +++ b/usage.md @@ -19,7 +19,7 @@ $ alga [OPTIONS] COMMAND [ARGS]... * `channel`: TV channels * `input`: HDMI and similar inputs * `media`: Control the playing media -* `power`: Turn TV on and off +* `power`: Turn TV (or screen) on and off * `setup`: Pair a new TV * `sound-output`: Audio output device * `version`: Print Alga version @@ -390,7 +390,7 @@ $ alga media stop [OPTIONS] ## `alga power` -Turn TV on and off +Turn TV (or screen) on and off **Usage**: @@ -406,6 +406,8 @@ $ alga power [OPTIONS] COMMAND [ARGS]... * `off`: Turn TV off * `on`: Turn TV on via Wake-on-LAN +* `screen-off`: Turn TV screen off +* `screen-on`: Turn TV screen on ### `alga power off` @@ -435,6 +437,34 @@ $ alga power on [OPTIONS] * `--help`: Show this message and exit. +### `alga power screen-off` + +Turn TV screen off + +**Usage**: + +```console +$ alga power screen-off [OPTIONS] +``` + +**Options**: + +* `--help`: Show this message and exit. + +### `alga power screen-on` + +Turn TV screen on + +**Usage**: + +```console +$ alga power screen-on [OPTIONS] +``` + +**Options**: + +* `--help`: Show this message and exit. + ## `alga setup` Pair a new TV