Add a config entry mechanism to rediscover a discovery that was ignored (#30099)

* Mechanism to rediscover a discovery that was ignored

* Add core config entry tests for new rediscover step

* Add tests for homekit_controller implementation of async_step_rediscover

* Rename rediscover to unignore

* Comment the new ignore/unignore mechanisms
This commit is contained in:
Jc2k
2019-12-21 10:22:07 +00:00
committed by Paulus Schoutsen
parent 3911f24f75
commit b41480ae46
4 changed files with 257 additions and 0 deletions

View File

@@ -108,6 +108,38 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow):
),
)
async def async_step_unignore(self, user_input):
"""Rediscover a previously ignored discover."""
unique_id = user_input["unique_id"]
await self.async_set_unique_id(unique_id)
records = await self.hass.async_add_executor_job(self.controller.discover, 5)
for record in records:
if normalize_hkid(record["id"]) != unique_id:
continue
return await self.async_step_zeroconf(
{
"host": record["address"],
"port": record["port"],
"hostname": record["name"],
"type": "_hap._tcp.local.",
"name": record["name"],
"properties": {
"md": record["md"],
"pv": record["pv"],
"id": unique_id,
"c#": record["c#"],
"s#": record["s#"],
"ff": record["ff"],
"ci": record["ci"],
"sf": record["sf"],
"sh": "",
},
}
)
return self.async_abort(reason="no_devices")
async def async_step_zeroconf(self, discovery_info):
"""Handle a discovered HomeKit accessory.