KNX address constant (#47196)
parent
3c290c9a44
commit
3fda9fd0c6
|
@ -18,7 +18,6 @@ from xknx.telegram import AddressFilter, GroupAddress, Telegram
|
|||
from xknx.telegram.apci import GroupValueRead, GroupValueResponse, GroupValueWrite
|
||||
|
||||
from homeassistant.const import (
|
||||
CONF_ADDRESS,
|
||||
CONF_HOST,
|
||||
CONF_PORT,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
|
@ -32,7 +31,7 @@ from homeassistant.helpers.reload import async_integration_yaml_config
|
|||
from homeassistant.helpers.service import async_register_admin_service
|
||||
from homeassistant.helpers.typing import ServiceCallType
|
||||
|
||||
from .const import DOMAIN, SupportedPlatforms
|
||||
from .const import DOMAIN, KNX_ADDRESS, SupportedPlatforms
|
||||
from .expose import create_knx_exposure
|
||||
from .factory import create_knx_device
|
||||
from .schema import (
|
||||
|
@ -150,7 +149,7 @@ CONFIG_SCHEMA = vol.Schema(
|
|||
SERVICE_KNX_SEND_SCHEMA = vol.Any(
|
||||
vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_ADDRESS): vol.All(
|
||||
vol.Required(KNX_ADDRESS): vol.All(
|
||||
cv.ensure_list,
|
||||
[ga_validator],
|
||||
),
|
||||
|
@ -161,7 +160,7 @@ SERVICE_KNX_SEND_SCHEMA = vol.Any(
|
|||
vol.Schema(
|
||||
# without type given payload is treated as raw bytes
|
||||
{
|
||||
vol.Required(CONF_ADDRESS): vol.All(
|
||||
vol.Required(KNX_ADDRESS): vol.All(
|
||||
cv.ensure_list,
|
||||
[ga_validator],
|
||||
),
|
||||
|
@ -174,7 +173,7 @@ SERVICE_KNX_SEND_SCHEMA = vol.Any(
|
|||
|
||||
SERVICE_KNX_READ_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_ADDRESS): vol.All(
|
||||
vol.Required(KNX_ADDRESS): vol.All(
|
||||
cv.ensure_list,
|
||||
[ga_validator],
|
||||
)
|
||||
|
@ -183,7 +182,7 @@ SERVICE_KNX_READ_SCHEMA = vol.Schema(
|
|||
|
||||
SERVICE_KNX_EVENT_REGISTER_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_ADDRESS): vol.All(
|
||||
vol.Required(KNX_ADDRESS): vol.All(
|
||||
cv.ensure_list,
|
||||
[ga_validator],
|
||||
),
|
||||
|
@ -200,7 +199,7 @@ SERVICE_KNX_EXPOSURE_REGISTER_SCHEMA = vol.Any(
|
|||
vol.Schema(
|
||||
# for removing only `address` is required
|
||||
{
|
||||
vol.Required(CONF_ADDRESS): ga_validator,
|
||||
vol.Required(KNX_ADDRESS): ga_validator,
|
||||
vol.Required(SERVICE_KNX_ATTR_REMOVE): vol.All(cv.boolean, True),
|
||||
},
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
|
@ -421,7 +420,7 @@ class KNXModule:
|
|||
|
||||
async def service_event_register_modify(self, call):
|
||||
"""Service for adding or removing a GroupAddress to the knx_event filter."""
|
||||
attr_address = call.data.get(CONF_ADDRESS)
|
||||
attr_address = call.data.get(KNX_ADDRESS)
|
||||
group_addresses = map(GroupAddress, attr_address)
|
||||
|
||||
if call.data.get(SERVICE_KNX_ATTR_REMOVE):
|
||||
|
@ -444,7 +443,7 @@ class KNXModule:
|
|||
|
||||
async def service_exposure_register_modify(self, call):
|
||||
"""Service for adding or removing an exposure to KNX bus."""
|
||||
group_address = call.data.get(CONF_ADDRESS)
|
||||
group_address = call.data.get(KNX_ADDRESS)
|
||||
|
||||
if call.data.get(SERVICE_KNX_ATTR_REMOVE):
|
||||
try:
|
||||
|
@ -475,7 +474,7 @@ class KNXModule:
|
|||
|
||||
async def service_send_to_knx_bus(self, call):
|
||||
"""Service for sending an arbitrary KNX message to the KNX bus."""
|
||||
attr_address = call.data.get(CONF_ADDRESS)
|
||||
attr_address = call.data.get(KNX_ADDRESS)
|
||||
attr_payload = call.data.get(SERVICE_KNX_ATTR_PAYLOAD)
|
||||
attr_type = call.data.get(SERVICE_KNX_ATTR_TYPE)
|
||||
|
||||
|
@ -499,7 +498,7 @@ class KNXModule:
|
|||
|
||||
async def service_read_to_knx_bus(self, call):
|
||||
"""Service for sending a GroupValueRead telegram to the KNX bus."""
|
||||
for address in call.data.get(CONF_ADDRESS):
|
||||
for address in call.data.get(KNX_ADDRESS):
|
||||
telegram = Telegram(
|
||||
destination_address=GroupAddress(address),
|
||||
payload=GroupValueRead(),
|
||||
|
|
|
@ -17,11 +17,16 @@ from homeassistant.components.climate.const import (
|
|||
|
||||
DOMAIN = "knx"
|
||||
|
||||
# Address is used for configuration and services by the same functions so the key has to match
|
||||
KNX_ADDRESS = "address"
|
||||
|
||||
CONF_INVERT = "invert"
|
||||
CONF_STATE_ADDRESS = "state_address"
|
||||
CONF_SYNC_STATE = "sync_state"
|
||||
CONF_RESET_AFTER = "reset_after"
|
||||
|
||||
ATTR_COUNTER = "counter"
|
||||
|
||||
|
||||
class ColorTempModes(Enum):
|
||||
# pylint: disable=invalid-name
|
||||
|
@ -66,5 +71,3 @@ PRESET_MODES = {
|
|||
"Standby": PRESET_AWAY,
|
||||
"Comfort": PRESET_COMFORT,
|
||||
}
|
||||
|
||||
ATTR_COUNTER = "counter"
|
||||
|
|
|
@ -5,7 +5,6 @@ from xknx import XKNX
|
|||
from xknx.devices import DateTime, ExposeSensor
|
||||
|
||||
from homeassistant.const import (
|
||||
CONF_ADDRESS,
|
||||
CONF_ENTITY_ID,
|
||||
STATE_OFF,
|
||||
STATE_ON,
|
||||
|
@ -16,6 +15,7 @@ from homeassistant.core import HomeAssistant, callback
|
|||
from homeassistant.helpers.event import async_track_state_change_event
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import KNX_ADDRESS
|
||||
from .schema import ExposeSchema
|
||||
|
||||
|
||||
|
@ -24,7 +24,7 @@ def create_knx_exposure(
|
|||
hass: HomeAssistant, xknx: XKNX, config: ConfigType
|
||||
) -> Union["KNXExposeSensor", "KNXExposeTime"]:
|
||||
"""Create exposures from config."""
|
||||
address = config[CONF_ADDRESS]
|
||||
address = config[KNX_ADDRESS]
|
||||
attribute = config.get(ExposeSchema.CONF_KNX_EXPOSE_ATTRIBUTE)
|
||||
entity_id = config.get(CONF_ENTITY_ID)
|
||||
expose_type = config.get(ExposeSchema.CONF_KNX_EXPOSE_TYPE)
|
||||
|
|
|
@ -17,10 +17,10 @@ from xknx.devices import (
|
|||
Weather as XknxWeather,
|
||||
)
|
||||
|
||||
from homeassistant.const import CONF_ADDRESS, CONF_DEVICE_CLASS, CONF_NAME, CONF_TYPE
|
||||
from homeassistant.const import CONF_DEVICE_CLASS, CONF_NAME, CONF_TYPE
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import ColorTempModes, SupportedPlatforms
|
||||
from .const import KNX_ADDRESS, ColorTempModes, SupportedPlatforms
|
||||
from .schema import (
|
||||
BinarySensorSchema,
|
||||
ClimateSchema,
|
||||
|
@ -99,7 +99,7 @@ def _create_light_color(
|
|||
"""Load color configuration from configuration structure."""
|
||||
if "individual_colors" in config and color in config["individual_colors"]:
|
||||
sub_config = config["individual_colors"][color]
|
||||
group_address_switch = sub_config.get(CONF_ADDRESS)
|
||||
group_address_switch = sub_config.get(KNX_ADDRESS)
|
||||
group_address_switch_state = sub_config.get(LightSchema.CONF_STATE_ADDRESS)
|
||||
group_address_brightness = sub_config.get(LightSchema.CONF_BRIGHTNESS_ADDRESS)
|
||||
group_address_brightness_state = sub_config.get(
|
||||
|
@ -160,7 +160,7 @@ def _create_light(knx_module: XKNX, config: ConfigType) -> XknxLight:
|
|||
return XknxLight(
|
||||
knx_module,
|
||||
name=config[CONF_NAME],
|
||||
group_address_switch=config.get(CONF_ADDRESS),
|
||||
group_address_switch=config.get(KNX_ADDRESS),
|
||||
group_address_switch_state=config.get(LightSchema.CONF_STATE_ADDRESS),
|
||||
group_address_brightness=config.get(LightSchema.CONF_BRIGHTNESS_ADDRESS),
|
||||
group_address_brightness_state=config.get(
|
||||
|
@ -275,7 +275,7 @@ def _create_switch(knx_module: XKNX, config: ConfigType) -> XknxSwitch:
|
|||
return XknxSwitch(
|
||||
knx_module,
|
||||
name=config[CONF_NAME],
|
||||
group_address=config[CONF_ADDRESS],
|
||||
group_address=config[KNX_ADDRESS],
|
||||
group_address_state=config.get(SwitchSchema.CONF_STATE_ADDRESS),
|
||||
invert=config.get(SwitchSchema.CONF_INVERT),
|
||||
)
|
||||
|
@ -298,7 +298,7 @@ def _create_notify(knx_module: XKNX, config: ConfigType) -> XknxNotification:
|
|||
return XknxNotification(
|
||||
knx_module,
|
||||
name=config[CONF_NAME],
|
||||
group_address=config[CONF_ADDRESS],
|
||||
group_address=config[KNX_ADDRESS],
|
||||
)
|
||||
|
||||
|
||||
|
@ -307,7 +307,7 @@ def _create_scene(knx_module: XKNX, config: ConfigType) -> XknxScene:
|
|||
return XknxScene(
|
||||
knx_module,
|
||||
name=config[CONF_NAME],
|
||||
group_address=config[CONF_ADDRESS],
|
||||
group_address=config[KNX_ADDRESS],
|
||||
scene_number=config[SceneSchema.CONF_SCENE_NUMBER],
|
||||
)
|
||||
|
||||
|
@ -372,7 +372,7 @@ def _create_fan(knx_module: XKNX, config: ConfigType) -> XknxFan:
|
|||
fan = XknxFan(
|
||||
knx_module,
|
||||
name=config[CONF_NAME],
|
||||
group_address_speed=config.get(CONF_ADDRESS),
|
||||
group_address_speed=config.get(KNX_ADDRESS),
|
||||
group_address_speed_state=config.get(FanSchema.CONF_STATE_ADDRESS),
|
||||
group_address_oscillation=config.get(FanSchema.CONF_OSCILLATION_ADDRESS),
|
||||
group_address_oscillation_state=config.get(
|
||||
|
|
|
@ -5,7 +5,6 @@ from xknx.io import DEFAULT_MCAST_PORT
|
|||
from xknx.telegram.address import GroupAddress, IndividualAddress
|
||||
|
||||
from homeassistant.const import (
|
||||
CONF_ADDRESS,
|
||||
CONF_DEVICE_CLASS,
|
||||
CONF_ENTITY_ID,
|
||||
CONF_HOST,
|
||||
|
@ -21,6 +20,7 @@ from .const import (
|
|||
CONF_STATE_ADDRESS,
|
||||
CONF_SYNC_STATE,
|
||||
CONTROLLER_MODES,
|
||||
KNX_ADDRESS,
|
||||
PRESET_MODES,
|
||||
ColorTempModes,
|
||||
)
|
||||
|
@ -256,7 +256,7 @@ class ExposeSchema:
|
|||
SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_KNX_EXPOSE_TYPE): vol.Any(int, float, str),
|
||||
vol.Required(CONF_ADDRESS): ga_validator,
|
||||
vol.Required(KNX_ADDRESS): ga_validator,
|
||||
vol.Optional(CONF_ENTITY_ID): cv.entity_id,
|
||||
vol.Optional(CONF_KNX_EXPOSE_ATTRIBUTE): cv.string,
|
||||
vol.Optional(CONF_KNX_EXPOSE_DEFAULT): cv.match_all,
|
||||
|
@ -277,7 +277,7 @@ class FanSchema:
|
|||
SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
vol.Required(CONF_ADDRESS): ga_validator,
|
||||
vol.Required(KNX_ADDRESS): ga_validator,
|
||||
vol.Optional(CONF_STATE_ADDRESS): ga_validator,
|
||||
vol.Optional(CONF_OSCILLATION_ADDRESS): ga_validator,
|
||||
vol.Optional(CONF_OSCILLATION_STATE_ADDRESS): ga_validator,
|
||||
|
@ -315,7 +315,7 @@ class LightSchema:
|
|||
|
||||
COLOR_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_ADDRESS): ga_validator,
|
||||
vol.Optional(KNX_ADDRESS): ga_validator,
|
||||
vol.Optional(CONF_STATE_ADDRESS): ga_validator,
|
||||
vol.Required(CONF_BRIGHTNESS_ADDRESS): ga_validator,
|
||||
vol.Optional(CONF_BRIGHTNESS_STATE_ADDRESS): ga_validator,
|
||||
|
@ -326,7 +326,7 @@ class LightSchema:
|
|||
vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
vol.Optional(CONF_ADDRESS): ga_validator,
|
||||
vol.Optional(KNX_ADDRESS): ga_validator,
|
||||
vol.Optional(CONF_STATE_ADDRESS): ga_validator,
|
||||
vol.Optional(CONF_BRIGHTNESS_ADDRESS): ga_validator,
|
||||
vol.Optional(CONF_BRIGHTNESS_STATE_ADDRESS): ga_validator,
|
||||
|
@ -358,16 +358,16 @@ class LightSchema:
|
|||
vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_INDIVIDUAL_COLORS): {
|
||||
vol.Required(CONF_RED): {vol.Required(CONF_ADDRESS): object},
|
||||
vol.Required(CONF_GREEN): {vol.Required(CONF_ADDRESS): object},
|
||||
vol.Required(CONF_BLUE): {vol.Required(CONF_ADDRESS): object},
|
||||
vol.Required(CONF_RED): {vol.Required(KNX_ADDRESS): object},
|
||||
vol.Required(CONF_GREEN): {vol.Required(KNX_ADDRESS): object},
|
||||
vol.Required(CONF_BLUE): {vol.Required(KNX_ADDRESS): object},
|
||||
},
|
||||
},
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
),
|
||||
vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_ADDRESS): object,
|
||||
vol.Required(KNX_ADDRESS): object,
|
||||
},
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
),
|
||||
|
@ -383,7 +383,7 @@ class NotifySchema:
|
|||
SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
vol.Required(CONF_ADDRESS): ga_validator,
|
||||
vol.Required(KNX_ADDRESS): ga_validator,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -397,7 +397,7 @@ class SceneSchema:
|
|||
SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
vol.Required(CONF_ADDRESS): ga_validator,
|
||||
vol.Required(KNX_ADDRESS): ga_validator,
|
||||
vol.Required(CONF_SCENE_NUMBER): cv.positive_int,
|
||||
}
|
||||
)
|
||||
|
@ -432,7 +432,7 @@ class SwitchSchema:
|
|||
SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
vol.Required(CONF_ADDRESS): ga_validator,
|
||||
vol.Required(KNX_ADDRESS): ga_validator,
|
||||
vol.Optional(CONF_STATE_ADDRESS): ga_validator,
|
||||
vol.Optional(CONF_INVERT): cv.boolean,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue