Use start helper in squeezebox for server discovery (#115978)
parent
036b6fca25
commit
b521acb724
|
@ -28,7 +28,6 @@ from homeassistant.const import (
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
CONF_PORT,
|
CONF_PORT,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
EVENT_HOMEASSISTANT_START,
|
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import (
|
from homeassistant.helpers import (
|
||||||
|
@ -44,6 +43,7 @@ from homeassistant.helpers.dispatcher import (
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.event import async_call_later
|
from homeassistant.helpers.event import async_call_later
|
||||||
|
from homeassistant.helpers.start import async_at_start
|
||||||
from homeassistant.util.dt import utcnow
|
from homeassistant.util.dt import utcnow
|
||||||
|
|
||||||
from .browse_media import (
|
from .browse_media import (
|
||||||
|
@ -207,12 +207,7 @@ async def async_setup_entry(
|
||||||
platform.async_register_entity_service(SERVICE_UNSYNC, None, "async_unsync")
|
platform.async_register_entity_service(SERVICE_UNSYNC, None, "async_unsync")
|
||||||
|
|
||||||
# Start server discovery task if not already running
|
# Start server discovery task if not already running
|
||||||
if hass.is_running:
|
config_entry.async_on_unload(async_at_start(hass, start_server_discovery))
|
||||||
hass.async_create_task(start_server_discovery(hass))
|
|
||||||
else:
|
|
||||||
hass.bus.async_listen_once(
|
|
||||||
EVENT_HOMEASSISTANT_START, start_server_discovery(hass)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class SqueezeBoxEntity(MediaPlayerEntity):
|
class SqueezeBoxEntity(MediaPlayerEntity):
|
||||||
|
|
Loading…
Reference in New Issue