diff --git a/custom_components/xiaomi_miot/__init__.py b/custom_components/xiaomi_miot/__init__.py index fe963b56a..0b4ed3db1 100644 --- a/custom_components/xiaomi_miot/__init__.py +++ b/custom_components/xiaomi_miot/__init__.py @@ -14,7 +14,19 @@ core as hass_core, config_entries, ) -from homeassistant.const import * +from homeassistant.const import ( + ATTR_ENTITY_ID, + CONF_HOST, + CONF_NAME, + CONF_PASSWORD, + CONF_SCAN_INTERVAL, + CONF_TOKEN, + CONF_USERNAME, + STATE_OFF, + STATE_ON, + STATE_UNKNOWN, + SERVICE_RELOAD, +) from homeassistant.config import DATA_CUSTOMIZE from homeassistant.exceptions import PlatformNotReady from homeassistant.helpers.entity import ( diff --git a/custom_components/xiaomi_miot/alarm_control_panel.py b/custom_components/xiaomi_miot/alarm_control_panel.py index 24b417db2..4cdfaec38 100644 --- a/custom_components/xiaomi_miot/alarm_control_panel.py +++ b/custom_components/xiaomi_miot/alarm_control_panel.py @@ -1,8 +1,13 @@ """Support alarm_control_panel entity for Xiaomi Miot.""" import logging -from homeassistant.const import * # noqa: F401 -from homeassistant.components.alarm_control_panel.const import * +from homeassistant.const import ( + STATE_ALARM_ARMED_AWAY, + STATE_ALARM_ARMED_HOME, + STATE_ALARM_ARMED_NIGHT, + STATE_ALARM_DISARMED, + STATE_ALARM_TRIGGERED, +) from homeassistant.components.alarm_control_panel import ( DOMAIN as ENTITY_DOMAIN, AlarmControlPanelEntity, diff --git a/custom_components/xiaomi_miot/binary_sensor.py b/custom_components/xiaomi_miot/binary_sensor.py index 6913f3329..145773b87 100644 --- a/custom_components/xiaomi_miot/binary_sensor.py +++ b/custom_components/xiaomi_miot/binary_sensor.py @@ -5,7 +5,11 @@ from functools import partial from datetime import datetime -from homeassistant.const import * # noqa: F401 +from homeassistant.const import ( + STATE_OFF, + STATE_ON, + STATE_UNKNOWN, +) from homeassistant.components.binary_sensor import ( DOMAIN as ENTITY_DOMAIN, BinarySensorEntity, diff --git a/custom_components/xiaomi_miot/button.py b/custom_components/xiaomi_miot/button.py index 62a304291..051c5fb9d 100644 --- a/custom_components/xiaomi_miot/button.py +++ b/custom_components/xiaomi_miot/button.py @@ -1,7 +1,6 @@ """Support button entity for Xiaomi Miot.""" import logging -from homeassistant.const import * # noqa: F401 from homeassistant.components.button import ( DOMAIN as ENTITY_DOMAIN, ButtonEntity, diff --git a/custom_components/xiaomi_miot/camera.py b/custom_components/xiaomi_miot/camera.py index bc5dcfd64..b47f3cd63 100644 --- a/custom_components/xiaomi_miot/camera.py +++ b/custom_components/xiaomi_miot/camera.py @@ -12,7 +12,7 @@ from urllib.parse import urlencode from datetime import datetime, timedelta -from homeassistant.const import * # noqa: F401 +from homeassistant.const import STATE_IDLE from homeassistant.core import HomeAssistant from homeassistant.components.camera import ( DOMAIN as ENTITY_DOMAIN, diff --git a/custom_components/xiaomi_miot/climate.py b/custom_components/xiaomi_miot/climate.py index 0eb988a70..d9f25403b 100644 --- a/custom_components/xiaomi_miot/climate.py +++ b/custom_components/xiaomi_miot/climate.py @@ -2,8 +2,22 @@ import logging from enum import Enum -from homeassistant.const import * # noqa: F401 -from homeassistant.components.climate.const import * +from homeassistant.const import ( + ATTR_DEVICE_CLASS, + ATTR_TEMPERATURE, + ATTR_UNIT_OF_MEASUREMENT, + STATE_UNKNOWN, + UnitOfTemperature, +) +from homeassistant.components.climate.const import ( + ATTR_CURRENT_HUMIDITY, + ATTR_CURRENT_TEMPERATURE, + ATTR_HVAC_MODE, + DEFAULT_MAX_HUMIDITY, + DEFAULT_MIN_HUMIDITY, + HVACAction, + HVACMode, +) from homeassistant.components.climate import ( DOMAIN as ENTITY_DOMAIN, ClimateEntity, diff --git a/custom_components/xiaomi_miot/config_flow.py b/custom_components/xiaomi_miot/config_flow.py index b0188df80..91921bbb0 100644 --- a/custom_components/xiaomi_miot/config_flow.py +++ b/custom_components/xiaomi_miot/config_flow.py @@ -6,7 +6,14 @@ import voluptuous as vol from homeassistant import config_entries -from homeassistant.const import * +from homeassistant.const import ( + CONF_HOST, + CONF_NAME, + CONF_PASSWORD, + CONF_SCAN_INTERVAL, + CONF_TOKEN, + CONF_USERNAME, +) from homeassistant.core import callback, split_entity_id from homeassistant.util import yaml from homeassistant.components import persistent_notification diff --git a/custom_components/xiaomi_miot/core/miot_spec.py b/custom_components/xiaomi_miot/core/miot_spec.py index 73c73e17c..b511f8fb8 100644 --- a/custom_components/xiaomi_miot/core/miot_spec.py +++ b/custom_components/xiaomi_miot/core/miot_spec.py @@ -5,7 +5,20 @@ import time import re -from homeassistant.const import * +from homeassistant.const import ( + CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, + CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER, + CONCENTRATION_PARTS_PER_CUBIC_METER, + CONCENTRATION_PARTS_PER_MILLION, + LIGHT_LUX, + PERCENTAGE, + UnitOfElectricCurrent, + UnitOfElectricPotential, + UnitOfEnergy, + UnitOfPower, + UnitOfPressure, + UnitOfTemperature, +) from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass from homeassistant.helpers.storage import Store from homeassistant.helpers.aiohttp_client import async_get_clientsession diff --git a/custom_components/xiaomi_miot/core/xiaomi_cloud.py b/custom_components/xiaomi_miot/core/xiaomi_cloud.py index c84b0a5eb..06b2b19f3 100644 --- a/custom_components/xiaomi_miot/core/xiaomi_cloud.py +++ b/custom_components/xiaomi_miot/core/xiaomi_cloud.py @@ -11,7 +11,10 @@ from functools import partial from urllib import parse -from homeassistant.const import * +from homeassistant.const import ( + CONF_PASSWORD, + CONF_USERNAME, +) from homeassistant.helpers.storage import Store from homeassistant.components import persistent_notification diff --git a/custom_components/xiaomi_miot/cover.py b/custom_components/xiaomi_miot/cover.py index 72a961589..032cbfcad 100644 --- a/custom_components/xiaomi_miot/cover.py +++ b/custom_components/xiaomi_miot/cover.py @@ -5,7 +5,11 @@ from functools import partial from datetime import timedelta -from homeassistant.const import * # noqa: F401 +from homeassistant.const import ( + CONF_NAME, + CONF_HOST, + CONF_TOKEN, +) from homeassistant.core import callback from homeassistant.components.cover import ( DOMAIN as ENTITY_DOMAIN, diff --git a/custom_components/xiaomi_miot/device_tracker.py b/custom_components/xiaomi_miot/device_tracker.py index 0527a7ef0..3ed68c52e 100644 --- a/custom_components/xiaomi_miot/device_tracker.py +++ b/custom_components/xiaomi_miot/device_tracker.py @@ -3,7 +3,6 @@ import time from datetime import timedelta -from homeassistant.const import * # noqa: F401 from homeassistant.components.device_tracker import ( DOMAIN as ENTITY_DOMAIN, ) diff --git a/custom_components/xiaomi_miot/fan.py b/custom_components/xiaomi_miot/fan.py index b022f0764..c4b7b02bf 100644 --- a/custom_components/xiaomi_miot/fan.py +++ b/custom_components/xiaomi_miot/fan.py @@ -1,7 +1,6 @@ """Support for Xiaomi fans.""" import logging -from homeassistant.const import * # noqa: F401 from homeassistant.components.fan import ( DOMAIN as ENTITY_DOMAIN, FanEntity, diff --git a/custom_components/xiaomi_miot/humidifier.py b/custom_components/xiaomi_miot/humidifier.py index 14a82466c..ebd112edf 100644 --- a/custom_components/xiaomi_miot/humidifier.py +++ b/custom_components/xiaomi_miot/humidifier.py @@ -1,8 +1,10 @@ """Support for humidifier and dehumidifier.""" import logging -from homeassistant.const import * # noqa: F401 -from homeassistant.components.humidifier.const import * +from homeassistant.components.humidifier.const import ( + DEFAULT_MAX_HUMIDITY, + DEFAULT_MIN_HUMIDITY, +) from homeassistant.components.humidifier import ( DOMAIN as ENTITY_DOMAIN, HumidifierEntity, diff --git a/custom_components/xiaomi_miot/light.py b/custom_components/xiaomi_miot/light.py index 836ab845f..6ac5964cc 100644 --- a/custom_components/xiaomi_miot/light.py +++ b/custom_components/xiaomi_miot/light.py @@ -2,7 +2,6 @@ import logging from functools import partial -from homeassistant.const import * # noqa: F401 from homeassistant.components.light import ( DOMAIN as ENTITY_DOMAIN, LightEntity, diff --git a/custom_components/xiaomi_miot/media_player.py b/custom_components/xiaomi_miot/media_player.py index 0fac6c076..c26688a03 100644 --- a/custom_components/xiaomi_miot/media_player.py +++ b/custom_components/xiaomi_miot/media_player.py @@ -11,14 +11,22 @@ from functools import partial from urllib.parse import urlencode, urlparse, parse_qsl -from homeassistant.const import * # noqa: F401 -from homeassistant.components.media_player.const import * +from homeassistant.const import ( + ATTR_ATTRIBUTION, + ATTR_FRIENDLY_NAME, + CONF_HOST, +) +from homeassistant.components.media_player.const import ( + MEDIA_TYPE_MUSIC, + MEDIA_TYPE_VIDEO, + RepeatMode, +) from homeassistant.components.media_player import ( DOMAIN as ENTITY_DOMAIN, + MediaPlayerDeviceClass, MediaPlayerEntity, - MediaPlayerState, # v2022.10 MediaPlayerEntityFeature, # v2022.5 - MediaPlayerDeviceClass, + MediaPlayerState, # v2022.10 ) from homeassistant.components.homekit.const import EVENT_HOMEKIT_TV_REMOTE_KEY_PRESSED from homeassistant.core import HassJob @@ -422,10 +430,10 @@ async def async_update_play_status(self, now=None): if self._attr_volume_level is not None: self._attr_volume_level = self._attr_volume_level / 100 self._attr_repeat = { - 0: REPEAT_MODE_ONE, - 1: REPEAT_MODE_ALL, - 3: REPEAT_MODE_OFF, # random - }.get(info.get('loop_type'), REPEAT_MODE_OFF) + 0: RepeatMode.ONE, + 1: RepeatMode.ALL, + 3: RepeatMode.OFF, # random + }.get(info.get('loop_type'), RepeatMode.OFF) self._attr_media_content_id = mid self._attr_media_title = song.get('title') or song.get('name') diff --git a/custom_components/xiaomi_miot/number.py b/custom_components/xiaomi_miot/number.py index 6ef2be414..96dff2c66 100644 --- a/custom_components/xiaomi_miot/number.py +++ b/custom_components/xiaomi_miot/number.py @@ -1,7 +1,6 @@ """Support number entity for Xiaomi Miot.""" import logging -from homeassistant.const import * # noqa: F401 from homeassistant.components.number import ( DOMAIN as ENTITY_DOMAIN, NumberEntity, diff --git a/custom_components/xiaomi_miot/remote.py b/custom_components/xiaomi_miot/remote.py index b1c92305f..46dd46f00 100644 --- a/custom_components/xiaomi_miot/remote.py +++ b/custom_components/xiaomi_miot/remote.py @@ -3,7 +3,10 @@ import time from functools import partial -from homeassistant.const import * # noqa: F401 +from homeassistant.const import ( + CONF_HOST, + CONF_TOKEN, +) from homeassistant.components import remote from homeassistant.components.remote import ( DOMAIN as ENTITY_DOMAIN, diff --git a/custom_components/xiaomi_miot/select.py b/custom_components/xiaomi_miot/select.py index 328ddfbbb..e0baea43a 100644 --- a/custom_components/xiaomi_miot/select.py +++ b/custom_components/xiaomi_miot/select.py @@ -1,7 +1,6 @@ """Support select entity for Xiaomi Miot.""" import logging -from homeassistant.const import * # noqa: F401 from homeassistant.components.select import ( DOMAIN as ENTITY_DOMAIN, SelectEntity, diff --git a/custom_components/xiaomi_miot/sensor.py b/custom_components/xiaomi_miot/sensor.py index bf51505ef..3818a6819 100644 --- a/custom_components/xiaomi_miot/sensor.py +++ b/custom_components/xiaomi_miot/sensor.py @@ -6,7 +6,16 @@ from datetime import datetime, timedelta from functools import partial, cmp_to_key -from homeassistant.const import * # noqa: F401 +from homeassistant.const import ( + CONCENTRATION_PARTS_PER_MILLION, + CONF_HOST, + CONF_NAME, + CONF_TOKEN, + PERCENTAGE, + STATE_UNKNOWN, + UnitOfTemperature, + UnitOfTime, +) from homeassistant.helpers.entity import ( Entity, ) diff --git a/custom_components/xiaomi_miot/switch.py b/custom_components/xiaomi_miot/switch.py index d22c87c17..837db6f42 100644 --- a/custom_components/xiaomi_miot/switch.py +++ b/custom_components/xiaomi_miot/switch.py @@ -2,7 +2,13 @@ import logging import time -from homeassistant.const import * # noqa: F401 +from homeassistant.const import ( + CONF_HOST, + CONF_NAME, + CONF_TOKEN, + STATE_OFF, + STATE_ON, +) from homeassistant.components.switch import ( DOMAIN as ENTITY_DOMAIN, SwitchEntity, diff --git a/custom_components/xiaomi_miot/text.py b/custom_components/xiaomi_miot/text.py index cb822044f..6ff4b58cc 100644 --- a/custom_components/xiaomi_miot/text.py +++ b/custom_components/xiaomi_miot/text.py @@ -2,7 +2,6 @@ import logging import time -from homeassistant.const import * # noqa: F401 from homeassistant.components.text import ( DOMAIN as ENTITY_DOMAIN, TextEntity, diff --git a/custom_components/xiaomi_miot/vacuum.py b/custom_components/xiaomi_miot/vacuum.py index dc524cf84..06ef1392a 100644 --- a/custom_components/xiaomi_miot/vacuum.py +++ b/custom_components/xiaomi_miot/vacuum.py @@ -4,7 +4,10 @@ from datetime import timedelta from functools import partial -from homeassistant.const import * # noqa: F401 +from homeassistant.const import ( + STATE_IDLE, + STATE_PAUSED, +) from homeassistant.components.vacuum import ( # noqa: F401 DOMAIN as ENTITY_DOMAIN, StateVacuumEntity, diff --git a/custom_components/xiaomi_miot/water_heater.py b/custom_components/xiaomi_miot/water_heater.py index 97f6d776e..e01be2f41 100644 --- a/custom_components/xiaomi_miot/water_heater.py +++ b/custom_components/xiaomi_miot/water_heater.py @@ -2,7 +2,12 @@ import logging import math -from homeassistant.const import * # noqa: F401 +from homeassistant.const import ( + ATTR_TEMPERATURE, + STATE_OFF, + STATE_ON, + UnitOfTemperature, +) from homeassistant.components.water_heater import ( DOMAIN as ENTITY_DOMAIN, WaterHeaterEntity,