Skip to content

Commit

Permalink
make filename depend on entity id
Browse files Browse the repository at this point in the history
  • Loading branch information
KoljaWindeler committed Jan 7, 2024
1 parent a717b37 commit 8c4b973
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions custom_components/ytube_music_player/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand All @@ -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)
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ytube_music_player/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions custom_components/ytube_music_player/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit 8c4b973

Please sign in to comment.