Fix crash in NAD integration (#34571)

Some amplifiers/receivers do not report any volume (due to them not
knowing), for example NAD C 356BEE is documented to return an empty
string for volume.

At least don't crash when we get None back.
This commit is contained in:
Frederik Gladhorn 2020-04-30 14:52:53 +02:00 committed by GitHub
parent 15b1a9ecea
commit a65edc8dc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -197,7 +197,10 @@ class NAD(MediaPlayerEntity):
else: else:
self._mute = True self._mute = True
self._volume = self.calc_volume(self._nad_receiver.main_volume("?")) volume = self._nad_receiver.main_volume("?")
# Some receivers cannot report the volume, e.g. C 356BEE,
# instead they only support stepping the volume up or down
self._volume = self.calc_volume(volume) if volume is not None else None
self._source = self._source_dict.get(self._nad_receiver.main_source("?")) self._source = self._source_dict.get(self._nad_receiver.main_source("?"))
def calc_volume(self, decibel): def calc_volume(self, decibel):