Example #1
0
async def async_setup(hass, config):
    """Set up the Plex component."""
    hass.data.setdefault(
        PLEX_DOMAIN,
        {
            SERVERS: {},
            DISPATCHERS: {},
            WEBSOCKETS: {},
            PLATFORMS_COMPLETED: {}
        },
    )

    await async_setup_services(hass)

    gdm = hass.data[PLEX_DOMAIN][GDM_SCANNER] = GDM()

    hass.data[PLEX_DOMAIN][GDM_DEBOUNCER] = Debouncer(
        hass,
        _LOGGER,
        cooldown=10,
        immediate=True,
        function=partial(gdm.scan, scan_for_clients=True),
    ).async_call

    return True
Example #2
0
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
    """Set up the Plex component."""
    hass.data.setdefault(
        PLEX_DOMAIN,
        {
            SERVERS: {},
            DISPATCHERS: {},
            WEBSOCKETS: {},
            PLATFORMS_COMPLETED: {}
        },
    )

    await async_setup_services(hass)

    gdm = hass.data[PLEX_DOMAIN][GDM_SCANNER] = GDM()

    def gdm_scan():
        _LOGGER.debug("Scanning for GDM clients")
        gdm.scan(scan_for_clients=True)

    hass.data[PLEX_DOMAIN][GDM_DEBOUNCER] = Debouncer(
        hass,
        _LOGGER,
        cooldown=10,
        immediate=True,
        function=gdm_scan,
    ).async_call

    return True
Example #3
0
async def async_discover(hass):
    """Scan for available Plex servers."""
    gdm = GDM()
    await hass.async_add_executor_job(gdm.scan)
    for server_data in gdm.entries:
        await hass.config_entries.flow.async_init(
            DOMAIN,
            context={CONF_SOURCE: config_entries.SOURCE_INTEGRATION_DISCOVERY},
            data=server_data,
        )
Example #4
0
def test_gdm(plex):
    gdm = GDM()

    gdm_enabled = plex.settings.get("GdmEnabled")

    gdm.scan(timeout=2)
    if gdm_enabled:
        assert len(gdm.entries)
    else:
        assert not len(gdm.entries)
    def __init__(self):
        self._monitor = Monitor()
        self._gdm = GDM()
        self._servers = {}

        self._start()