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

Improve logging for selected options in Onkyo #139279

Merged
Merged
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
40 changes: 30 additions & 10 deletions homeassistant/components/onkyo/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@
self._volume_resolution = volume_resolution
self._max_volume = max_volume

self._options_sources = sources

Check warning on line 401 in homeassistant/components/onkyo/media_player.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/onkyo/media_player.py#L401

Added line #L401 was not covered by tests
self._source_lib_mapping = _input_source_lib_mappings(zone)
self._rev_source_lib_mapping = _rev_input_source_lib_mappings(zone)
self._source_mapping = {
Expand All @@ -409,6 +410,7 @@
value: key for key, value in self._source_mapping.items()
}

self._options_sound_modes = sound_modes

Check warning on line 413 in homeassistant/components/onkyo/media_player.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/onkyo/media_player.py#L413

Added line #L413 was not covered by tests
self._sound_mode_lib_mapping = _listening_mode_lib_mappings(zone)
self._rev_sound_mode_lib_mapping = _rev_listening_mode_lib_mappings(zone)
self._sound_mode_mapping = {
Expand Down Expand Up @@ -623,11 +625,20 @@
return

source_meaning = source.value_meaning
_LOGGER.error(
'Input source "%s" is invalid for entity: %s',
source_meaning,
self.entity_id,
)

if source not in self._options_sources:
_LOGGER.warning(

Check warning on line 630 in homeassistant/components/onkyo/media_player.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/onkyo/media_player.py#L629-L630

Added lines #L629 - L630 were not covered by tests
'Input source "%s" for entity: %s is not in the list. Check integration options',
source_meaning,
self.entity_id,
)
else:
_LOGGER.error(

Check warning on line 636 in homeassistant/components/onkyo/media_player.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/onkyo/media_player.py#L636

Added line #L636 was not covered by tests
'Input source "%s" is invalid for entity: %s',
source_meaning,
self.entity_id,
)

self._attr_source = source_meaning

@callback
Expand All @@ -638,11 +649,20 @@
return

sound_mode_meaning = sound_mode.value_meaning
_LOGGER.error(
'Listening mode "%s" is invalid for entity: %s',
sound_mode_meaning,
self.entity_id,
)

if sound_mode not in self._options_sound_modes:
_LOGGER.warning(

Check warning on line 654 in homeassistant/components/onkyo/media_player.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/onkyo/media_player.py#L653-L654

Added lines #L653 - L654 were not covered by tests
'Listening mode "%s" for entity: %s is not in the list. Check integration options',
sound_mode_meaning,
self.entity_id,
)
else:
_LOGGER.error(

Check warning on line 660 in homeassistant/components/onkyo/media_player.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/onkyo/media_player.py#L660

Added line #L660 was not covered by tests
'Listening mode "%s" is invalid for entity: %s',
sound_mode_meaning,
self.entity_id,
)

self._attr_sound_mode = sound_mode_meaning

@callback
Expand Down