Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Added sound modes #15

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
9 changes: 3 additions & 6 deletions pymusiccast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,12 @@ def name(self, name):
def healthy_update_timer(self):
"""Check state of update timer."""
state = None

if self.update_status_timer and self.update_status_timer.is_alive():
_LOGGER.debug("%s: Timer: healthy", self._ip_address)
state = True
else:
_LOGGER.debug("%s: Timer: not healthy", self._ip_address)
state = False

return state

def initialize(self):
Expand Down Expand Up @@ -176,14 +174,12 @@ def handle_netusb(self, message):
"""Handle 'netusb' in message."""
# _LOGGER.debug("message: {}".format(message))
needs_update = 0

if self._yamaha:
if "play_info_updated" in message:
play_info = self.get_play_info()
# _LOGGER.debug(play_info)
if play_info:
new_media_status = MediaStatus(play_info, self._ip_address)

if self._yamaha.media_status != new_media_status:
# we need to send an update upwards
self._yamaha.new_media_status(new_media_status)
Expand All @@ -199,12 +195,10 @@ def handle_netusb(self, message):
new_status = STATE_PAUSED
else:
new_status = STATE_UNKNOWN

if self._yamaha.status is not new_status:
_LOGGER.debug("%s: playback: %s", self._ip_address, new_status)
self._yamaha.status = new_status
needs_update += 1

return needs_update

def handle_features(self, device_features):
Expand All @@ -219,6 +213,9 @@ def handle_features(self, device_features):
input_list = zone.get("input_list", [])
input_list.sort()
self.zones[zone_id].source_list = input_list
sound_program_list = zone.get("sound_program_list", [])
sound_program_list.sort()
self.zones[zone_id].sound_mode_list = sound_program_list

def handle_event(self, message):
"""Dispatch all event messages."""
Expand Down
4 changes: 4 additions & 0 deletions pymusiccast/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"setVolume": "http://{}/YamahaExtendedControl/v1/{}/setVolume",
"startDistribution": "http://{}/YamahaExtendedControl/v1/dist/startDistribution",
"stopDistribution": "http://{}/YamahaExtendedControl/v1/dist/stopDistribution",
"getSoundPrograms": (
"http://{}/YamahaExtendedControl" "/v1/{}/getSoundProgramList"
),
"setSoundProgram": "http://{}/YamahaExtendedControl/v1/{}/setSoundProgram",
}

STATE_UNKNOWN = "unknown"
Expand Down
19 changes: 19 additions & 0 deletions pymusiccast/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,22 @@ def update_dist_info(self, new_dist=None):
group_members = new_dist.get("group_members")
self._yamaha.group_members = group_members
self._status_sent = self.update_hass()

@property
def sound_mode_list(self):
"""Return sound_mode_list."""
return self._yamaha.sound_mode_list

@sound_mode_list.setter
def sound_mode_list(self, sound_mode_list):
"""Sets sound_mode_list."""
self._yamaha.sound_mode_list = sound_mode_list

def set_sound_program(self, sound_program):
"""Send sound program command."""
req_url = ENDPOINTS["setSoundProgram"].format(
self.ip_address, self.zone_id, sound_program
)
self._yamaha._sound_mode = sound_program
params = {"program": sound_program}
return request(req_url, params=params)