mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Isolate consts better to where they are used (#63569)
This commit is contained in:
parent
442690b885
commit
3e2495f417
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from copy import copy
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
import logging
|
||||
from typing import Any, Final
|
||||
|
||||
@ -25,7 +25,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.event import async_call_later
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
from .const import DOMAIN, RING_INTERVAL
|
||||
from .const import DOMAIN
|
||||
from .data import ProtectData
|
||||
from .entity import ProtectDeviceEntity, ProtectNVREntity, async_all_device_entities
|
||||
from .models import ProtectRequiredKeysMixin
|
||||
@ -49,6 +49,7 @@ _KEY_BATTERY_LOW = "battery_low"
|
||||
_KEY_DISK_HEALTH = "disk_health"
|
||||
|
||||
DEVICE_CLASS_RING: Final = "unifiprotect__ring"
|
||||
RING_INTERVAL = timedelta(seconds=3)
|
||||
|
||||
|
||||
CAMERA_SENSORS: tuple[ProtectBinaryEntityDescription, ...] = (
|
||||
|
@ -1,12 +1,8 @@
|
||||
"""Constant definitions for UniFi Protect Integration."""
|
||||
|
||||
from datetime import timedelta
|
||||
|
||||
from pyunifiprotect.data.types import ModelType, Version
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import ATTR_ENTITY_ID, Platform
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.const import Platform
|
||||
|
||||
DOMAIN = "unifiprotect"
|
||||
|
||||
@ -34,9 +30,6 @@ DEFAULT_BRAND = "Ubiquiti"
|
||||
DEFAULT_SCAN_INTERVAL = 5
|
||||
DEFAULT_VERIFY_SSL = False
|
||||
|
||||
RING_INTERVAL = timedelta(seconds=3)
|
||||
|
||||
DEVICE_TYPE_CAMERA = "camera"
|
||||
DEVICES_THAT_ADOPT = {
|
||||
ModelType.CAMERA,
|
||||
ModelType.LIGHT,
|
||||
@ -49,8 +42,6 @@ DEVICES_FOR_SUBSCRIBE = DEVICES_WITH_ENTITIES | {ModelType.EVENT}
|
||||
MIN_REQUIRED_PROTECT_V = Version("1.20.0")
|
||||
OUTDATED_LOG_MESSAGE = "You are running v%s of UniFi Protect. Minimum required version is v%s. Please upgrade UniFi Protect and then retry"
|
||||
|
||||
SERVICE_SET_DOORBELL_MESSAGE = "set_doorbell_message"
|
||||
|
||||
TYPE_EMPTY_VALUE = ""
|
||||
|
||||
PLATFORMS = [
|
||||
@ -64,11 +55,3 @@ PLATFORMS = [
|
||||
Platform.SENSOR,
|
||||
Platform.SWITCH,
|
||||
]
|
||||
|
||||
SET_DOORBELL_LCD_MESSAGE_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Required(ATTR_ENTITY_ID): cv.entity_ids,
|
||||
vol.Required(ATTR_MESSAGE): cv.string,
|
||||
vol.Optional(ATTR_DURATION, default=""): cv.string,
|
||||
}
|
||||
)
|
||||
|
@ -19,21 +19,18 @@ from pyunifiprotect.data import (
|
||||
Viewer,
|
||||
)
|
||||
from pyunifiprotect.data.devices import LCDMessage
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.select import SelectEntity, SelectEntityDescription
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import entity_platform
|
||||
from homeassistant.helpers import config_validation as cv, entity_platform
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
from .const import (
|
||||
DOMAIN,
|
||||
SERVICE_SET_DOORBELL_MESSAGE,
|
||||
SET_DOORBELL_LCD_MESSAGE_SCHEMA,
|
||||
TYPE_EMPTY_VALUE,
|
||||
)
|
||||
from .const import ATTR_DURATION, ATTR_MESSAGE, DOMAIN, TYPE_EMPTY_VALUE
|
||||
from .data import ProtectData
|
||||
from .entity import ProtectDeviceEntity, async_all_device_entities
|
||||
from .models import ProtectRequiredKeysMixin
|
||||
@ -55,7 +52,6 @@ INFRARED_MODES = [
|
||||
{"id": IRLEDMode.OFF.value, "name": "Always Disable"},
|
||||
]
|
||||
|
||||
|
||||
LIGHT_MODE_MOTION = "On Motion - Always"
|
||||
LIGHT_MODE_MOTION_DARK = "On Motion - When Dark"
|
||||
LIGHT_MODE_DARK = "When Dark"
|
||||
@ -85,6 +81,16 @@ DEVICE_RECORDING_MODES = [
|
||||
|
||||
DEVICE_CLASS_LCD_MESSAGE: Final = "unifiprotect__lcd_message"
|
||||
|
||||
SERVICE_SET_DOORBELL_MESSAGE = "set_doorbell_message"
|
||||
|
||||
SET_DOORBELL_LCD_MESSAGE_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Required(ATTR_ENTITY_ID): cv.entity_ids,
|
||||
vol.Required(ATTR_MESSAGE): cv.string,
|
||||
vol.Optional(ATTR_DURATION, default=""): cv.string,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ProtectSelectEntityDescription(ProtectRequiredKeysMixin, SelectEntityDescription):
|
||||
|
@ -13,12 +13,10 @@ from pyunifiprotect.data.devices import Sensor
|
||||
from homeassistant.components.unifiprotect.binary_sensor import (
|
||||
CAMERA_SENSORS,
|
||||
LIGHT_SENSORS,
|
||||
RING_INTERVAL,
|
||||
SENSE_SENSORS,
|
||||
)
|
||||
from homeassistant.components.unifiprotect.const import (
|
||||
DEFAULT_ATTRIBUTION,
|
||||
RING_INTERVAL,
|
||||
)
|
||||
from homeassistant.components.unifiprotect.const import DEFAULT_ATTRIBUTION
|
||||
from homeassistant.const import (
|
||||
ATTR_ATTRIBUTION,
|
||||
ATTR_LAST_TRIP_TIME,
|
||||
|
@ -23,12 +23,12 @@ from homeassistant.components.unifiprotect.const import (
|
||||
ATTR_DURATION,
|
||||
ATTR_MESSAGE,
|
||||
DEFAULT_ATTRIBUTION,
|
||||
SERVICE_SET_DOORBELL_MESSAGE,
|
||||
)
|
||||
from homeassistant.components.unifiprotect.select import (
|
||||
CAMERA_SELECTS,
|
||||
LIGHT_MODE_OFF,
|
||||
LIGHT_SELECTS,
|
||||
SERVICE_SET_DOORBELL_MESSAGE,
|
||||
VIEWER_SELECTS,
|
||||
)
|
||||
from homeassistant.const import ATTR_ATTRIBUTION, ATTR_ENTITY_ID, ATTR_OPTION, Platform
|
||||
|
Loading…
x
Reference in New Issue
Block a user