Clean up command learning in the Broadlink integration (#36318)
This commit is contained in:
1 parent
7cc3102209
commit
38bb8ef4d2
3 files changed
+37
-59
No files matched your search
@@ -2,7 +2,6 @@
|
||||
import asyncio
|
||||
from base64 import b64decode, b64encode
|
||||
from binascii import unhexlify
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
import re
|
||||
|
||||
@@ -13,7 +12,7 @@ from homeassistant.const import CONF_HOST
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
from .const import CONF_PACKET, DOMAIN, SERVICE_LEARN, SERVICE_SEND
|
||||
from .const import CONF_PACKET, DOMAIN, LEARNING_TIMEOUT, SERVICE_LEARN, SERVICE_SEND
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -84,7 +83,7 @@ async def async_setup_service(hass, host, device):
|
||||
|
||||
_LOGGER.info("Press the key you want Home Assistant to learn")
|
||||
start_time = utcnow()
|
||||
while (utcnow() - start_time) < timedelta(seconds=20):
|
||||
while (utcnow() - start_time) < LEARNING_TIMEOUT:
|
||||
await asyncio.sleep(1)
|
||||
try:
|
||||
packet = await device.async_request(device.api.check_data)
|
||||
|
||||
Reference in new issue
Block a user