fix chromecast power state
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Fri, 5 Mar 2021 08:03:05 +0000 (09:03 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Fri, 5 Mar 2021 08:03:05 +0000 (09:03 +0100)
music_assistant/constants.py
music_assistant/mass.py
music_assistant/models/player.py
music_assistant/providers/chromecast/player.py

index d1d9379820ecb840087c2fa1f10297e0edde52d3..f218ece1ab730a5ff04ded7a79baeb44cc362dd7 100755 (executable)
@@ -1,6 +1,6 @@
 """All constants for Music Assistant."""
 
-__version__ = "0.1.6"
+__version__ = "0.1.7"
 REQUIRED_PYTHON_VER = "3.8"
 
 # configuration keys/attributes
index 253324e02e3d4ac32e12bdf2273aea2a6995e5b4..d554d348ed0bf9f626093cf52c9b2e20a96faa74 100644 (file)
@@ -286,9 +286,6 @@ class MusicAssistant:
         while isinstance(check_target, functools.partial):
             check_target = check_target.func
 
-        if self._exit:
-            LOGGER.debug("scheduling job %s while exiting!", check_target.__name__)
-
         if threading.current_thread() is not threading.main_thread():
             # called from other thread
             if asyncio.iscoroutine(check_target):
index d48c8ae21a1172841f96b62755145d3363c019d8..8968e086e47e5bbd77f6d35227ebba7e48c815af 100755 (executable)
@@ -393,6 +393,8 @@ class Player:
     @callback
     def update_state(self) -> None:
         """Call to update current player state in the player manager."""
+        if self.mass.exit:
+            return
         if not self.added_to_mass:
             if self.enabled:
                 # player is now enabled and can be added
index 442ebf4619e901fc1475b759ef147db0fc000e9a..7e36c71cb8f9c98588757f17817fb3e942a954f7 100644 (file)
@@ -69,9 +69,7 @@ class ChromecastPlayer(Player):
     @property
     def name(self) -> str:
         """Return name of this player."""
-        return (
-            self._chromecast.name if self._chromecast else self._cast_info.friendly_name
-        )
+        return self._cast_info.friendly_name
 
     @property
     def powered(self) -> bool:
@@ -84,7 +82,8 @@ class ChromecastPlayer(Player):
                 or self.media_status.player_is_paused
                 or self.media_status.player_is_idle
             )
-        return not self.cast_status.volume_muted and not self.cast_status.is_stand_by
+        # Chromecast does not support power so we (ab)use mute instead
+        return not self.cast_status.volume_muted
 
     @property
     def should_poll(self) -> bool:
@@ -94,8 +93,6 @@ class ChromecastPlayer(Player):
     @property
     def state(self) -> PlaybackState:
         """Return the state of the player."""
-        if self.cast_status and self.cast_status.is_stand_by:
-            return PlaybackState.Off
         if self.media_status is None:
             return PlaybackState.Stopped
         if self.media_status.player_is_playing: