Skip to content

Commit 23bcedc

Browse files
authored
Merge pull request #109 from JackJPowell/zeroconf-fixes
Improve zeroconf discovery
2 parents e25d1a8 + b74f3a6 commit 23bcedc

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

custom_components/unfoldedcircle/config_flow.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,9 @@ async def async_step_zeroconf(self, discovery_info: ZeroconfServiceInfo):
186186

187187
_LOGGER.debug("Unfolded circle remote found %s :", discovery_info)
188188
# Use mac address as unique id
189-
if mac_address:
190-
await self._async_set_unique_id_and_abort_if_already_configured(mac_address)
189+
if not mac_address:
190+
return self.async_abort(reason="no_mac")
191+
await self._async_set_unique_id_and_abort_if_already_configured(mac_address)
191192

192193
self.context.update(
193194
{
@@ -392,9 +393,9 @@ async def _async_set_unique_id_and_abort_if_already_configured(
392393
if index > 0:
393394
unique_id = unique_id[0:index]
394395

395-
await self.async_set_unique_id(unique_id, raise_on_progress=False)
396+
await self.async_set_unique_id(unique_id)
396397
self._abort_if_unique_id_configured(
397-
updates={CONF_MAC: self.discovery_info[CONF_MAC]},
398+
updates={CONF_MAC: unique_id},
398399
)
399400

400401
async def async_step_reauth(

custom_components/unfoldedcircle/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ async def device_info_from_discovery_info(discovery_info: ZeroconfServiceInfo) -
260260
response = await Remote.get_version_information(endpoint)
261261
device_name = response.get("device_name", None)
262262
if not device_name:
263-
device_name = "Remote Three"
263+
device_name = "Remote 3"
264264
mac_address = response.get("address", "").replace(":", "").lower()
265265
except Exception:
266266
pass

custom_components/unfoldedcircle/translations/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"already_configured": "Device is already configured",
55
"already_in_progress": "Device is pending setup",
66
"no_mac": "This device is not recognized as a valid Unfolded Circle Remote (No MAC Address)",
7-
"reauth_successful": "Reauthentication was successful"
7+
"reauth_successful": "Reauthentication was successful",
8+
"unique_id_required": "Device missing unique identification required for discovery."
89
},
910
"error": {
1011
"cannot_connect": "Failed to connect",

0 commit comments

Comments
 (0)