diff --git a/custom_components/ytube_music_player/const.py b/custom_components/ytube_music_player/const.py index 5bbf6d0..a84b588 100644 --- a/custom_components/ytube_music_player/const.py +++ b/custom_components/ytube_music_player/const.py @@ -130,6 +130,7 @@ SERVICE_CALL_OFF_IS_IDLE_1X = "off_is_idle_1x" SERVICE_CALL_PAUSED_IS_IDLE = "paused_is_idle" SERIVCE_CALL_DEBUG_AS_ERROR = "debug_as_error" +SERVICE_CALL_LIKE_IN_NAME = "like_in_name" CONF_RECEIVERS = 'speakers' # list of speakers (media_players) diff --git a/custom_components/ytube_music_player/manifest.json b/custom_components/ytube_music_player/manifest.json index 2de2142..f20ed3f 100644 --- a/custom_components/ytube_music_player/manifest.json +++ b/custom_components/ytube_music_player/manifest.json @@ -14,5 +14,5 @@ "codeowners": [ "@KoljaWindeler" ], - "version": "0.20210410.01" + "version": "0.20210410.02" } diff --git a/custom_components/ytube_music_player/media_player.py b/custom_components/ytube_music_player/media_player.py index c2e0e9e..3f3ce5b 100644 --- a/custom_components/ytube_music_player/media_player.py +++ b/custom_components/ytube_music_player/media_player.py @@ -57,7 +57,8 @@ class yTubeMusicComponent(MediaPlayerEntity): def __init__(self, hass, config, name_add): self.hass = hass self._debug_as_error = False - self._name = config.get(CONF_NAME,DOMAIN+name_add) + self._org_name = config.get(CONF_NAME,DOMAIN+name_add) + self._name = self._org_name # confgurations can be either the full entity_id or just the name self._select_playlist = input_select.DOMAIN+"."+config.get(CONF_SELECT_PLAYLIST, DEFAULT_SELECT_PLAYLIST).replace(input_select.DOMAIN+".","") self._select_playMode = input_select.DOMAIN+"."+config.get(CONF_SELECT_PLAYMODE, DEFAULT_SELECT_PLAYMODE).replace(input_select.DOMAIN+".","") @@ -87,6 +88,7 @@ def __init__(self, hass, config, name_add): self._api = None self._js = "" self._update_needed = False + self._like_in_name = False self._remote_player = "" self._untrack_remote_player = None @@ -445,6 +447,8 @@ async def async_turn_off_media_player(self, data=None): self._attributes['_media_type'] = "" self._attributes['_media_id'] = "" self._attributes['current_track'] = 0 + if(self._like_in_name): + self._name = self._org_name self.async_schedule_update_ha_state() if(self._remote_player == ""): @@ -570,7 +574,7 @@ async def async_sync_player(self, entity_id=None, old_state=None, new_state=None else: self._state = STATE_OFF self.log_me('debug',"media player got turned off") - self.turn_off() + self.async_turn_off() elif(old_state.state == STATE_PLAYING and new_state.state == STATE_PAUSED and # workaround for SONOS (changes to PAUSED at the end of a track) (datetime.datetime.now()-self._last_auto_advance).total_seconds() > 10 and self._x_to_idle == STATE_PAUSED): self._allow_next = False @@ -922,9 +926,13 @@ async def async_get_track(self, entity_id=None, old_state=None, new_state=None, self._attributes['current_track'] = self._next_track_no self._attributes['videoId'] = _track['videoId'] if('likeStatus' in _track): - self._attributes['likeStatus'] = _track['likeStatus'] + self._attributes['likeStatus'] = _track['likeStatus'] + if(self._like_in_name): + self._name = self._org_name + " - " + _track['likeStatus'] else: self._attributes['likeStatus'] = "" + if(self._like_in_name): + self._name = self._org_name """ Find the unique track id. """ @@ -1334,6 +1342,8 @@ async def async_call_method(self, command=None, parameters=None): arg = 'LIKE' await self.hass.async_add_executor_job(self._api.rate_song,self._attributes['videoId'],arg) self._attributes['likeStatus'] = arg + if(self._like_in_name): + self._name = self._org_name + " - " + arg self.async_schedule_update_ha_state() self._tracks[self._next_track_no]['likeStatus'] = arg except: @@ -1389,6 +1399,10 @@ async def async_call_method(self, command=None, parameters=None): elif(command == SERIVCE_CALL_DEBUG_AS_ERROR): self._debug_as_error = True self.log_me('debug',"Posting debug messages as error until restart") + elif(command == SERVICE_CALL_LIKE_IN_NAME): + self._like_in_name = True + self._name = self._org_name + " - " + self._attributes['likeStatus'] + self.log_me('debug',"Showing like status in name until restart")