From 59a66ce0ec2a3fe9f249fa291fbe6ea0e75e6e08 Mon Sep 17 00:00:00 2001 From: Henrik Widlund <4659350+henrikwidlund@users.noreply.github.com> Date: Mon, 19 May 2025 18:27:32 +0200 Subject: [PATCH 1/5] Add support for Guide, Page Up/Down --- pyatv/const.py | 9 +++++++++ pyatv/core/facade.py | 14 ++++++++++++++ pyatv/interface.py | 14 ++++++++++++++ pyatv/protocols/companion/__init__.py | 15 +++++++++++++++ tests/fake_device/companion.py | 3 +++ .../companion/test_companion_functional.py | 3 +++ 6 files changed, 58 insertions(+) diff --git a/pyatv/const.py b/pyatv/const.py index ea75f047a..70ee20c22 100644 --- a/pyatv/const.py +++ b/pyatv/const.py @@ -450,6 +450,15 @@ class FeatureName(Enum): Click = 65 """Touch click command.""" + Guide = 66 + """Show EPG.""" + + PageUp = 67 + """Page Up.""" + + PageDown = 68 + """Page Down.""" + class TouchAction(Enum): """Touch action constants.""" diff --git a/pyatv/core/facade.py b/pyatv/core/facade.py index 7bafe33fc..f6ba53bfc 100644 --- a/pyatv/core/facade.py +++ b/pyatv/core/facade.py @@ -193,6 +193,20 @@ async def screensaver(self) -> None: """Activate screen saver..""" return await self.relay("screensaver")() + @shield.guard + async def guide(self) -> None: + """Show EPG.""" + return await self.relay("guide")() + + @shield.guard + async def page_up(self) -> None: + """Page Up.""" + return await self.relay("page_up")() + + @shield.guard + async def page_down(self) -> None: + """Page Down.""" + return await self.relay("page_down")() class FacadeMetadata(Relayer, interface.Metadata): """Facade implementation for retrieving metadata from an Apple TV.""" diff --git a/pyatv/interface.py b/pyatv/interface.py index dae282b2e..1dc731ff6 100644 --- a/pyatv/interface.py +++ b/pyatv/interface.py @@ -454,6 +454,20 @@ async def screensaver(self) -> None: """Activate screen saver..""" raise exceptions.NotSupportedError() + @feature(66, "Guide", "Show EPG.") + async def guide(self) -> None: + """Show EPG.""" + raise exceptions.NotSupportedError() + + @feature(67, "PageUp", "Page Up.") + async def page_up(self) -> None: + """Page Up.""" + raise exceptions.NotSupportedError() + + @feature(68, "PageDown", "Page Down.") + async def page_down(self) -> None: + """Page Down.""" + raise exceptions.NotSupportedError() # TODO: Should be made into a dataclass when support for 3.6 is dropped class Playing(ABC): diff --git a/pyatv/protocols/companion/__init__.py b/pyatv/protocols/companion/__init__.py index a7e3f6a50..4797349b2 100644 --- a/pyatv/protocols/companion/__init__.py +++ b/pyatv/protocols/companion/__init__.py @@ -139,6 +139,9 @@ class MediaControlFlags(IntFlag): FeatureName.ChannelUp, FeatureName.ChannelDown, FeatureName.Screensaver, + FeatureName.Guide, + FeatureName.PageUp, + FeatureName.PageDown, # Keyboard interface FeatureName.TextFocusState, FeatureName.TextGet, @@ -380,6 +383,18 @@ async def screensaver(self) -> None: """Activate screen saver.""" await self._press_button(HidCommand.Screensaver) + async def guide(self) -> None: + """Show EPG.""" + await self._press_button(HidCommand.Guide) + + async def page_up(self) -> None: + """Page up.""" + await self._press_button(HidCommand.PageUp) + + async def page_down(self) -> None: + """Page down.""" + await self._press_button(HidCommand.PageDown) + async def _press_button( self, command: HidCommand, diff --git a/tests/fake_device/companion.py b/tests/fake_device/companion.py index fe6fda057..ad9698e86 100644 --- a/tests/fake_device/companion.py +++ b/tests/fake_device/companion.py @@ -48,6 +48,9 @@ HidCommand.ChannelIncrement: "channel_up", HidCommand.ChannelDecrement: "channel_down", HidCommand.Screensaver: "screensaver", + HidCommand.Guide: "guide", + HidCommand.PageUp: "page_up", + HidCommand.PageDown: "page_down", } MEDIA_CONTROL_MAP = { diff --git a/tests/protocols/companion/test_companion_functional.py b/tests/protocols/companion/test_companion_functional.py index d68fc6804..457f5fce6 100644 --- a/tests/protocols/companion/test_companion_functional.py +++ b/tests/protocols/companion/test_companion_functional.py @@ -204,6 +204,9 @@ async def test_session_start_and_stop(companion_client, companion_state): "play_pause", "channel_up", "channel_down", + "guide", + "page_up", + "page_down", # Media Control "play", "pause", From 272c93c51279279c7fd06c3960e0a526c09fb9d2 Mon Sep 17 00:00:00 2001 From: Henrik Widlund <4659350+henrikwidlund@users.noreply.github.com> Date: Mon, 19 May 2025 18:32:05 +0200 Subject: [PATCH 2/5] Disable publish to pypi --- .github/workflows/release_temp.yml | 160 +++++++++++++++++++++++++++++ .github/workflows/tests_temp.yml | 103 +++++++++++++++++++ 2 files changed, 263 insertions(+) create mode 100644 .github/workflows/release_temp.yml create mode 100644 .github/workflows/tests_temp.yml diff --git a/.github/workflows/release_temp.yml b/.github/workflows/release_temp.yml new file mode 100644 index 000000000..ad89ebb74 --- /dev/null +++ b/.github/workflows/release_temp.yml @@ -0,0 +1,160 @@ +name: Publish containers and make release + +on: + push: + branches: ['master', 'test_release_branch'] + tags: + - '*' + workflow_dispatch: + +env: + REGISTRY: ghcr.io + PYTHON_VERSION: 3.12 + +jobs: + build_containers: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Cargo download work-around + run: | + mkdir -p ~/.cargo + cat < ~/.cargo/config.toml + [net] + git-fetch-with-cli = true + EOF + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Build wheel + id: wheel + run: | + # If not a release branch, add SHA1 to patch version + if [ "$(python scripts/version.py is_release)" = "false" ]; then + python scripts/version.py sha1 + fi + + python -m pip install --upgrade setuptools pip wheel + python setup.py sdist bdist_wheel + echo "version=$(python scripts/version.py get)" >> $GITHUB_OUTPUT + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ github.repository }} + labels: | + org.opencontainers.image.ref.name=${{ github.ref }} + tags: | + type=ref,event=branch + type=ref,event=pr, + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + github-token: ${{ secrets.GITHUB_TOKEN }} + builder: ${{ steps.buildx.outputs.name }} + platforms: linux/amd64,linux/arm64 + push: true + cache-from: type=gha + cache-to: type=gha,mode=max + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=${{ steps.wheel.outputs.version }} + + - name: Upload built artifacts + uses: actions/upload-artifact@v4 + with: + name: packages + path: | + dist + + make_release: + if: ${{ startsWith(github.ref, 'refs/tags/v') }} + needs: build_containers + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Download pre-built packages + uses: actions/download-artifact@v4.1.7 + with: + name: packages + path: dist + + - name: Extract release notes and name + id: info + shell: python {0} + run: | + import os + import re + + name = None + version = None + notes = "" + with open("CHANGES.md", "r", encoding="utf-8") as handle: + for line in handle: + if line.startswith("##"): + if name is None: + version, name = re.match(r"## ([0-9.]+) ([^(]+) \(.*", line).groups() + else: + break + if name is not None: + notes += line + + with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as fh: + fh.writelines([f"name={name}\n", f"version={version}\n"]) + + with open("notes.md", "w", encoding="utf-8") as handle: + handle.write(notes) + + - name: Publish release + uses: ncipollo/release-action@v1 + with: + artifacts: "dist/pyatv-${{ steps.info.outputs.version }}.tar.gz,dist/pyatv-${{ steps.info.outputs.version }}-*.whl" + bodyFile: "notes.md" + token: ${{ secrets.GITHUB_TOKEN }} + draft: false + tag: v${{ steps.info.outputs.version }} + name: ${{ steps.info.outputs.name }} + +# - name: Publish distribution to PyPI +# uses: pypa/gh-action-pypi-publish@release/v1 +# with: +# password: ${{ secrets.PYPI_API_TOKEN }} +# skip_existing: true diff --git a/.github/workflows/tests_temp.yml b/.github/workflows/tests_temp.yml new file mode 100644 index 000000000..d43fbc9fd --- /dev/null +++ b/.github/workflows/tests_temp.yml @@ -0,0 +1,103 @@ +name: Tests + +on: + push: + branches: + - master + pull_request: + workflow_dispatch: + +jobs: + build: + name: >- + ${{ matrix.python-version }} + / + ${{ matrix.platform }} + / + (regression: ${{ matrix.regression }}) + runs-on: ${{ matrix.platform }} + env: + CACHE_INVALIDATE: "v4" + CACHE_KEY: ${{ github.run_id }}-${{ github.job }}-${{ matrix.python-version }}-${{ matrix.platform }}-${{ matrix.regression }} + strategy: + matrix: + # https://help.github.com/articles/virtual-environments-for-github-actions + platform: + - ubuntu-latest + - macos-latest + - windows-latest + python-version: + - "3.9" + - "3.10" + - "3.11" + - "3.12" + - "3.13" + chickn-args: + - "--no-venv" + regression: + - false + include: + - platform: ubuntu-latest + python-version: 3.9 + chickn-args: "--no-venv -v requirements_file=base_versions.txt" + regression: true + steps: + # Receipe for not running jobs again when re-running workflow + # https://medium.com/xcnotes/how-to-re-run-only-failed-jobs-on-github-actions-b79b13d1ceb2 + - id: timestamp + shell: bash + run: echo "::set-output name=timestamp::$(timestamp +%s)" + - name: Restore the previous run result + uses: actions/cache@v4 + with: + path: | + run_result + key: ${{ env.CACHE_KEY }}-${{ steps.timestamp.outputs.timestamp }} + restore-keys: | + ${{ env.CACHE_KEY }}- + - id: run_result + shell: bash + run: cat run_result 2>/dev/null || echo 'default' + + # Regular flow continues here + - uses: actions/checkout@v2 + if: steps.run_result.outputs.run_result != 'success' + with: + fetch-depth: 2 + - name: Set up Python ${{ matrix.python-version }} + if: steps.run_result.outputs.run_result != 'success' + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - uses: syphar/restore-virtualenv@v1 + if: steps.run_result.outputs.run_result != 'success' + id: cache-virtualenv + with: + custom_cache_key_element: ${{ env.CACHE_INVALIDATE }} + requirement_files: | + **/*.txt + **/requirements/**.txt + + - uses: syphar/restore-pip-download-cache@v1 + if: steps.run_result.outputs.run_result != 'success' && steps.cache-virtualenv.outputs.cache-hit != 'true' + + - name: Install dependencies + if: steps.run_result.outputs.run_result != 'success' + run: | + python -m pip install --upgrade setuptools pip pyyaml + - name: Test with chickn + if: steps.run_result.outputs.run_result != 'success' + run: python ./scripts/chickn.py -t miniaudio -t ${{ matrix.python-version }} ${{ matrix.chickn-args }} + shell: bash + - name: Upload coverage to Codecov + if: steps.run_result.outputs.run_result != 'success' + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage.xml + name: pyatv + fail_ci_if_error: false + + - name: Mark build as successful + if: steps.run_result.outputs.run_result != 'success' + run: echo "::set-output name=run_result::success" > run_result From e76128e2394582d99ad9444a546f573e7ea04f82 Mon Sep 17 00:00:00 2001 From: Henrik Widlund <4659350+henrikwidlund@users.noreply.github.com> Date: Mon, 19 May 2025 18:37:04 +0200 Subject: [PATCH 3/5] Fix formatting --- pyatv/core/facade.py | 1 + pyatv/interface.py | 1 + 2 files changed, 2 insertions(+) diff --git a/pyatv/core/facade.py b/pyatv/core/facade.py index f6ba53bfc..30ec50c36 100644 --- a/pyatv/core/facade.py +++ b/pyatv/core/facade.py @@ -208,6 +208,7 @@ async def page_down(self) -> None: """Page Down.""" return await self.relay("page_down")() + class FacadeMetadata(Relayer, interface.Metadata): """Facade implementation for retrieving metadata from an Apple TV.""" diff --git a/pyatv/interface.py b/pyatv/interface.py index 1dc731ff6..bf7049cde 100644 --- a/pyatv/interface.py +++ b/pyatv/interface.py @@ -469,6 +469,7 @@ async def page_down(self) -> None: """Page Down.""" raise exceptions.NotSupportedError() + # TODO: Should be made into a dataclass when support for 3.6 is dropped class Playing(ABC): """Base class for retrieving what is currently playing.""" From 956ffc3d95f577787770bd9d7c2f6ede12b5c19a Mon Sep 17 00:00:00 2001 From: Henrik Widlund <4659350+henrikwidlund@users.noreply.github.com> Date: Sat, 24 May 2025 13:55:50 +0200 Subject: [PATCH 4/5] Remove temp actions --- .github/workflows/release_temp.yml | 160 ----------------------------- .github/workflows/tests_temp.yml | 103 ------------------- 2 files changed, 263 deletions(-) delete mode 100644 .github/workflows/release_temp.yml delete mode 100644 .github/workflows/tests_temp.yml diff --git a/.github/workflows/release_temp.yml b/.github/workflows/release_temp.yml deleted file mode 100644 index ad89ebb74..000000000 --- a/.github/workflows/release_temp.yml +++ /dev/null @@ -1,160 +0,0 @@ -name: Publish containers and make release - -on: - push: - branches: ['master', 'test_release_branch'] - tags: - - '*' - workflow_dispatch: - -env: - REGISTRY: ghcr.io - PYTHON_VERSION: 3.12 - -jobs: - build_containers: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - name: Cargo download work-around - run: | - mkdir -p ~/.cargo - cat < ~/.cargo/config.toml - [net] - git-fetch-with-cli = true - EOF - - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ env.PYTHON_VERSION }} - - - name: Build wheel - id: wheel - run: | - # If not a release branch, add SHA1 to patch version - if [ "$(python scripts/version.py is_release)" = "false" ]; then - python scripts/version.py sha1 - fi - - python -m pip install --upgrade setuptools pip wheel - python setup.py sdist bdist_wheel - echo "version=$(python scripts/version.py get)" >> $GITHUB_OUTPUT - - - name: Log in to the Container registry - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.REGISTRY }}/${{ github.repository }} - labels: | - org.opencontainers.image.ref.name=${{ github.ref }} - tags: | - type=ref,event=branch - type=ref,event=pr, - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=sha - - - name: Build and push Docker image - uses: docker/build-push-action@v4 - with: - context: . - github-token: ${{ secrets.GITHUB_TOKEN }} - builder: ${{ steps.buildx.outputs.name }} - platforms: linux/amd64,linux/arm64 - push: true - cache-from: type=gha - cache-to: type=gha,mode=max - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - VERSION=${{ steps.wheel.outputs.version }} - - - name: Upload built artifacts - uses: actions/upload-artifact@v4 - with: - name: packages - path: | - dist - - make_release: - if: ${{ startsWith(github.ref, 'refs/tags/v') }} - needs: build_containers - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ env.PYTHON_VERSION }} - - - name: Download pre-built packages - uses: actions/download-artifact@v4.1.7 - with: - name: packages - path: dist - - - name: Extract release notes and name - id: info - shell: python {0} - run: | - import os - import re - - name = None - version = None - notes = "" - with open("CHANGES.md", "r", encoding="utf-8") as handle: - for line in handle: - if line.startswith("##"): - if name is None: - version, name = re.match(r"## ([0-9.]+) ([^(]+) \(.*", line).groups() - else: - break - if name is not None: - notes += line - - with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as fh: - fh.writelines([f"name={name}\n", f"version={version}\n"]) - - with open("notes.md", "w", encoding="utf-8") as handle: - handle.write(notes) - - - name: Publish release - uses: ncipollo/release-action@v1 - with: - artifacts: "dist/pyatv-${{ steps.info.outputs.version }}.tar.gz,dist/pyatv-${{ steps.info.outputs.version }}-*.whl" - bodyFile: "notes.md" - token: ${{ secrets.GITHUB_TOKEN }} - draft: false - tag: v${{ steps.info.outputs.version }} - name: ${{ steps.info.outputs.name }} - -# - name: Publish distribution to PyPI -# uses: pypa/gh-action-pypi-publish@release/v1 -# with: -# password: ${{ secrets.PYPI_API_TOKEN }} -# skip_existing: true diff --git a/.github/workflows/tests_temp.yml b/.github/workflows/tests_temp.yml deleted file mode 100644 index d43fbc9fd..000000000 --- a/.github/workflows/tests_temp.yml +++ /dev/null @@ -1,103 +0,0 @@ -name: Tests - -on: - push: - branches: - - master - pull_request: - workflow_dispatch: - -jobs: - build: - name: >- - ${{ matrix.python-version }} - / - ${{ matrix.platform }} - / - (regression: ${{ matrix.regression }}) - runs-on: ${{ matrix.platform }} - env: - CACHE_INVALIDATE: "v4" - CACHE_KEY: ${{ github.run_id }}-${{ github.job }}-${{ matrix.python-version }}-${{ matrix.platform }}-${{ matrix.regression }} - strategy: - matrix: - # https://help.github.com/articles/virtual-environments-for-github-actions - platform: - - ubuntu-latest - - macos-latest - - windows-latest - python-version: - - "3.9" - - "3.10" - - "3.11" - - "3.12" - - "3.13" - chickn-args: - - "--no-venv" - regression: - - false - include: - - platform: ubuntu-latest - python-version: 3.9 - chickn-args: "--no-venv -v requirements_file=base_versions.txt" - regression: true - steps: - # Receipe for not running jobs again when re-running workflow - # https://medium.com/xcnotes/how-to-re-run-only-failed-jobs-on-github-actions-b79b13d1ceb2 - - id: timestamp - shell: bash - run: echo "::set-output name=timestamp::$(timestamp +%s)" - - name: Restore the previous run result - uses: actions/cache@v4 - with: - path: | - run_result - key: ${{ env.CACHE_KEY }}-${{ steps.timestamp.outputs.timestamp }} - restore-keys: | - ${{ env.CACHE_KEY }}- - - id: run_result - shell: bash - run: cat run_result 2>/dev/null || echo 'default' - - # Regular flow continues here - - uses: actions/checkout@v2 - if: steps.run_result.outputs.run_result != 'success' - with: - fetch-depth: 2 - - name: Set up Python ${{ matrix.python-version }} - if: steps.run_result.outputs.run_result != 'success' - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - uses: syphar/restore-virtualenv@v1 - if: steps.run_result.outputs.run_result != 'success' - id: cache-virtualenv - with: - custom_cache_key_element: ${{ env.CACHE_INVALIDATE }} - requirement_files: | - **/*.txt - **/requirements/**.txt - - - uses: syphar/restore-pip-download-cache@v1 - if: steps.run_result.outputs.run_result != 'success' && steps.cache-virtualenv.outputs.cache-hit != 'true' - - - name: Install dependencies - if: steps.run_result.outputs.run_result != 'success' - run: | - python -m pip install --upgrade setuptools pip pyyaml - - name: Test with chickn - if: steps.run_result.outputs.run_result != 'success' - run: python ./scripts/chickn.py -t miniaudio -t ${{ matrix.python-version }} ${{ matrix.chickn-args }} - shell: bash - - name: Upload coverage to Codecov - if: steps.run_result.outputs.run_result != 'success' - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - file: ./coverage.xml - name: pyatv - fail_ci_if_error: false - - - name: Mark build as successful - if: steps.run_result.outputs.run_result != 'success' - run: echo "::set-output name=run_result::success" > run_result From 64f9e0774a9883e762c2306db0822e1069a6b1c8 Mon Sep 17 00:00:00 2001 From: Henrik Widlund <4659350+henrikwidlund@users.noreply.github.com> Date: Sat, 24 May 2025 14:21:19 +0200 Subject: [PATCH 5/5] Cleanup of commands Remove page_up - doesn't seem to do anything Rename page_down to control center since that's what it does --- pyatv/const.py | 7 ++----- pyatv/core/facade.py | 11 +++-------- pyatv/interface.py | 11 +++-------- pyatv/protocols/companion/__init__.py | 11 +++-------- tests/fake_device/companion.py | 3 +-- .../protocols/companion/test_companion_functional.py | 3 +-- 6 files changed, 13 insertions(+), 33 deletions(-) diff --git a/pyatv/const.py b/pyatv/const.py index 70ee20c22..cba672269 100644 --- a/pyatv/const.py +++ b/pyatv/const.py @@ -453,11 +453,8 @@ class FeatureName(Enum): Guide = 66 """Show EPG.""" - PageUp = 67 - """Page Up.""" - - PageDown = 68 - """Page Down.""" + ControlCenter = 68 + """Open the Control Center.""" class TouchAction(Enum): diff --git a/pyatv/core/facade.py b/pyatv/core/facade.py index 30ec50c36..f9193aafc 100644 --- a/pyatv/core/facade.py +++ b/pyatv/core/facade.py @@ -199,14 +199,9 @@ async def guide(self) -> None: return await self.relay("guide")() @shield.guard - async def page_up(self) -> None: - """Page Up.""" - return await self.relay("page_up")() - - @shield.guard - async def page_down(self) -> None: - """Page Down.""" - return await self.relay("page_down")() + async def control_center(self) -> None: + """Open the control center.""" + return await self.relay("control_center")() class FacadeMetadata(Relayer, interface.Metadata): diff --git a/pyatv/interface.py b/pyatv/interface.py index bf7049cde..eeaef8f14 100644 --- a/pyatv/interface.py +++ b/pyatv/interface.py @@ -459,14 +459,9 @@ async def guide(self) -> None: """Show EPG.""" raise exceptions.NotSupportedError() - @feature(67, "PageUp", "Page Up.") - async def page_up(self) -> None: - """Page Up.""" - raise exceptions.NotSupportedError() - - @feature(68, "PageDown", "Page Down.") - async def page_down(self) -> None: - """Page Down.""" + @feature(68, "ControlCenter", "Control Center.") + async def control_center(self) -> None: + """Open the control center.""" raise exceptions.NotSupportedError() diff --git a/pyatv/protocols/companion/__init__.py b/pyatv/protocols/companion/__init__.py index 4797349b2..0fd2bcd9b 100644 --- a/pyatv/protocols/companion/__init__.py +++ b/pyatv/protocols/companion/__init__.py @@ -140,8 +140,7 @@ class MediaControlFlags(IntFlag): FeatureName.ChannelDown, FeatureName.Screensaver, FeatureName.Guide, - FeatureName.PageUp, - FeatureName.PageDown, + FeatureName.ControlCenter, # Keyboard interface FeatureName.TextFocusState, FeatureName.TextGet, @@ -387,12 +386,8 @@ async def guide(self) -> None: """Show EPG.""" await self._press_button(HidCommand.Guide) - async def page_up(self) -> None: - """Page up.""" - await self._press_button(HidCommand.PageUp) - - async def page_down(self) -> None: - """Page down.""" + async def control_center(self) -> None: + """Open the control center.""" await self._press_button(HidCommand.PageDown) async def _press_button( diff --git a/tests/fake_device/companion.py b/tests/fake_device/companion.py index ad9698e86..fe11e2f96 100644 --- a/tests/fake_device/companion.py +++ b/tests/fake_device/companion.py @@ -49,8 +49,7 @@ HidCommand.ChannelDecrement: "channel_down", HidCommand.Screensaver: "screensaver", HidCommand.Guide: "guide", - HidCommand.PageUp: "page_up", - HidCommand.PageDown: "page_down", + HidCommand.PageDown: "control_center", } MEDIA_CONTROL_MAP = { diff --git a/tests/protocols/companion/test_companion_functional.py b/tests/protocols/companion/test_companion_functional.py index 457f5fce6..561db962c 100644 --- a/tests/protocols/companion/test_companion_functional.py +++ b/tests/protocols/companion/test_companion_functional.py @@ -205,8 +205,7 @@ async def test_session_start_and_stop(companion_client, companion_state): "channel_up", "channel_down", "guide", - "page_up", - "page_down", + "control_center", # Media Control "play", "pause",