Use new CONF_MODEL core constant (2/3) (#68831)
* Use CONF_MODEL in xiaomi_miio * Use CONF_MODEL in xiaomi Co-authored-by: epenet <epenet@users.noreply.github.com>pull/68840/head
parent
a29990a784
commit
014aadb299
|
@ -12,6 +12,7 @@ from homeassistant.components.camera import PLATFORM_SCHEMA, Camera
|
|||
from homeassistant.components.ffmpeg import get_ffmpeg_manager
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_MODEL,
|
||||
CONF_NAME,
|
||||
CONF_PASSWORD,
|
||||
CONF_PATH,
|
||||
|
@ -34,7 +35,6 @@ DEFAULT_USERNAME = "root"
|
|||
DEFAULT_ARGUMENTS = "-pred 1"
|
||||
|
||||
CONF_FFMPEG_ARGUMENTS = "ffmpeg_arguments"
|
||||
CONF_MODEL = "model"
|
||||
|
||||
MODEL_YI = "yi"
|
||||
MODEL_XIAOFANG = "xiaofang"
|
||||
|
|
|
@ -32,7 +32,7 @@ from miio import (
|
|||
from miio.gateway.gateway import GatewayException
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, CONF_TOKEN, Platform
|
||||
from homeassistant.const import CONF_HOST, CONF_MODEL, CONF_TOKEN, Platform
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
@ -43,7 +43,6 @@ from .const import (
|
|||
CONF_DEVICE,
|
||||
CONF_FLOW_TYPE,
|
||||
CONF_GATEWAY,
|
||||
CONF_MODEL,
|
||||
DOMAIN,
|
||||
KEY_COORDINATOR,
|
||||
KEY_DEVICE,
|
||||
|
|
|
@ -5,14 +5,13 @@ from miio import AirQualityMonitor, AirQualityMonitorCGDN1, DeviceException
|
|||
|
||||
from homeassistant.components.air_quality import AirQualityEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, CONF_TOKEN
|
||||
from homeassistant.const import CONF_HOST, CONF_MODEL, CONF_TOKEN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import (
|
||||
CONF_DEVICE,
|
||||
CONF_FLOW_TYPE,
|
||||
CONF_MODEL,
|
||||
MODEL_AIRQUALITYMONITOR_B1,
|
||||
MODEL_AIRQUALITYMONITOR_CGDN1,
|
||||
MODEL_AIRQUALITYMONITOR_S1,
|
||||
|
|
|
@ -11,6 +11,7 @@ from homeassistant.components.binary_sensor import (
|
|||
BinarySensorEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_MODEL
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -19,7 +20,6 @@ from . import VacuumCoordinatorDataAttributes
|
|||
from .const import (
|
||||
CONF_DEVICE,
|
||||
CONF_FLOW_TYPE,
|
||||
CONF_MODEL,
|
||||
DOMAIN,
|
||||
KEY_COORDINATOR,
|
||||
KEY_DEVICE,
|
||||
|
|
|
@ -10,12 +10,12 @@ from homeassistant.components.button import (
|
|||
ButtonEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_MODEL
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import (
|
||||
CONF_MODEL,
|
||||
DOMAIN,
|
||||
KEY_COORDINATOR,
|
||||
KEY_DEVICE,
|
||||
|
|
|
@ -9,7 +9,7 @@ import voluptuous as vol
|
|||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.config_entries import SOURCE_REAUTH
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_TOKEN
|
||||
from homeassistant.const import CONF_HOST, CONF_MODEL, CONF_NAME, CONF_TOKEN
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.device_registry import format_mac
|
||||
|
@ -24,7 +24,6 @@ from .const import (
|
|||
CONF_GATEWAY,
|
||||
CONF_MAC,
|
||||
CONF_MANUAL,
|
||||
CONF_MODEL,
|
||||
DEFAULT_CLOUD_COUNTRY,
|
||||
DOMAIN,
|
||||
MODELS_ALL,
|
||||
|
|
|
@ -13,7 +13,6 @@ DOMAIN = "xiaomi_miio"
|
|||
CONF_FLOW_TYPE = "config_flow_device"
|
||||
CONF_GATEWAY = "gateway"
|
||||
CONF_DEVICE = "device"
|
||||
CONF_MODEL = "model"
|
||||
CONF_MAC = "mac"
|
||||
CONF_CLOUD_USERNAME = "cloud_username"
|
||||
CONF_CLOUD_PASSWORD = "cloud_password"
|
||||
|
|
|
@ -8,7 +8,7 @@ from typing import Any, TypeVar
|
|||
from construct.core import ChecksumError
|
||||
from miio import Device, DeviceException
|
||||
|
||||
from homeassistant.const import ATTR_CONNECTIONS
|
||||
from homeassistant.const import ATTR_CONNECTIONS, CONF_MODEL
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
|
@ -16,7 +16,7 @@ from homeassistant.helpers.update_coordinator import (
|
|||
DataUpdateCoordinator,
|
||||
)
|
||||
|
||||
from .const import CONF_MAC, CONF_MODEL, DOMAIN, AuthException, SetupException
|
||||
from .const import CONF_MAC, DOMAIN, AuthException, SetupException
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ from homeassistant.components.fan import (
|
|||
FanEntity,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.const import ATTR_ENTITY_ID, CONF_MODEL
|
||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -84,8 +84,6 @@ _LOGGER = logging.getLogger(__name__)
|
|||
|
||||
DATA_KEY = "fan.xiaomi_miio"
|
||||
|
||||
CONF_MODEL = "model"
|
||||
|
||||
ATTR_MODE_NATURE = "Nature"
|
||||
ATTR_MODE_NORMAL = "Normal"
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ from miio.airhumidifier_mjjsq import OperationMode as AirhumidifierMjjsqOperatio
|
|||
from homeassistant.components.humidifier import HumidifierDeviceClass, HumidifierEntity
|
||||
from homeassistant.components.humidifier.const import SUPPORT_MODES
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_MODE
|
||||
from homeassistant.const import ATTR_MODE, CONF_MODEL
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.util.percentage import percentage_to_ranged_value
|
||||
|
@ -17,7 +17,6 @@ from homeassistant.util.percentage import percentage_to_ranged_value
|
|||
from .const import (
|
||||
CONF_DEVICE,
|
||||
CONF_FLOW_TYPE,
|
||||
CONF_MODEL,
|
||||
DOMAIN,
|
||||
KEY_COORDINATOR,
|
||||
KEY_DEVICE,
|
||||
|
|
|
@ -25,7 +25,7 @@ from homeassistant.components.light import (
|
|||
LightEntity,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_ENTITY_ID, CONF_HOST, CONF_TOKEN
|
||||
from homeassistant.const import ATTR_ENTITY_ID, CONF_HOST, CONF_MODEL, CONF_TOKEN
|
||||
from homeassistant.core import HomeAssistant, ServiceCall
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
@ -36,7 +36,6 @@ from .const import (
|
|||
CONF_DEVICE,
|
||||
CONF_FLOW_TYPE,
|
||||
CONF_GATEWAY,
|
||||
CONF_MODEL,
|
||||
DOMAIN,
|
||||
KEY_COORDINATOR,
|
||||
MODELS_LIGHT_BULB,
|
||||
|
|
|
@ -6,7 +6,7 @@ from dataclasses import dataclass
|
|||
from homeassistant.components.number import NumberEntity, NumberEntityDescription
|
||||
from homeassistant.components.number.const import DOMAIN as PLATFORM_DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import DEGREE, TIME_MINUTES
|
||||
from homeassistant.const import CONF_MODEL, DEGREE, TIME_MINUTES
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
|
@ -15,7 +15,6 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||
from .const import (
|
||||
CONF_DEVICE,
|
||||
CONF_FLOW_TYPE,
|
||||
CONF_MODEL,
|
||||
DOMAIN,
|
||||
FEATURE_FLAGS_AIRFRESH,
|
||||
FEATURE_FLAGS_AIRFRESH_A1,
|
||||
|
|
|
@ -12,6 +12,7 @@ from miio.fan_common import LedBrightness as FanLedBrightness
|
|||
|
||||
from homeassistant.components.select import SelectEntity, SelectEntityDescription
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_MODEL
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -19,7 +20,6 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||
from .const import (
|
||||
CONF_DEVICE,
|
||||
CONF_FLOW_TYPE,
|
||||
CONF_MODEL,
|
||||
DOMAIN,
|
||||
FEATURE_SET_LED_BRIGHTNESS,
|
||||
KEY_COORDINATOR,
|
||||
|
|
|
@ -28,6 +28,7 @@ from homeassistant.const import (
|
|||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||
CONCENTRATION_PARTS_PER_MILLION,
|
||||
CONF_HOST,
|
||||
CONF_MODEL,
|
||||
CONF_TOKEN,
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
|
@ -49,7 +50,6 @@ from .const import (
|
|||
CONF_DEVICE,
|
||||
CONF_FLOW_TYPE,
|
||||
CONF_GATEWAY,
|
||||
CONF_MODEL,
|
||||
DOMAIN,
|
||||
KEY_COORDINATOR,
|
||||
KEY_DEVICE,
|
||||
|
|
|
@ -21,6 +21,7 @@ from homeassistant.const import (
|
|||
ATTR_MODE,
|
||||
ATTR_TEMPERATURE,
|
||||
CONF_HOST,
|
||||
CONF_MODEL,
|
||||
CONF_TOKEN,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||
|
@ -32,7 +33,6 @@ from .const import (
|
|||
CONF_DEVICE,
|
||||
CONF_FLOW_TYPE,
|
||||
CONF_GATEWAY,
|
||||
CONF_MODEL,
|
||||
DOMAIN,
|
||||
FEATURE_FLAGS_AIRFRESH,
|
||||
FEATURE_FLAGS_AIRFRESH_A1,
|
||||
|
|
|
@ -9,7 +9,7 @@ import pytest
|
|||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.xiaomi_miio import const
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_TOKEN
|
||||
from homeassistant.const import CONF_HOST, CONF_MODEL, CONF_NAME, CONF_TOKEN
|
||||
|
||||
from . import TEST_MAC
|
||||
|
||||
|
@ -169,7 +169,7 @@ async def test_config_flow_gateway_success(hass):
|
|||
const.CONF_CLOUD_COUNTRY: None,
|
||||
CONF_HOST: TEST_HOST,
|
||||
CONF_TOKEN: TEST_TOKEN,
|
||||
const.CONF_MODEL: TEST_MODEL,
|
||||
CONF_MODEL: TEST_MODEL,
|
||||
const.CONF_MAC: TEST_MAC,
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ async def test_config_flow_gateway_cloud_success(hass):
|
|||
const.CONF_CLOUD_COUNTRY: TEST_CLOUD_COUNTRY,
|
||||
CONF_HOST: TEST_HOST,
|
||||
CONF_TOKEN: TEST_TOKEN,
|
||||
const.CONF_MODEL: TEST_MODEL,
|
||||
CONF_MODEL: TEST_MODEL,
|
||||
const.CONF_MAC: TEST_MAC,
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ async def test_config_flow_gateway_cloud_multiple_success(hass):
|
|||
const.CONF_CLOUD_COUNTRY: TEST_CLOUD_COUNTRY,
|
||||
CONF_HOST: TEST_HOST2,
|
||||
CONF_TOKEN: TEST_TOKEN,
|
||||
const.CONF_MODEL: TEST_MODEL,
|
||||
CONF_MODEL: TEST_MODEL,
|
||||
const.CONF_MAC: TEST_MAC2,
|
||||
}
|
||||
|
||||
|
@ -425,7 +425,7 @@ async def test_zeroconf_gateway_success(hass):
|
|||
const.CONF_CLOUD_COUNTRY: TEST_CLOUD_COUNTRY,
|
||||
CONF_HOST: TEST_HOST,
|
||||
CONF_TOKEN: TEST_TOKEN,
|
||||
const.CONF_MODEL: TEST_MODEL,
|
||||
CONF_MODEL: TEST_MODEL,
|
||||
const.CONF_MAC: TEST_MAC,
|
||||
}
|
||||
|
||||
|
@ -581,7 +581,7 @@ async def test_import_flow_success(hass):
|
|||
const.CONF_CLOUD_COUNTRY: None,
|
||||
CONF_HOST: TEST_HOST,
|
||||
CONF_TOKEN: TEST_TOKEN,
|
||||
const.CONF_MODEL: const.MODELS_SWITCH[0],
|
||||
CONF_MODEL: const.MODELS_SWITCH[0],
|
||||
const.CONF_MAC: TEST_MAC,
|
||||
}
|
||||
|
||||
|
@ -661,7 +661,7 @@ async def test_config_flow_step_device_manual_model_succes(hass):
|
|||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{const.CONF_MODEL: overwrite_model},
|
||||
{CONF_MODEL: overwrite_model},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
|
@ -673,7 +673,7 @@ async def test_config_flow_step_device_manual_model_succes(hass):
|
|||
const.CONF_CLOUD_COUNTRY: None,
|
||||
CONF_HOST: TEST_HOST,
|
||||
CONF_TOKEN: TEST_TOKEN,
|
||||
const.CONF_MODEL: overwrite_model,
|
||||
CONF_MODEL: overwrite_model,
|
||||
const.CONF_MAC: None,
|
||||
}
|
||||
|
||||
|
@ -717,7 +717,7 @@ async def config_flow_device_success(hass, model_to_test):
|
|||
const.CONF_CLOUD_COUNTRY: None,
|
||||
CONF_HOST: TEST_HOST,
|
||||
CONF_TOKEN: TEST_TOKEN,
|
||||
const.CONF_MODEL: model_to_test,
|
||||
CONF_MODEL: model_to_test,
|
||||
const.CONF_MAC: TEST_MAC,
|
||||
}
|
||||
|
||||
|
@ -763,7 +763,7 @@ async def config_flow_generic_roborock(hass):
|
|||
const.CONF_CLOUD_COUNTRY: None,
|
||||
CONF_HOST: TEST_HOST,
|
||||
CONF_TOKEN: TEST_TOKEN,
|
||||
const.CONF_MODEL: DUMMY_MODEL,
|
||||
CONF_MODEL: DUMMY_MODEL,
|
||||
const.CONF_MAC: TEST_MAC,
|
||||
}
|
||||
|
||||
|
@ -817,7 +817,7 @@ async def zeroconf_device_success(hass, zeroconf_name_to_test, model_to_test):
|
|||
const.CONF_CLOUD_COUNTRY: None,
|
||||
CONF_HOST: TEST_HOST,
|
||||
CONF_TOKEN: TEST_TOKEN,
|
||||
const.CONF_MODEL: model_to_test,
|
||||
CONF_MODEL: model_to_test,
|
||||
const.CONF_MAC: TEST_MAC,
|
||||
}
|
||||
|
||||
|
@ -860,7 +860,7 @@ async def test_options_flow(hass):
|
|||
const.CONF_FLOW_TYPE: const.CONF_GATEWAY,
|
||||
CONF_HOST: TEST_HOST,
|
||||
CONF_TOKEN: TEST_TOKEN,
|
||||
const.CONF_MODEL: TEST_MODEL,
|
||||
CONF_MODEL: TEST_MODEL,
|
||||
const.CONF_MAC: TEST_MAC,
|
||||
},
|
||||
title=TEST_NAME,
|
||||
|
@ -900,7 +900,7 @@ async def test_options_flow_incomplete(hass):
|
|||
const.CONF_FLOW_TYPE: const.CONF_GATEWAY,
|
||||
CONF_HOST: TEST_HOST,
|
||||
CONF_TOKEN: TEST_TOKEN,
|
||||
const.CONF_MODEL: TEST_MODEL,
|
||||
CONF_MODEL: TEST_MODEL,
|
||||
const.CONF_MAC: TEST_MAC,
|
||||
},
|
||||
title=TEST_NAME,
|
||||
|
@ -938,7 +938,7 @@ async def test_reauth(hass):
|
|||
const.CONF_FLOW_TYPE: const.CONF_GATEWAY,
|
||||
CONF_HOST: TEST_HOST,
|
||||
CONF_TOKEN: TEST_TOKEN,
|
||||
const.CONF_MODEL: TEST_MODEL,
|
||||
CONF_MODEL: TEST_MODEL,
|
||||
const.CONF_MAC: TEST_MAC,
|
||||
},
|
||||
title=TEST_NAME,
|
||||
|
@ -986,6 +986,6 @@ async def test_reauth(hass):
|
|||
const.CONF_CLOUD_COUNTRY: TEST_CLOUD_COUNTRY,
|
||||
CONF_HOST: TEST_HOST,
|
||||
CONF_TOKEN: TEST_TOKEN,
|
||||
const.CONF_MODEL: TEST_MODEL,
|
||||
CONF_MODEL: TEST_MODEL,
|
||||
const.CONF_MAC: TEST_MAC,
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ from homeassistant.components.xiaomi_miio.const import (
|
|||
CONF_DEVICE,
|
||||
CONF_FLOW_TYPE,
|
||||
CONF_MAC,
|
||||
CONF_MODEL,
|
||||
DOMAIN as XIAOMI_DOMAIN,
|
||||
MODELS_VACUUM,
|
||||
)
|
||||
|
@ -45,6 +44,7 @@ from homeassistant.const import (
|
|||
ATTR_ENTITY_ID,
|
||||
ATTR_SUPPORTED_FEATURES,
|
||||
CONF_HOST,
|
||||
CONF_MODEL,
|
||||
CONF_TOKEN,
|
||||
STATE_UNAVAILABLE,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue