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

Added additional commands #290

Merged
merged 11 commits into from
May 4, 2024
57 changes: 56 additions & 1 deletion denonavr/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@
"command_set_all_zone_stereo",
"command_pause",
"command_play",
"command_cusor_up",
"command_cusor_down",
"command_cusor_left",
"command_cusor_right",
"command_cusor_enter",
"command_back",
"command_info",
"command_options",
"command_setup_open",
"command_setup_close",
"command_setup_query",
],
)
TelnetCommands = namedtuple(
Expand All @@ -68,7 +79,18 @@
"command_tonecontrol",
"command_bass",
"command_treble",
],
"command_cusor_up",
"command_cusor_down",
"command_cusor_left",
"command_cusor_right",
"command_cusor_enter",
"command_back",
"command_info",
"command_options",
"command_setup_open",
"command_setup_close",
"command_setup_query"
]
)

# AVR-X search patterns
Expand Down Expand Up @@ -327,6 +349,17 @@
COMMAND_MUTE_OFF_URL = "/goform/formiPhoneAppMute.xml?1+MuteOff"
COMMAND_SEL_SM_URL = "/goform/formiPhoneAppDirect.xml?MS"
COMMAND_SET_ZST_URL = "/goform/formiPhoneAppDirect.xml?MN"
COMMAND_CURSOR_UP = "/goform/formiPhoneAppDirect.xml?MNCUP"
COMMAND_CURSOR_DOWN = "/goform/formiPhoneAppDirect.xml?MNCDN"
COMMAND_CURSOR_LEFT = "/goform/formiPhoneAppDirect.xml?MNCLT"
COMMAND_CURSOR_RIGHT = "/goform/formiPhoneAppDirect.xml?MNCRT"
COMMAND_CURSOR_ENTER = "/goform/formiPhoneAppDirect.xml?MNENT"
COMMAND_BACK = "/goform/formiPhoneAppDirect.xml?MNRTN"
COMMAND_INFO = "/goform/formiPhoneAppDirect.xml?MNINF"
COMMAND_OPTIONS = "/goform/formiPhoneAppDirect.xml?MNOPT"
COMMAND_SETUP_OPEN = "/goform/formiPhoneAppDirect.xml?MNMEN%20ON"
COMMAND_SETUP_CLOSE = "/goform/formiPhoneAppDirect.xml?MNMEN%20OFF"
COMMAND_SETUP_QUERY = "/goform/formiPhoneAppDirect.xml?MNMEN?"

# Zone 2 URLs
STATUS_Z2_URL = "/goform/formZone2_Zone2XmlStatus.xml"
Expand Down Expand Up @@ -375,6 +408,17 @@
command_set_all_zone_stereo=COMMAND_SET_ZST_URL,
command_pause=COMMAND_PAUSE,
command_play=COMMAND_PLAY,
command_cusor_up=COMMAND_CURSOR_UP,
command_cusor_down=COMMAND_CURSOR_DOWN,
command_cusor_left=COMMAND_CURSOR_LEFT,
command_cusor_right=COMMAND_CURSOR_RIGHT,
command_cusor_enter=COMMAND_CURSOR_ENTER,
command_back=COMMAND_BACK,
command_info=COMMAND_INFO,
command_options=COMMAND_OPTIONS,
command_setup_open=COMMAND_SETUP_OPEN,
command_setup_close=COMMAND_SETUP_CLOSE,
command_setup_query=COMMAND_SETUP_QUERY
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines should be added to ZONE2_URLS and ZONE3_URLS too.
This might be the reason why the tests are failing.

)

ZONE2_URLS = ReceiverURLs(
Expand Down Expand Up @@ -503,6 +547,17 @@
command_tonecontrol="PSTONE CTRL ",
command_bass="PSBAS ",
command_treble="PSTRE ",
command_cusor_up="MNCUP",
command_cusor_down="MNCDN",
command_cusor_left="MNCLT",
command_cusor_right="MNCRT",
command_cusor_enter="MNENT",
command_back="MNRTN",
command_info="MNINF",
command_options="MNOPT",
command_setup_open="MNMEN ON",
command_setup_close="MNMEN OFF",
command_setup_query="MNMEN?"
)

ZONE2_TELNET_COMMANDS = TelnetCommands(
Expand Down
81 changes: 81 additions & 0 deletions denonavr/foundation.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,87 @@ async def async_power_off(self) -> None:
else:
await self.api.async_get_command(self.urls.command_power_standby)

async def async_cursor_up(self) -> None:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please call each of your new functions from DenonAVR class like in this example. Otherwise the methods won't be publicly accessible.

"""Cursor Up on receiver via HTTP get command."""
if self.telnet_available:
await self.telnet_api.async_send_commands(
self.telnet_commands.command_cusor_up
)
else:
await self.api.async_get_command(self.urls.command_cusor_up)

async def async_cursor_down(self) -> None:
"""Cursor Down on receiver via HTTP get command."""
if self.telnet_available:
await self.telnet_api.async_send_commands(
self.telnet_commands.command_cusor_down
)
else:
await self.api.async_get_command(self.urls.command_cusor_down)

async def async_cursor_left(self) -> None:
"""Cursor Left on receiver via HTTP get command."""
if self.telnet_available:
await self.telnet_api.async_send_commands(
self.telnet_commands.command_cusor_left
)
else:
await self.api.async_get_command(self.urls.command_cusor_left)

async def async_cursor_right(self) -> None:
"""Cursor Right on receiver via HTTP get command."""
if self.telnet_available:
await self.telnet_api.async_send_commands(
self.telnet_commands.command_cusor_right
)
else:
await self.api.async_get_command(self.urls.command_cusor_right)

async def async_cursor_enter(self) -> None:
"""Cursor Enter on receiver via HTTP get command."""
if self.telnet_available:
await self.telnet_api.async_send_commands(
self.telnet_commands.command_cusor_enter
)
else:
await self.api.async_get_command(self.urls.command_cusor_enter)

async def async_back(self) -> None:
"""Back command on receiver via HTTP get command."""
if self.telnet_available:
await self.telnet_api.async_send_commands(self.telnet_commands.command_back)
else:
await self.api.async_get_command(self.urls.command_back)

async def async_info(self) -> None:
"""Info OSD on receiver via HTTP get command."""
if self.telnet_available:
await self.telnet_api.async_send_commands(self.telnet_commands.command_info)
else:
await self.api.async_get_command(self.urls.command_info)

async def async_options(self) -> None:
"""Options menu on receiver via HTTP get command."""
await self.api.async_get_command(self.urls.command_options)

async def async_settings_menu(self) -> None:
"""Options menu on receiver via HTTP get command."""
res = await self.api.async_get_command(self.urls.command_setup_query)
if self.telnet_available:
if res is not None and res == "MNMEN ON":
await self.telnet_api.async_send_commands(
self.telnet_commands.command_setup_close
)
else:
await self.telnet_api.async_send_commands(
self.telnet_commands.command_setup_open
)
else:
if res is not None and res == "MNMEN ON":
await self.api.async_get_command(self.urls.command_setup_close)
else:
await self.api.async_get_command(self.urls.command_setup_open)


@attr.s(auto_attribs=True, on_setattr=DENON_ATTR_SETATTR)
class DenonAVRFoundation:
Expand Down
Loading