From 8c4b97316c97792d6aa592707091226f31948eaa Mon Sep 17 00:00:00 2001 From: Kolja Windeler Date: Sun, 7 Jan 2024 17:07:37 +0100 Subject: [PATCH] make filename depend on entity id --- custom_components/ytube_music_player/config_flow.py | 10 +++++----- custom_components/ytube_music_player/const.py | 2 +- .../ytube_music_player/translations/en.json | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/custom_components/ytube_music_player/config_flow.py b/custom_components/ytube_music_player/config_flow.py index d63f18f..6e0e619 100644 --- a/custom_components/ytube_music_player/config_flow.py +++ b/custom_components/ytube_music_player/config_flow.py @@ -60,7 +60,7 @@ async def async_step_oauth(self, user_input=None): # pylint: disable=unused-ar user_input[CONF_CODE] = self.code return self.async_show_form(step_id="oauth", data_schema=vol.Schema(await async_create_form(self.hass,user_input,1)), errors=self._errors) # if we get here then Oauth worked, right? - user_input[CONF_HEADER_PATH] = os.path.join(self.hass.config.path(STORAGE_DIR),DEFAULT_HEADER_FILENAME) + user_input[CONF_HEADER_PATH] = os.path.join(self.hass.config.path(STORAGE_DIR),DEFAULT_HEADER_FILENAME+user_input[CONF_NAME].replace(' ','_')+'.json') return self.async_show_form(step_id="finish", data_schema=vol.Schema(await async_create_form(self.hass,user_input,2)), errors=self._errors) @@ -69,6 +69,8 @@ async def async_step_finish(self,user_input=None): self._errors = {} if user_input is not None: self.data = user_input + _LOGGER.error("here2") + _LOGGER.error(user_input) await self.hass.async_add_executor_job(lambda: self.refresh_token.store_token(self.data[CONF_HEADER_PATH])) if(self.data[CONF_ADVANCE_CONFIG]): return self.async_show_form(step_id="adv_finish", data_schema=vol.Schema(await async_create_form(self.hass,user_input,3)), errors=self._errors) @@ -142,12 +144,10 @@ async def async_create_form(hass, user_input, page=1): user_input = ensure_config(user_input) data_schema = OrderedDict() - if(page == 1): - data_schema[vol.Required(CONF_CODE+"lala", default="https://www.google.com/device?user_code="+user_input[CONF_CODE]["user_code"])] = str # name of the component without domain - - elif(page == 2): + data_schema[vol.Required(CONF_CODE+"TT", default="https://www.google.com/device?user_code="+user_input[CONF_CODE]["user_code"])] = str # name of the component without domain data_schema[vol.Required(CONF_NAME, default=user_input[CONF_NAME])] = str # name of the component without domain + elif(page == 2): data_schema[vol.Required(CONF_RECEIVERS,default=user_input[CONF_RECEIVERS])] = selector({ "entity": { "multiple": "true", diff --git a/custom_components/ytube_music_player/const.py b/custom_components/ytube_music_player/const.py index e49c1d5..cd5621a 100644 --- a/custom_components/ytube_music_player/const.py +++ b/custom_components/ytube_music_player/const.py @@ -134,7 +134,7 @@ DEFAULT_SELECT_PLAYLIST = "" #input_select.DOMAIN + "." + DOMAIN + '_playlist' # cleared defaults to avoid further issues with multiple instances DEFAULT_SELECT_PLAYMODE = "" #input_select.DOMAIN + "." + DOMAIN + '_playmode' # cleared defaults to avoid further issues with multiple instances DEFAULT_SELECT_SPEAKERS = "" #input_select.DOMAIN + "." + DOMAIN + '_speakers' # cleared defaults to avoid further issues with multiple instances -DEFAULT_HEADER_FILENAME = 'ytube_header.json' +DEFAULT_HEADER_FILENAME = 'header_' DEFAULT_LIKE_IN_NAME = False DEFAULT_DEBUG_AS_ERROR = False DEFAULT_INIT_EXTRA_SENSOR = False diff --git a/custom_components/ytube_music_player/translations/en.json b/custom_components/ytube_music_player/translations/en.json index 197f529..2b38d7d 100644 --- a/custom_components/ytube_music_player/translations/en.json +++ b/custom_components/ytube_music_player/translations/en.json @@ -5,14 +5,14 @@ "oauth": { "description": "Please open the URL below in a seperate browser window. Once you completed the setup please return to this page and go on", "data": { - "code": "Google Device Code" + "codeTT": "Google Device Code", + "name": "Name for the entity (without 'media_player' prefix)" } }, "finish": { "description": "Please enter the basic data. Further information available at https://github.com/KoljaWindeler/ytube_music_player", "data": { - "name": "Name for the entity (without 'media_player' prefix)", - "speakers": "Select the default output device", + "speakers": "Select the default output device(s)", "header_path": "File path for the header file", "advance_config": "Show advance configuration" }