Migrate HEOS discovery to manifest (#24508)

* Migrate HEOS discovery to manifest

* Fix tests
This commit is contained in:
Paulus Schoutsen 2019-06-12 16:08:08 -07:00 committed by GitHub
parent 4c328e4959
commit f54ad26630
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 7 deletions

View file

@ -47,7 +47,6 @@ SERVICE_XIAOMI_GW = 'xiaomi_gw'
CONFIG_ENTRY_HANDLERS = {
SERVICE_DAIKIN: 'daikin',
SERVICE_HEOS: 'heos',
SERVICE_TELLDUSLIVE: 'tellduslive',
'sonos': 'sonos',
SERVICE_IGD: 'upnp',
@ -97,6 +96,7 @@ MIGRATED_SERVICE_HANDLERS = [
'deconz',
'esphome',
'google_cast',
SERVICE_HEOS,
'homekit',
'ikea_tradfri',
'philips_hue',

View file

@ -22,7 +22,7 @@ class HeosFlowHandler(config_entries.ConfigFlow):
VERSION = 1
CONNECTION_CLASS = config_entries.CONN_CLASS_LOCAL_PUSH
async def async_step_discovery(self, discovery_info):
async def async_step_ssdp(self, discovery_info):
"""Handle a discovered Heos device."""
# Store discovered host
friendly_name = "{} ({})".format(

View file

@ -6,6 +6,11 @@
"requirements": [
"pyheos==0.5.2"
],
"ssdp": {
"st": [
"urn:schemas-denon-com:device:ACT-Denon:1"
]
},
"dependencies": [],
"codeowners": [
"@andrewsayre"

View file

@ -15,5 +15,9 @@ SSDP = {
"hue"
]
},
"st": {}
"st": {
"urn:schemas-denon-com:device:ACT-Denon:1": [
"heos"
]
}
}

View file

@ -76,7 +76,7 @@ async def test_create_entry_when_friendly_name_valid(hass, controller):
async def test_discovery_shows_create_form(hass, controller, discovery_data):
"""Test discovery shows form to confirm setup and subsequent abort."""
await hass.config_entries.flow.async_init(
DOMAIN, context={'source': 'discovery'},
DOMAIN, context={'source': 'ssdp'},
data=discovery_data)
await hass.async_block_till_done()
assert len(hass.config_entries.flow.async_progress()) == 1
@ -87,7 +87,7 @@ async def test_discovery_shows_create_form(hass, controller, discovery_data):
discovery_data[CONF_HOST] = "127.0.0.2"
discovery_data[CONF_NAME] = "Bedroom"
await hass.config_entries.flow.async_init(
DOMAIN, context={'source': 'discovery'},
DOMAIN, context={'source': 'ssdp'},
data=discovery_data)
await hass.async_block_till_done()
assert len(hass.config_entries.flow.async_progress()) == 1
@ -103,6 +103,6 @@ async def test_disovery_flow_aborts_already_setup(
config_entry.add_to_hass(hass)
flow = HeosFlowHandler()
flow.hass = hass
result = await flow.async_step_discovery(discovery_data)
result = await flow.async_step_ssdp(discovery_data)
assert result['type'] == data_entry_flow.RESULT_TYPE_ABORT
assert result['reason'] == 'already_setup'

View file

@ -27,7 +27,8 @@ async def test_async_setup_creates_entry(hass, config):
assert entry.data == {CONF_HOST: '127.0.0.1'}
async def test_async_setup_updates_entry(hass, config_entry, config):
async def test_async_setup_updates_entry(hass, config_entry, config,
controller):
"""Test component setup updates entry from config."""
config[DOMAIN][CONF_HOST] = '127.0.0.2'
config_entry.add_to_hass(hass)