mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Update NAD states only when the device is on (#34809)
Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
98a056f7a9
commit
1510d5625a
@ -167,23 +167,28 @@ class NAD(MediaPlayerEntity):
|
||||
"""List of available input sources."""
|
||||
return sorted(list(self._reverse_mapping.keys()))
|
||||
|
||||
def update(self):
|
||||
@property
|
||||
def available(self):
|
||||
"""Return if device is available."""
|
||||
return self._state is not None
|
||||
|
||||
def update(self) -> None:
|
||||
"""Retrieve latest state."""
|
||||
if self._nad_receiver.main_power("?") == "Off":
|
||||
self._state = STATE_OFF
|
||||
else:
|
||||
self._state = STATE_ON
|
||||
power_state = self._nad_receiver.main_power("?")
|
||||
if not power_state:
|
||||
self._state = None
|
||||
return
|
||||
self._state = (
|
||||
STATE_ON if self._nad_receiver.main_power("?") == "On" else STATE_OFF
|
||||
)
|
||||
|
||||
if self._nad_receiver.main_mute("?") == "Off":
|
||||
self._mute = False
|
||||
else:
|
||||
self._mute = True
|
||||
|
||||
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("?"))
|
||||
if self._state == STATE_ON:
|
||||
self._mute = self._nad_receiver.main_mute("?") == "On"
|
||||
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("?"))
|
||||
|
||||
def calc_volume(self, decibel):
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user