From: Marcel van der Veldt Date: Thu, 15 Feb 2024 09:33:31 +0000 (+0100) Subject: Fix HomeAssistant provider on supervised installs (#1082) X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=aca2b8f471a1e0f3d5351cbdb4fb39055e6db210;p=music-assistant-server.git Fix HomeAssistant provider on supervised installs (#1082) --- diff --git a/music_assistant/server/providers/hass/__init__.py b/music_assistant/server/providers/hass/__init__.py index 3d951e3a..42cecec3 100644 --- a/music_assistant/server/providers/hass/__init__.py +++ b/music_assistant/server/providers/hass/__init__.py @@ -91,30 +91,58 @@ async def get_config_entries( # set the retrieved token on the values object to pass along values[CONF_AUTH_TOKEN] = long_lived_token - entries = () - if not await async_is_supervisor(): - entries = ( + if await async_is_supervisor(): + # on supervisor, we use the internal url + # token set to None for auto retrieval + return ( ConfigEntry( key=CONF_URL, type=ConfigEntryType.STRING, - label="URL", + label=CONF_URL, required=True, - description="URL to your Home Assistant instance (e.g. http://192.168.1.1:8123)", - value=values.get(CONF_URL) if values else None, + default_value="http://supervisor/core/api", + value="http://supervisor/core/api", ), ConfigEntry( key=CONF_AUTH_TOKEN, - type=ConfigEntryType.SECURE_STRING, - label="Authentication token for HomeAssistant", - description="You need to link Music Assistant to your Home Assistant instance.", - action=CONF_ACTION_AUTH, - action_label="Authenticate Home Assistant", - depends_on=CONF_URL, - value=values.get(CONF_AUTH_TOKEN) if values else None, + type=ConfigEntryType.STRING, + label=CONF_AUTH_TOKEN, + required=False, + default_value=None, + value=None, ), ) - - return entries + # manual configuration + return ( + ConfigEntry( + key=CONF_URL, + type=ConfigEntryType.STRING, + label="URL", + required=True, + description="URL to your Home Assistant instance (e.g. http://192.168.1.1:8123)", + value=values.get(CONF_URL) if values else None, + ), + ConfigEntry( + key=CONF_ACTION_AUTH, + type=ConfigEntryType.ACTION, + label="(re)Authenticate Home Assistant", + description="Authenticate to your home assistant " + "instance and generate the long lived token.", + action=CONF_ACTION_AUTH, + depends_on=CONF_URL, + required=False, + ), + ConfigEntry( + key=CONF_AUTH_TOKEN, + type=ConfigEntryType.SECURE_STRING, + label="Authentication token for HomeAssistant", + description="You can either paste a Long Lived Token here manually or use the " + "'authenticate' button to generate a token for you with logging in.", + depends_on=CONF_URL, + value=values.get(CONF_AUTH_TOKEN) if values else None, + advanced=True, + ), + ) class HomeAssistant(PluginProvider):