mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Only auth on enter_learning in response to errors for broadlink (#27341)
* Only auth on enter_learning in response to errors. * Remove extra newline. * Add missing break on successful attempt. * Avoid logging success message when auth is unsuccessful.
This commit is contained in:
parent
e3894d212c
commit
9f58e5d6ea
@ -75,18 +75,20 @@ def async_setup_service(hass, host, device):
|
|||||||
|
|
||||||
async def _learn_command(call):
|
async def _learn_command(call):
|
||||||
"""Learn a packet from remote."""
|
"""Learn a packet from remote."""
|
||||||
|
|
||||||
device = hass.data[DOMAIN][call.data[CONF_HOST]]
|
device = hass.data[DOMAIN][call.data[CONF_HOST]]
|
||||||
|
|
||||||
try:
|
for retry in range(DEFAULT_RETRY):
|
||||||
auth = await hass.async_add_executor_job(device.auth)
|
try:
|
||||||
except socket.timeout:
|
await hass.async_add_executor_job(device.enter_learning)
|
||||||
_LOGGER.error("Failed to connect to device, timeout")
|
break
|
||||||
return
|
except (socket.timeout, ValueError):
|
||||||
if not auth:
|
try:
|
||||||
_LOGGER.error("Failed to connect to device")
|
await hass.async_add_executor_job(device.auth)
|
||||||
return
|
except socket.timeout:
|
||||||
|
if retry == DEFAULT_RETRY - 1:
|
||||||
await hass.async_add_executor_job(device.enter_learning)
|
_LOGGER.error("Failed to enter learning mode")
|
||||||
|
return
|
||||||
|
|
||||||
_LOGGER.info("Press the key you want Home Assistant to learn")
|
_LOGGER.info("Press the key you want Home Assistant to learn")
|
||||||
start_time = utcnow()
|
start_time = utcnow()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user