Make general code quality improvements in the Broadlink integration (#58848)

* Create DEVICE_TYPES constant

* Rename _auth_fetch_firmware() to _get_firmware_version()

* Rename dev_type to device_type

* Use SOURCE_REAUTH from config_entries namespace

* Fix unidiomatic imports
This commit is contained in:
Felipe Martins Diel 2021-10-31 20:01:11 -03:00 committed by GitHub
parent adfebaf510
commit 3f61ff4f96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 22 deletions

View file

@ -34,10 +34,10 @@ from homeassistant.components.remote import (
)
from homeassistant.const import CONF_HOST, STATE_OFF
from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.storage import Store
from homeassistant.util.dt import utcnow
from homeassistant.util import dt
from .const import DOMAIN
from .entity import BroadlinkEntity
@ -332,8 +332,8 @@ class BroadlinkRemote(BroadlinkEntity, RemoteEntity, RestoreEntity):
)
try:
start_time = utcnow()
while (utcnow() - start_time) < LEARNING_TIMEOUT:
start_time = dt.utcnow()
while (dt.utcnow() - start_time) < LEARNING_TIMEOUT:
await asyncio.sleep(1)
try:
code = await self._device.async_request(self._device.api.check_data)
@ -367,8 +367,8 @@ class BroadlinkRemote(BroadlinkEntity, RemoteEntity, RestoreEntity):
)
try:
start_time = utcnow()
while (utcnow() - start_time) < LEARNING_TIMEOUT:
start_time = dt.utcnow()
while (dt.utcnow() - start_time) < LEARNING_TIMEOUT:
await asyncio.sleep(1)
found = await self._device.async_request(
self._device.api.check_frequency
@ -405,8 +405,8 @@ class BroadlinkRemote(BroadlinkEntity, RemoteEntity, RestoreEntity):
)
try:
start_time = utcnow()
while (utcnow() - start_time) < LEARNING_TIMEOUT:
start_time = dt.utcnow()
while (dt.utcnow() - start_time) < LEARNING_TIMEOUT:
await asyncio.sleep(1)
try:
code = await self._device.async_request(self._device.api.check_data)