core/homeassistant/components/roon/__init__.py

38 lines
1.0 KiB
Python
Raw Normal View History

Add roon media player integration (#37553) * Import roon code. * Fix flake8/pylint issues. * Fix lint issues, extend timeout, change contact infomation. * Add new files to .coveragerc * Make file executable. * Fix problem with integration not working after initial creation. * Improve logic unavailable players by caching data. * Review changes Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Review changes Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Review changes Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Review changes Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Review changes Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Review changes Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Review changes Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Review changes Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Review changes Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Review changes Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Update review suggestions * Rremove custom play action script. * Add test requirements. * Tidy manifest. * Missed fixes. * Refactor config_flow to use current pattern. * Add config_flow tests. * Refactor to use signal dispatch helpers. * Remove ToDo: for now. * Remove remaining zone / source logic for initial release, * Stop authenticate blocking, handle timeout. * Removed unneeded code. * Review comments update. * Fix comment. * Apply suggestions from code review Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Apply suggestions from code review Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Fix bug in seek. * Use sync rather than async update Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Upgrade library, remove exception now caught in library, * Review comments. * Review changes Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Check for duplicate host before adding. * Review comment. Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Remove unused code, revise turn_on/turn_off. * Sync translations. * Make interim timeout const. * Refactor tests. * Add tests with an existing config entry. * Apply suggestions from code review Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Remove CannotConnect Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-08-12 13:09:47 +00:00
"""Roon (www.roonlabs.com) component."""
from homeassistant.const import CONF_HOST
from homeassistant.helpers import device_registry as dr
from .const import DOMAIN
from .server import RoonServer
async def async_setup(hass, config):
"""Set up the Roon platform."""
hass.data[DOMAIN] = {}
return True
async def async_setup_entry(hass, entry):
"""Set up a roonserver from a config entry."""
host = entry.data[CONF_HOST]
roonserver = RoonServer(hass, entry)
if not await roonserver.async_setup():
return False
hass.data[DOMAIN][entry.entry_id] = roonserver
device_registry = await dr.async_get_registry(hass)
device_registry.async_get_or_create(
config_entry_id=entry.entry_id,
identifiers={(DOMAIN, entry.entry_id)},
manufacturer="Roonlabs",
name=host,
)
return True
async def async_unload_entry(hass, entry):
"""Unload a config entry."""
roonserver = hass.data[DOMAIN].pop(entry.entry_id)
return await roonserver.async_reset()