Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

favor companion protocol for power state and listen to TVSystemStatus events #2598

Merged
merged 4 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyatv/core/facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class FacadePower(Relayer, interface.Power, interface.PowerListener):
def __init__(self, core_dispatcher: CoreStateDispatcher):
"""Initialize a new FacadePower instance."""
# This is border line, maybe need another structure to support this
Relayer.__init__(self, interface.Power, DEFAULT_PRIORITIES)
Relayer.__init__(self, interface.Power, self.OVERRIDE_PRIORITIES)
interface.Power.__init__(self)

def powerstate_update(
Expand All @@ -320,7 +320,7 @@ def powerstate_update(
@shield.guard
def power_state(self) -> const.PowerState:
"""Return device power state."""
return self.relay("power_state")
return self.relay("power_state", priority=self.OVERRIDE_PRIORITIES)

@shield.guard
async def turn_on(self, await_new_state: bool = False) -> None:
Expand Down
3 changes: 3 additions & 0 deletions pyatv/protocols/companion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ async def initialize(self) -> None:
self.api.listen_to("SystemStatus", self._handle_system_status_update)
await self.api.subscribe_event("SystemStatus")

self.api.listen_to("TVSystemStatus", self._handle_system_status_update)
await self.api.subscribe_event("TVSystemStatus")

_LOGGER.debug("Initial power state is %s", self.power_state)
except Exception as ex:
_LOGGER.exception(
Expand Down
Loading