2020-08-26 16:03:03 +00:00
|
|
|
"""Constants for the KNX integration."""
|
2022-04-10 13:56:45 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2023-05-10 22:13:22 +00:00
|
|
|
from collections.abc import Awaitable, Callable
|
2020-08-26 16:03:03 +00:00
|
|
|
from enum import Enum
|
2022-03-30 19:10:47 +00:00
|
|
|
from typing import Final, TypedDict
|
2020-08-26 16:03:03 +00:00
|
|
|
|
2023-05-10 22:13:22 +00:00
|
|
|
from xknx.telegram import Telegram
|
|
|
|
|
2022-09-10 21:39:52 +00:00
|
|
|
from homeassistant.components.climate import (
|
2020-08-26 16:03:03 +00:00
|
|
|
PRESET_AWAY,
|
|
|
|
PRESET_COMFORT,
|
|
|
|
PRESET_ECO,
|
2020-11-13 08:37:45 +00:00
|
|
|
PRESET_NONE,
|
2020-08-26 16:03:03 +00:00
|
|
|
PRESET_SLEEP,
|
2022-04-25 12:57:31 +00:00
|
|
|
HVACAction,
|
|
|
|
HVACMode,
|
2020-08-26 16:03:03 +00:00
|
|
|
)
|
2021-12-03 17:29:38 +00:00
|
|
|
from homeassistant.const import Platform
|
2020-08-26 16:03:03 +00:00
|
|
|
|
2021-06-01 06:59:23 +00:00
|
|
|
DOMAIN: Final = "knx"
|
2020-08-26 16:03:03 +00:00
|
|
|
|
2021-03-01 20:59:36 +00:00
|
|
|
# Address is used for configuration and services by the same functions so the key has to match
|
2021-06-01 06:59:23 +00:00
|
|
|
KNX_ADDRESS: Final = "address"
|
2021-03-01 20:59:36 +00:00
|
|
|
|
2021-06-01 06:59:23 +00:00
|
|
|
CONF_INVERT: Final = "invert"
|
|
|
|
CONF_KNX_EXPOSE: Final = "expose"
|
2021-06-23 15:20:49 +00:00
|
|
|
CONF_KNX_INDIVIDUAL_ADDRESS: Final = "individual_address"
|
2022-03-29 14:46:02 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
# Connection constants
|
|
|
|
##
|
2021-11-20 10:30:41 +00:00
|
|
|
CONF_KNX_CONNECTION_TYPE: Final = "connection_type"
|
|
|
|
CONF_KNX_AUTOMATIC: Final = "automatic"
|
2021-06-23 15:20:49 +00:00
|
|
|
CONF_KNX_ROUTING: Final = "routing"
|
2022-11-27 22:33:12 +00:00
|
|
|
CONF_KNX_ROUTING_BACKBONE_KEY: Final = "backbone_key"
|
|
|
|
CONF_KNX_ROUTING_SYNC_LATENCY_TOLERANCE: Final = "sync_latency_tolerance"
|
|
|
|
CONF_KNX_ROUTING_SECURE: Final = "routing_secure"
|
2021-06-23 15:20:49 +00:00
|
|
|
CONF_KNX_TUNNELING: Final = "tunneling"
|
2022-01-26 05:36:07 +00:00
|
|
|
CONF_KNX_TUNNELING_TCP: Final = "tunneling_tcp"
|
2022-03-30 19:10:47 +00:00
|
|
|
CONF_KNX_TUNNELING_TCP_SECURE: Final = "tunneling_tcp_secure"
|
|
|
|
CONF_KNX_LOCAL_IP: Final = "local_ip"
|
|
|
|
CONF_KNX_MCAST_GRP: Final = "multicast_group"
|
|
|
|
CONF_KNX_MCAST_PORT: Final = "multicast_port"
|
2023-02-20 13:48:56 +00:00
|
|
|
CONF_KNX_TUNNEL_ENDPOINT_IA: Final = "tunnel_endpoint_ia"
|
2022-03-29 14:46:02 +00:00
|
|
|
|
2022-03-30 19:10:47 +00:00
|
|
|
CONF_KNX_RATE_LIMIT: Final = "rate_limit"
|
|
|
|
CONF_KNX_ROUTE_BACK: Final = "route_back"
|
|
|
|
CONF_KNX_STATE_UPDATER: Final = "state_updater"
|
|
|
|
CONF_KNX_DEFAULT_STATE_UPDATER: Final = True
|
2022-11-26 05:49:11 +00:00
|
|
|
CONF_KNX_DEFAULT_RATE_LIMIT: Final = 0
|
|
|
|
|
|
|
|
DEFAULT_ROUTING_IA: Final = "0.0.240"
|
2022-03-30 19:10:47 +00:00
|
|
|
|
2023-05-22 16:09:59 +00:00
|
|
|
CONF_KNX_TELEGRAM_LOG_SIZE: Final = "telegram_log_size"
|
|
|
|
TELEGRAM_LOG_DEFAULT: Final = 50
|
|
|
|
TELEGRAM_LOG_MAX: Final = 5000 # ~2 MB or ~5 hours of reasonable bus load
|
|
|
|
|
2022-03-30 19:10:47 +00:00
|
|
|
##
|
|
|
|
# Secure constants
|
|
|
|
##
|
|
|
|
CONST_KNX_STORAGE_KEY: Final = "knx/"
|
|
|
|
CONF_KNX_KNXKEY_FILENAME: Final = "knxkeys_filename"
|
|
|
|
CONF_KNX_KNXKEY_PASSWORD: Final = "knxkeys_password"
|
|
|
|
|
|
|
|
CONF_KNX_SECURE_USER_ID: Final = "user_id"
|
|
|
|
CONF_KNX_SECURE_USER_PASSWORD: Final = "user_password"
|
|
|
|
CONF_KNX_SECURE_DEVICE_AUTHENTICATION: Final = "device_authentication"
|
2022-03-29 14:46:02 +00:00
|
|
|
|
|
|
|
|
2021-11-10 19:34:35 +00:00
|
|
|
CONF_PAYLOAD: Final = "payload"
|
|
|
|
CONF_PAYLOAD_LENGTH: Final = "payload_length"
|
2021-06-23 15:20:49 +00:00
|
|
|
CONF_RESET_AFTER: Final = "reset_after"
|
2021-06-24 08:54:04 +00:00
|
|
|
CONF_RESPOND_TO_READ: Final = "respond_to_read"
|
2021-06-01 06:59:23 +00:00
|
|
|
CONF_STATE_ADDRESS: Final = "state_address"
|
|
|
|
CONF_SYNC_STATE: Final = "sync_state"
|
2021-11-20 10:30:41 +00:00
|
|
|
|
2021-12-15 18:30:38 +00:00
|
|
|
# yaml config merged with config entry data
|
2021-11-20 10:30:41 +00:00
|
|
|
DATA_KNX_CONFIG: Final = "knx_config"
|
2021-12-15 18:30:38 +00:00
|
|
|
# original hass yaml config
|
|
|
|
DATA_HASS_CONFIG: Final = "knx_hass_config"
|
2020-08-26 16:03:03 +00:00
|
|
|
|
2021-06-01 06:59:23 +00:00
|
|
|
ATTR_COUNTER: Final = "counter"
|
2021-06-26 12:30:36 +00:00
|
|
|
ATTR_SOURCE: Final = "source"
|
2021-03-01 20:59:36 +00:00
|
|
|
|
2023-05-10 22:13:22 +00:00
|
|
|
AsyncMessageCallbackType = Callable[[Telegram], Awaitable[None]]
|
|
|
|
MessageCallbackType = Callable[[Telegram], None]
|
|
|
|
|
2020-08-26 16:03:03 +00:00
|
|
|
|
2022-03-30 19:10:47 +00:00
|
|
|
class KNXConfigEntryData(TypedDict, total=False):
|
|
|
|
"""Config entry for the KNX integration."""
|
|
|
|
|
|
|
|
connection_type: str
|
|
|
|
individual_address: str
|
2023-05-22 16:09:59 +00:00
|
|
|
local_ip: str | None # not required
|
2022-03-30 19:10:47 +00:00
|
|
|
multicast_group: str
|
|
|
|
multicast_port: int
|
2023-05-22 16:09:59 +00:00
|
|
|
route_back: bool # not required
|
|
|
|
host: str # only required for tunnelling
|
|
|
|
port: int # only required for tunnelling
|
|
|
|
tunnel_endpoint_ia: str | None
|
|
|
|
# KNX secure
|
|
|
|
user_id: int | None # not required
|
|
|
|
user_password: str | None # not required
|
|
|
|
device_authentication: str | None # not required
|
|
|
|
knxkeys_filename: str # not required
|
|
|
|
knxkeys_password: str # not required
|
|
|
|
backbone_key: str | None # not required
|
|
|
|
sync_latency_tolerance: int | None # not required
|
|
|
|
# OptionsFlow only
|
2022-03-30 19:10:47 +00:00
|
|
|
state_updater: bool
|
|
|
|
rate_limit: int
|
2023-05-22 16:09:59 +00:00
|
|
|
# Integration only (not forwarded to xknx)
|
|
|
|
telegram_log_size: int # not required
|
2022-03-30 19:10:47 +00:00
|
|
|
|
|
|
|
|
2020-08-26 16:03:03 +00:00
|
|
|
class ColorTempModes(Enum):
|
|
|
|
"""Color temperature modes for config validation."""
|
|
|
|
|
2021-02-24 00:26:17 +00:00
|
|
|
ABSOLUTE = "DPT-7.600"
|
2023-06-26 01:05:35 +00:00
|
|
|
ABSOLUTE_FLOAT = "DPT-9"
|
2021-02-24 00:26:17 +00:00
|
|
|
RELATIVE = "DPT-5.001"
|
2020-08-26 16:03:03 +00:00
|
|
|
|
|
|
|
|
2021-12-03 17:29:38 +00:00
|
|
|
SUPPORTED_PLATFORMS: Final = [
|
|
|
|
Platform.BINARY_SENSOR,
|
|
|
|
Platform.BUTTON,
|
|
|
|
Platform.CLIMATE,
|
|
|
|
Platform.COVER,
|
|
|
|
Platform.FAN,
|
|
|
|
Platform.LIGHT,
|
|
|
|
Platform.NOTIFY,
|
|
|
|
Platform.NUMBER,
|
|
|
|
Platform.SCENE,
|
|
|
|
Platform.SELECT,
|
|
|
|
Platform.SENSOR,
|
|
|
|
Platform.SWITCH,
|
2022-11-29 17:05:51 +00:00
|
|
|
Platform.TEXT,
|
2021-12-03 17:29:38 +00:00
|
|
|
Platform.WEATHER,
|
|
|
|
]
|
2020-08-26 16:03:03 +00:00
|
|
|
|
2020-11-13 08:37:45 +00:00
|
|
|
# Map KNX controller modes to HA modes. This list might not be complete.
|
2021-06-01 06:59:23 +00:00
|
|
|
CONTROLLER_MODES: Final = {
|
2020-08-26 16:03:03 +00:00
|
|
|
# Map DPT 20.105 HVAC control modes
|
2022-04-25 12:57:31 +00:00
|
|
|
"Auto": HVACMode.AUTO,
|
|
|
|
"Heat": HVACMode.HEAT,
|
|
|
|
"Cool": HVACMode.COOL,
|
|
|
|
"Off": HVACMode.OFF,
|
|
|
|
"Fan only": HVACMode.FAN_ONLY,
|
|
|
|
"Dry": HVACMode.DRY,
|
2020-08-26 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
2021-06-15 15:51:16 +00:00
|
|
|
CURRENT_HVAC_ACTIONS: Final = {
|
2022-04-25 12:57:31 +00:00
|
|
|
HVACMode.HEAT: HVACAction.HEATING,
|
|
|
|
HVACMode.COOL: HVACAction.COOLING,
|
|
|
|
HVACMode.OFF: HVACAction.OFF,
|
|
|
|
HVACMode.FAN_ONLY: HVACAction.FAN,
|
|
|
|
HVACMode.DRY: HVACAction.DRYING,
|
2021-06-15 15:51:16 +00:00
|
|
|
}
|
|
|
|
|
2021-06-01 06:59:23 +00:00
|
|
|
PRESET_MODES: Final = {
|
2020-08-26 16:03:03 +00:00
|
|
|
# Map DPT 20.102 HVAC operating modes to HA presets
|
2020-11-13 08:37:45 +00:00
|
|
|
"Auto": PRESET_NONE,
|
2020-08-26 16:03:03 +00:00
|
|
|
"Frost Protection": PRESET_ECO,
|
|
|
|
"Night": PRESET_SLEEP,
|
|
|
|
"Standby": PRESET_AWAY,
|
|
|
|
"Comfort": PRESET_COMFORT,
|
|
|
|
}
|