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

Add new attribute query_result_json to expose query_result as json in squeezebox #115739

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions homeassistant/components/squeezebox/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
SERVICE_UNSYNC = "unsync"

ATTR_QUERY_RESULT = "query_result"
ATTR_QUERY_RESULT_JSON = "query_result_json"
ATTR_SYNC_GROUP = "sync_group"

SIGNAL_PLAYER_REDISCOVERED = "squeezebox_player_rediscovered"
Expand All @@ -83,6 +84,7 @@
ATTR_TO_PROPERTY = [
ATTR_QUERY_RESULT,
ATTR_SYNC_GROUP,
ATTR_QUERY_RESULT_JSON
]

SQUEEZEBOX_MODE = {
Expand Down Expand Up @@ -249,6 +251,7 @@ def __init__(self, player):
"""Initialize the SqueezeBox device."""
self._player = player
self._query_result = {}
self._query_result_json = {}
self._remove_dispatcher = None
self._attr_unique_id = format_mac(player.player_id)
self._attr_device_info = DeviceInfo(
Expand Down Expand Up @@ -409,6 +412,11 @@ def query_result(self):
"""Return the result from the call_query service."""
return self._query_result

@property
def query_result_json(self):
"""Return the result from the call_query service."""
return self._query_result_json

async def async_turn_off(self) -> None:
"""Turn off media player."""
await self._player.async_set_power(False)
Expand Down Expand Up @@ -562,6 +570,10 @@ async def async_call_query(self, command, parameters=None):
all_params.extend(parameters)
self._query_result = await self._player.async_query(*all_params)
_LOGGER.debug("call_query got result %s", self._query_result)
try:
self._query_result_json = json.dumps(self._query_result)
except:
self._query_result_json = "{}"

async def async_join_players(self, group_members: list[str]) -> None:
"""Add other Squeezebox players to this player's sync group.
Expand Down