diff --git a/homeassistant/components/tuya/__init__.py b/homeassistant/components/tuya/__init__.py index fb5b4d759f3..ad6c8142828 100644 --- a/homeassistant/components/tuya/__init__.py +++ b/homeassistant/components/tuya/__init__.py @@ -1,7 +1,6 @@ """Support for Tuya Smart devices.""" from __future__ import annotations -import logging from typing import NamedTuple import requests @@ -34,14 +33,13 @@ from .const import ( CONF_PROJECT_TYPE, CONF_USERNAME, DOMAIN, + LOGGER, PLATFORMS, TUYA_DISCOVERY_NEW, TUYA_HA_SIGNAL_UPDATE_ENTITY, DPCode, ) -_LOGGER = logging.getLogger(__name__) - class HomeAssistantTuyaData(NamedTuple): """Tuya data stored in the Home Assistant data object.""" @@ -250,7 +248,7 @@ class DeviceListener(TuyaDeviceListener): def update_device(self, device: TuyaDevice) -> None: """Update device status.""" if device.id in self.device_ids: - _LOGGER.debug( + LOGGER.debug( "Received update for device %s: %s", device.id, self.device_manager.device_map[device.id].status, @@ -280,7 +278,7 @@ class DeviceListener(TuyaDeviceListener): @callback def async_remove_device(self, device_id: str) -> None: """Remove device from Home Assistant.""" - _LOGGER.debug("Remove device: %s", device_id) + LOGGER.debug("Remove device: %s", device_id) device_registry = dr.async_get(self.hass) device_entry = device_registry.async_get_device( identifiers={(DOMAIN, device_id)} diff --git a/homeassistant/components/tuya/base.py b/homeassistant/components/tuya/base.py index 928899940f4..38abac9a0fa 100644 --- a/homeassistant/components/tuya/base.py +++ b/homeassistant/components/tuya/base.py @@ -3,7 +3,6 @@ from __future__ import annotations from dataclasses import dataclass import json -import logging from typing import Any from tuya_iot import TuyaDevice, TuyaDeviceManager @@ -11,11 +10,9 @@ from tuya_iot import TuyaDevice, TuyaDeviceManager from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity import DeviceInfo, Entity -from .const import DOMAIN, TUYA_HA_SIGNAL_UPDATE_ENTITY +from .const import DOMAIN, LOGGER, TUYA_HA_SIGNAL_UPDATE_ENTITY from .util import remap_value -_LOGGER = logging.getLogger(__name__) - @dataclass class IntegerTypeData: @@ -151,5 +148,5 @@ class TuyaEntity(Entity): def _send_command(self, commands: list[dict[str, Any]]) -> None: """Send command to the device.""" - _LOGGER.debug("Sending commands for device %s: %s", self.device.id, commands) + LOGGER.debug("Sending commands for device %s: %s", self.device.id, commands) self.device_manager.send_commands(self.device.id, commands) diff --git a/homeassistant/components/tuya/config_flow.py b/homeassistant/components/tuya/config_flow.py index 08a913992a3..bf2c54a6158 100644 --- a/homeassistant/components/tuya/config_flow.py +++ b/homeassistant/components/tuya/config_flow.py @@ -1,7 +1,6 @@ """Config flow for Tuya.""" from __future__ import annotations -import logging from typing import Any from tuya_iot import AuthType, TuyaOpenAPI @@ -19,6 +18,7 @@ from .const import ( CONF_PASSWORD, CONF_USERNAME, DOMAIN, + LOGGER, SMARTLIFE_APP, TUYA_COUNTRIES, TUYA_RESPONSE_CODE, @@ -29,8 +29,6 @@ from .const import ( TUYA_SMART_APP, ) -_LOGGER = logging.getLogger(__name__) - class TuyaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): """Tuya Config Flow.""" @@ -78,7 +76,7 @@ class TuyaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): schema=data[CONF_APP_TYPE], ) - _LOGGER.debug("Response %s", response) + LOGGER.debug("Response %s", response) if response.get(TUYA_RESPONSE_SUCCESS, False): break diff --git a/homeassistant/components/tuya/cover.py b/homeassistant/components/tuya/cover.py index a450c38e2a0..2d18e947a06 100644 --- a/homeassistant/components/tuya/cover.py +++ b/homeassistant/components/tuya/cover.py @@ -2,7 +2,6 @@ from __future__ import annotations from dataclasses import dataclass -import logging from typing import Any from tuya_iot import TuyaDevice, TuyaDeviceManager @@ -27,8 +26,6 @@ from . import HomeAssistantTuyaData from .base import EnumTypeData, IntegerTypeData, TuyaEntity from .const import DOMAIN, TUYA_DISCOVERY_NEW, DPCode -_LOGGER = logging.getLogger(__name__) - @dataclass class TuyaCoverEntityDescription(CoverEntityDescription):