mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Add and use an async_fire_service_discovered helper (#23232)
This commit is contained in:
parent
b2a7699cdf
commit
b3a8b0056b
@ -269,6 +269,15 @@ def fire_service_discovered(hass, service, info):
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ha.callback
|
||||||
|
def async_fire_service_discovered(hass, service, info):
|
||||||
|
"""Fire the MQTT message."""
|
||||||
|
hass.bus.async_fire(EVENT_PLATFORM_DISCOVERED, {
|
||||||
|
ATTR_SERVICE: service,
|
||||||
|
ATTR_DISCOVERED: info
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
def load_fixture(filename):
|
def load_fixture(filename):
|
||||||
"""Load a fixture."""
|
"""Load a fixture."""
|
||||||
path = os.path.join(os.path.dirname(__file__), 'fixtures', filename)
|
path = os.path.join(os.path.dirname(__file__), 'fixtures', filename)
|
||||||
|
@ -15,7 +15,7 @@ from homeassistant.components.homekit_controller.const import (
|
|||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
async_fire_time_changed, fire_service_discovered, load_fixture)
|
async_fire_time_changed, async_fire_service_discovered, load_fixture)
|
||||||
|
|
||||||
|
|
||||||
class FakePairing:
|
class FakePairing:
|
||||||
@ -221,7 +221,7 @@ async def setup_test_accessories(hass, accessories, capitalize=False):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fire_service_discovered(hass, SERVICE_HOMEKIT, discovery_info)
|
async_fire_service_discovered(hass, SERVICE_HOMEKIT, discovery_info)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
return pairing
|
return pairing
|
||||||
@ -245,7 +245,7 @@ async def device_config_changed(hass, accessories):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fire_service_discovered(hass, SERVICE_HOMEKIT, discovery_info)
|
async_fire_service_discovered(hass, SERVICE_HOMEKIT, discovery_info)
|
||||||
|
|
||||||
# Wait for services to reconfigure
|
# Wait for services to reconfigure
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user