From 463a9777e5fbc541d0cb3fafa2fd087370be06e0 Mon Sep 17 00:00:00 2001 From: mang1985 Date: Fri, 12 Apr 2024 19:52:05 +0800 Subject: [PATCH] Fix issues with the option flow after upgrading the component. --- custom_components/ytube_music_player/const.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/custom_components/ytube_music_player/const.py b/custom_components/ytube_music_player/const.py index dff2b1c..f8a973b 100644 --- a/custom_components/ytube_music_player/const.py +++ b/custom_components/ytube_music_player/const.py @@ -317,8 +317,15 @@ def ensure_config(user_input): out[CONF_MAX_DATARATE] = DEFAULT_MAX_DATARATE if user_input is not None: + # for the old shuffle_mode setting. out.update(user_input) - + if isinstance(_shuffle_mode := out[CONF_SHUFFLE_MODE], int): + if _shuffle_mode >= 1: + out[CONF_SHUFFLE_MODE] = ALL_SHUFFLE_MODES[_shuffle_mode - 1] + else: + out[CONF_SHUFFLE_MODE] = PLAYMODE_DIRECT + _LOGGER.error(f"shuffle_mode: {_shuffle_mode} is a deprecated value and has been replaced with '{out[CONF_SHUFFLE_MODE]}'.") + return out