Skip to content

Commit

Permalink
(feat) add simple commands for Output Monitor 1, Monitor 2, Monitor Auto
Browse files Browse the repository at this point in the history
  • Loading branch information
splattner committed Jun 13, 2024
1 parent 0f2aa35 commit d25846a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
24 changes: 24 additions & 0 deletions intg-denonavr/avr.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,30 @@ async def options(self) -> ucapi.StatusCodes:
else:
await self._receiver.async_get_command(AVR_COMMAND_URL + "?MNOPT")

@async_handle_denonlib_errors
async def output_monitor_1(self) -> ucapi.StatusCodes:
"""Send cursor down command to AVR."""
if self._use_telnet:
await self._receiver.async_send_telnet_commands("VSMONI1")
else:
await self._receiver.async_get_command(AVR_COMMAND_URL + "?VSMONI1")

@async_handle_denonlib_errors
async def output_monitor_2(self) -> ucapi.StatusCodes:
"""Send cursor down command to AVR."""
if self._use_telnet:
await self._receiver.async_send_telnet_commands("VSMONI2")
else:
await self._receiver.async_get_command(AVR_COMMAND_URL + "?VSMONI2")

@async_handle_denonlib_errors
async def output_monitor_auto(self) -> ucapi.StatusCodes:
"""Send cursor down command to AVR."""
if self._use_telnet:
await self._receiver.async_send_telnet_commands("VSMONIAUTO")
else:
await self._receiver.async_get_command(AVR_COMMAND_URL + "?VSMONIAUTO")

@async_handle_denonlib_errors
async def back(self) -> ucapi.StatusCodes:
"""Send back command to AVR."""
Expand Down
22 changes: 20 additions & 2 deletions intg-denonavr/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@
import avr
from config import AvrDevice, create_entity_id
from ucapi import EntityTypes, MediaPlayer, StatusCodes
from ucapi.media_player import Attributes, Commands, DeviceClasses, Features, States
from ucapi.media_player import (
Attributes,
Commands,
DeviceClasses,
Features,
Options,
States,
)

_LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -70,15 +77,20 @@ def __init__(self, device: AvrDevice, receiver: avr.DenonDevice):
attributes[Attributes.SOUND_MODE] = ""
attributes[Attributes.SOUND_MODE_LIST] = []

self.simple_commands = ["OUTPUT_1", "OUTPUT_2", "OUTPUT_AUTO"]

options = {Options.SIMPLE_COMMANDS: self.simple_commands}

super().__init__(
entity_id,
device.name,
features,
attributes,
device_class=DeviceClasses.RECEIVER,
options=options,
)

async def command(self, cmd_id: str, params: dict[str, Any] | None = None) -> StatusCodes:
async def command(self, cmd_id: str, params: dict[str, Any] | None = None) -> StatusCodes: # pylint: disable=R0915
"""
Media-player entity command handler.
Expand Down Expand Up @@ -134,6 +146,12 @@ async def command(self, cmd_id: str, params: dict[str, Any] | None = None) -> St
res = await self._receiver.options()
elif cmd_id == Commands.INFO:
res = await self._receiver.info()
elif cmd_id == "OUTPUT_1":
res = await self._receiver.output_monitor_1()
elif cmd_id == "OUTPUT_2":
res = await self._receiver.output_monitor_2()
elif cmd_id == "OUTPUT_AUTO":
res = await self._receiver.output_monitor_auto()
else:
return StatusCodes.NOT_IMPLEMENTED

Expand Down

0 comments on commit d25846a

Please sign in to comment.