mirror of
https://github.com/sudoxnym/fin-assistant.git
synced 2026-04-14 11:37:38 +00:00
FIX: config flow
This commit is contained in:
parent
32290197a8
commit
47f0770545
5 changed files with 37 additions and 15 deletions
|
|
@ -4,7 +4,11 @@ Jellyfin integration for Home Assistant
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
### 1.0
|
### 1.0.1
|
||||||
|
|
||||||
|
- Config flow fixes
|
||||||
|
|
||||||
|
### 1.0.0
|
||||||
|
|
||||||
- Initial public release
|
- Initial public release
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
"""The jellyfin component."""
|
"""The jellyfin component."""
|
||||||
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
@ -136,6 +137,8 @@ async def async_setup(hass: HomeAssistant, config: dict):
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
|
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
|
||||||
|
autolog("<<<")
|
||||||
|
|
||||||
global UPDATE_UNLISTENER
|
global UPDATE_UNLISTENER
|
||||||
if UPDATE_UNLISTENER:
|
if UPDATE_UNLISTENER:
|
||||||
UPDATE_UNLISTENER()
|
UPDATE_UNLISTENER()
|
||||||
|
|
@ -184,10 +187,13 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
|
||||||
hass.services.async_register(
|
hass.services.async_register(
|
||||||
DOMAIN, my_service, async_service_handler, schema=schema)
|
DOMAIN, my_service, async_service_handler, schema=schema)
|
||||||
|
|
||||||
for component in PLATFORMS:
|
await _jelly.start()
|
||||||
hass.data[DOMAIN][config.get(CONF_URL)][component] = {}
|
|
||||||
|
for platform in PLATFORMS:
|
||||||
|
hass.data[DOMAIN][config.get(CONF_URL)][platform] = {}
|
||||||
|
hass.data[DOMAIN][config.get(CONF_URL)][platform]["entities"] = []
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
hass.config_entries.async_forward_entry_setup(config_entry, component)
|
hass.config_entries.async_forward_entry_setup(config_entry, platform)
|
||||||
)
|
)
|
||||||
|
|
||||||
async_dispatcher_send(hass, SIGNAL_STATE_UPDATED)
|
async_dispatcher_send(hass, SIGNAL_STATE_UPDATED)
|
||||||
|
|
@ -198,12 +204,26 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
|
||||||
|
|
||||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, stop_jellyfin)
|
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, stop_jellyfin)
|
||||||
|
|
||||||
await _jelly.start()
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry):
|
||||||
|
_LOGGER.info("Unloading jellyfin")
|
||||||
|
|
||||||
async def _update_listener(hass, config_entry):
|
unload_ok = all(
|
||||||
|
await asyncio.gather(
|
||||||
|
*[
|
||||||
|
hass.config_entries.async_forward_entry_unload(config_entry, component)
|
||||||
|
for component in PLATFORMS
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
_jelly: JellyfinClientManager = hass.data[DOMAIN][config_entry.data.get(CONF_URL)]["manager"]
|
||||||
|
await _jelly.stop()
|
||||||
|
|
||||||
|
return unload_ok
|
||||||
|
|
||||||
|
async def _update_listener(hass: HomeAssistant, config_entry):
|
||||||
"""Update listener."""
|
"""Update listener."""
|
||||||
_LOGGER.debug("reload triggered")
|
_LOGGER.debug("reload triggered")
|
||||||
await hass.config_entries.async_reload(config_entry.entry_id)
|
await hass.config_entries.async_reload(config_entry.entry_id)
|
||||||
|
|
@ -644,10 +664,10 @@ class JellyfinClientManager(object):
|
||||||
await self.update_data()
|
await self.update_data()
|
||||||
|
|
||||||
async def stop(self):
|
async def stop(self):
|
||||||
autolog(">>>")
|
autolog("<<<")
|
||||||
|
|
||||||
await self.hass.async_add_executor_job(self.jf_client.stop)
|
|
||||||
self.is_stopping = True
|
self.is_stopping = True
|
||||||
|
await self.hass.async_add_executor_job(self.jf_client.stop)
|
||||||
|
|
||||||
@util.Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@util.Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
async def update_data (self):
|
async def update_data (self):
|
||||||
|
|
|
||||||
|
|
@ -120,9 +120,9 @@ class JellyfinOptionsFlowHandler(config_entries.OptionsFlow):
|
||||||
self._url = config_entry.data[CONF_URL] if CONF_URL in config_entry.data else None
|
self._url = config_entry.data[CONF_URL] if CONF_URL in config_entry.data else None
|
||||||
self._username = config_entry.data[CONF_USERNAME] if CONF_USERNAME in config_entry.data else None
|
self._username = config_entry.data[CONF_USERNAME] if CONF_USERNAME in config_entry.data else None
|
||||||
self._password = config_entry.data[CONF_PASSWORD] if CONF_PASSWORD in config_entry.data else None
|
self._password = config_entry.data[CONF_PASSWORD] if CONF_PASSWORD in config_entry.data else None
|
||||||
self._verify_ssl = config_entry.data[CONF_VERIFY_SSL] if CONF_VERIFY_SSL in config_entry.options else DEFAULT_VERIFY_SSL
|
self._verify_ssl = config_entry.data[CONF_VERIFY_SSL] if CONF_VERIFY_SSL in config_entry.data else DEFAULT_VERIFY_SSL
|
||||||
self._generate_upcoming = config_entry.data[CONF_GENERATE_UPCOMING] if CONF_GENERATE_UPCOMING in config_entry.options else False
|
self._generate_upcoming = config_entry.data[CONF_GENERATE_UPCOMING] if CONF_GENERATE_UPCOMING in config_entry.data else False
|
||||||
self._generate_yamc = config_entry.data[CONF_GENERATE_YAMC] if CONF_GENERATE_YAMC in config_entry.options else False
|
self._generate_yamc = config_entry.data[CONF_GENERATE_YAMC] if CONF_GENERATE_YAMC in config_entry.data else False
|
||||||
|
|
||||||
async def async_step_init(self, user_input=None):
|
async def async_step_init(self, user_input=None):
|
||||||
"""Manage the options."""
|
"""Manage the options."""
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"domain": "jellyfin",
|
"domain": "jellyfin",
|
||||||
"name": "Jellyfin",
|
"name": "Jellyfin",
|
||||||
"version": "1.0",
|
"version": "1.0.1",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/emby",
|
"documentation": "https://www.home-assistant.io/integrations/emby",
|
||||||
"requirements": ["jellyfin-apiclient-python==1.7.2"],
|
"requirements": ["jellyfin-apiclient-python==1.7.2"],
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,6 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entities):
|
async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entities):
|
||||||
|
|
||||||
_jelly: JellyfinClientManager = hass.data[DOMAIN][config_entry.data.get(CONF_URL)]["manager"]
|
_jelly: JellyfinClientManager = hass.data[DOMAIN][config_entry.data.get(CONF_URL)]["manager"]
|
||||||
hass.data[DOMAIN][_jelly.host][PLATFORM]["entities"] = []
|
|
||||||
|
|
||||||
async_add_entities([JellyfinSensor(_jelly)], True)
|
async_add_entities([JellyfinSensor(_jelly)], True)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue