Use new Platform enum in KNX (#60902)

This commit is contained in:
Marvin Wichmann 2021-12-03 18:29:38 +01:00 committed by GitHub
parent 77cd751543
commit 3baa7b679d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 118 additions and 147 deletions

View File

@ -47,7 +47,7 @@ from .const import (
DATA_KNX_CONFIG, DATA_KNX_CONFIG,
DOMAIN, DOMAIN,
KNX_ADDRESS, KNX_ADDRESS,
SupportedPlatforms, SUPPORTED_PLATFORMS,
) )
from .expose import KNXExposeSensor, KNXExposeTime, create_knx_exposure from .expose import KNXExposeSensor, KNXExposeTime, create_knx_exposure
from .schema import ( from .schema import (
@ -251,16 +251,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
) )
hass.config_entries.async_setup_platforms( hass.config_entries.async_setup_platforms(
entry, entry, [platform for platform in SUPPORTED_PLATFORMS if platform in config]
[platform.value for platform in SupportedPlatforms if platform.value in config],
) )
# set up notify platform, no entry support for notify component yet, # set up notify platform, no entry support for notify component yet,
# have to use discovery to load platform. # have to use discovery to load platform.
if NotifySchema.PLATFORM_NAME in conf: if NotifySchema.PLATFORM in conf:
hass.async_create_task( hass.async_create_task(
discovery.async_load_platform( discovery.async_load_platform(
hass, "notify", DOMAIN, conf[NotifySchema.PLATFORM_NAME], config hass, "notify", DOMAIN, conf[NotifySchema.PLATFORM], config
) )
) )
@ -310,9 +309,9 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
unload_ok = await hass.config_entries.async_unload_platforms( unload_ok = await hass.config_entries.async_unload_platforms(
entry, entry,
[ [
platform.value platform
for platform in SupportedPlatforms for platform in SUPPORTED_PLATFORMS
if platform.value in hass.data[DATA_KNX_CONFIG] if platform in hass.data[DATA_KNX_CONFIG]
], ],
) )
if unload_ok: if unload_ok:

View File

@ -15,19 +15,14 @@ from homeassistant.const import (
STATE_ON, STATE_ON,
STATE_UNAVAILABLE, STATE_UNAVAILABLE,
STATE_UNKNOWN, STATE_UNKNOWN,
Platform,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from .const import ( from .const import ATTR_COUNTER, ATTR_SOURCE, DATA_KNX_CONFIG, DOMAIN
ATTR_COUNTER,
ATTR_SOURCE,
DATA_KNX_CONFIG,
DOMAIN,
SupportedPlatforms,
)
from .knx_entity import KnxEntity from .knx_entity import KnxEntity
from .schema import BinarySensorSchema from .schema import BinarySensorSchema
@ -43,7 +38,7 @@ async def async_setup_entry(
async_add_entities( async_add_entities(
KNXBinarySensor(xknx, entity_config) KNXBinarySensor(xknx, entity_config)
for entity_config in config[SupportedPlatforms.BINARY_SENSOR.value] for entity_config in config[Platform.BINARY_SENSOR]
) )

View File

@ -6,7 +6,7 @@ from xknx.devices import RawValue as XknxRawValue
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.button import ButtonEntity from homeassistant.components.button import ButtonEntity
from homeassistant.const import CONF_ENTITY_CATEGORY, CONF_NAME from homeassistant.const import CONF_ENTITY_CATEGORY, CONF_NAME, Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -17,7 +17,6 @@ from .const import (
DATA_KNX_CONFIG, DATA_KNX_CONFIG,
DOMAIN, DOMAIN,
KNX_ADDRESS, KNX_ADDRESS,
SupportedPlatforms,
) )
from .knx_entity import KnxEntity from .knx_entity import KnxEntity
@ -32,8 +31,7 @@ async def async_setup_entry(
config: ConfigType = hass.data[DATA_KNX_CONFIG] config: ConfigType = hass.data[DATA_KNX_CONFIG]
async_add_entities( async_add_entities(
KNXButton(xknx, entity_config) KNXButton(xknx, entity_config) for entity_config in config[Platform.BUTTON]
for entity_config in config[SupportedPlatforms.BUTTON.value]
) )

View File

@ -22,6 +22,7 @@ from homeassistant.const import (
CONF_ENTITY_CATEGORY, CONF_ENTITY_CATEGORY,
CONF_NAME, CONF_NAME,
TEMP_CELSIUS, TEMP_CELSIUS,
Platform,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -33,7 +34,6 @@ from .const import (
DATA_KNX_CONFIG, DATA_KNX_CONFIG,
DOMAIN, DOMAIN,
PRESET_MODES, PRESET_MODES,
SupportedPlatforms,
) )
from .knx_entity import KnxEntity from .knx_entity import KnxEntity
from .schema import ClimateSchema from .schema import ClimateSchema
@ -50,9 +50,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up climate(s) for KNX platform.""" """Set up climate(s) for KNX platform."""
xknx: XKNX = hass.data[DOMAIN].xknx xknx: XKNX = hass.data[DOMAIN].xknx
config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][ config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][Platform.CLIMATE]
SupportedPlatforms.CLIMATE.value
]
async_add_entities(KNXClimate(xknx, entity_config) for entity_config in config) async_add_entities(KNXClimate(xknx, entity_config) for entity_config in config)

View File

@ -20,6 +20,7 @@ from homeassistant.components.climate.const import (
PRESET_NONE, PRESET_NONE,
PRESET_SLEEP, PRESET_SLEEP,
) )
from homeassistant.const import Platform
DOMAIN: Final = "knx" DOMAIN: Final = "knx"
@ -54,23 +55,21 @@ class ColorTempModes(Enum):
RELATIVE = "DPT-5.001" RELATIVE = "DPT-5.001"
class SupportedPlatforms(Enum): SUPPORTED_PLATFORMS: Final = [
"""Supported platforms.""" Platform.BINARY_SENSOR,
Platform.BUTTON,
BINARY_SENSOR = "binary_sensor" Platform.CLIMATE,
BUTTON = "button" Platform.COVER,
CLIMATE = "climate" Platform.FAN,
COVER = "cover" Platform.LIGHT,
FAN = "fan" Platform.NOTIFY,
LIGHT = "light" Platform.NUMBER,
NOTIFY = "notify" Platform.SCENE,
NUMBER = "number" Platform.SELECT,
SCENE = "scene" Platform.SENSOR,
SELECT = "select" Platform.SWITCH,
SENSOR = "sensor" Platform.WEATHER,
SWITCH = "switch" ]
WEATHER = "weather"
# Map KNX controller modes to HA modes. This list might not be complete. # Map KNX controller modes to HA modes. This list might not be complete.
CONTROLLER_MODES: Final = { CONTROLLER_MODES: Final = {

View File

@ -23,13 +23,18 @@ from homeassistant.components.cover import (
SUPPORT_STOP_TILT, SUPPORT_STOP_TILT,
CoverEntity, CoverEntity,
) )
from homeassistant.const import CONF_DEVICE_CLASS, CONF_ENTITY_CATEGORY, CONF_NAME from homeassistant.const import (
CONF_DEVICE_CLASS,
CONF_ENTITY_CATEGORY,
CONF_NAME,
Platform,
)
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.event import async_track_utc_time_change from homeassistant.helpers.event import async_track_utc_time_change
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from .const import DATA_KNX_CONFIG, DOMAIN, SupportedPlatforms from .const import DATA_KNX_CONFIG, DOMAIN
from .knx_entity import KnxEntity from .knx_entity import KnxEntity
from .schema import CoverSchema from .schema import CoverSchema
@ -41,9 +46,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up cover(s) for KNX platform.""" """Set up cover(s) for KNX platform."""
xknx: XKNX = hass.data[DOMAIN].xknx xknx: XKNX = hass.data[DOMAIN].xknx
config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][ config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][Platform.COVER]
SupportedPlatforms.COVER.value
]
async_add_entities(KNXCover(xknx, entity_config) for entity_config in config) async_add_entities(KNXCover(xknx, entity_config) for entity_config in config)

View File

@ -9,7 +9,7 @@ from xknx.devices import Fan as XknxFan
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.fan import SUPPORT_OSCILLATE, SUPPORT_SET_SPEED, FanEntity from homeassistant.components.fan import SUPPORT_OSCILLATE, SUPPORT_SET_SPEED, FanEntity
from homeassistant.const import CONF_ENTITY_CATEGORY, CONF_NAME from homeassistant.const import CONF_ENTITY_CATEGORY, CONF_NAME, Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -19,7 +19,7 @@ from homeassistant.util.percentage import (
ranged_value_to_percentage, ranged_value_to_percentage,
) )
from .const import DATA_KNX_CONFIG, DOMAIN, KNX_ADDRESS, SupportedPlatforms from .const import DATA_KNX_CONFIG, DOMAIN, KNX_ADDRESS
from .knx_entity import KnxEntity from .knx_entity import KnxEntity
from .schema import FanSchema from .schema import FanSchema
@ -33,7 +33,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up fan(s) for KNX platform.""" """Set up fan(s) for KNX platform."""
xknx: XKNX = hass.data[DOMAIN].xknx xknx: XKNX = hass.data[DOMAIN].xknx
config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][SupportedPlatforms.FAN.value] config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][Platform.FAN]
async_add_entities(KNXFan(xknx, entity_config) for entity_config in config) async_add_entities(KNXFan(xknx, entity_config) for entity_config in config)

View File

@ -23,19 +23,13 @@ from homeassistant.components.light import (
COLOR_MODE_XY, COLOR_MODE_XY,
LightEntity, LightEntity,
) )
from homeassistant.const import CONF_ENTITY_CATEGORY, CONF_NAME from homeassistant.const import CONF_ENTITY_CATEGORY, CONF_NAME, Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
from .const import ( from .const import DATA_KNX_CONFIG, DOMAIN, KNX_ADDRESS, ColorTempModes
DATA_KNX_CONFIG,
DOMAIN,
KNX_ADDRESS,
ColorTempModes,
SupportedPlatforms,
)
from .knx_entity import KnxEntity from .knx_entity import KnxEntity
from .schema import LightSchema from .schema import LightSchema
@ -47,9 +41,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up light(s) for KNX platform.""" """Set up light(s) for KNX platform."""
xknx: XKNX = hass.data[DOMAIN].xknx xknx: XKNX = hass.data[DOMAIN].xknx
config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][ config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][Platform.LIGHT]
SupportedPlatforms.LIGHT.value
]
async_add_entities(KNXLight(xknx, entity_config) for entity_config in config) async_add_entities(KNXLight(xknx, entity_config) for entity_config in config)

View File

@ -15,6 +15,7 @@ from homeassistant.const import (
CONF_TYPE, CONF_TYPE,
STATE_UNAVAILABLE, STATE_UNAVAILABLE,
STATE_UNKNOWN, STATE_UNKNOWN,
Platform,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -27,7 +28,6 @@ from .const import (
DATA_KNX_CONFIG, DATA_KNX_CONFIG,
DOMAIN, DOMAIN,
KNX_ADDRESS, KNX_ADDRESS,
SupportedPlatforms,
) )
from .knx_entity import KnxEntity from .knx_entity import KnxEntity
from .schema import NumberSchema from .schema import NumberSchema
@ -40,9 +40,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up number(s) for KNX platform.""" """Set up number(s) for KNX platform."""
xknx: XKNX = hass.data[DOMAIN].xknx xknx: XKNX = hass.data[DOMAIN].xknx
config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][ config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][Platform.NUMBER]
SupportedPlatforms.NUMBER.value
]
async_add_entities(KNXNumber(xknx, entity_config) for entity_config in config) async_add_entities(KNXNumber(xknx, entity_config) for entity_config in config)

View File

@ -8,12 +8,12 @@ from xknx.devices import Scene as XknxScene
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.scene import Scene from homeassistant.components.scene import Scene
from homeassistant.const import CONF_ENTITY_CATEGORY, CONF_NAME from homeassistant.const import CONF_ENTITY_CATEGORY, CONF_NAME, Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from .const import DATA_KNX_CONFIG, DOMAIN, KNX_ADDRESS, SupportedPlatforms from .const import DATA_KNX_CONFIG, DOMAIN, KNX_ADDRESS
from .knx_entity import KnxEntity from .knx_entity import KnxEntity
from .schema import SceneSchema from .schema import SceneSchema
@ -25,9 +25,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up scene(s) for KNX platform.""" """Set up scene(s) for KNX platform."""
xknx: XKNX = hass.data[DOMAIN].xknx xknx: XKNX = hass.data[DOMAIN].xknx
config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][ config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][Platform.SCENE]
SupportedPlatforms.SCENE.value
]
async_add_entities(KNXScene(xknx, entity_config) for entity_config in config) async_add_entities(KNXScene(xknx, entity_config) for entity_config in config)

View File

@ -30,6 +30,7 @@ from homeassistant.const import (
CONF_NAME, CONF_NAME,
CONF_PORT, CONF_PORT,
CONF_TYPE, CONF_TYPE,
Platform,
) )
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import ENTITY_CATEGORIES_SCHEMA from homeassistant.helpers.entity import ENTITY_CATEGORIES_SCHEMA
@ -50,7 +51,6 @@ from .const import (
KNX_ADDRESS, KNX_ADDRESS,
PRESET_MODES, PRESET_MODES,
ColorTempModes, ColorTempModes,
SupportedPlatforms,
) )
################## ##################
@ -275,14 +275,14 @@ class EventSchema:
class KNXPlatformSchema(ABC): class KNXPlatformSchema(ABC):
"""Voluptuous schema for KNX platform entity configuration.""" """Voluptuous schema for KNX platform entity configuration."""
PLATFORM_NAME: ClassVar[str] PLATFORM: ClassVar[Platform | str]
ENTITY_SCHEMA: ClassVar[vol.Schema] ENTITY_SCHEMA: ClassVar[vol.Schema]
@classmethod @classmethod
def platform_node(cls) -> dict[vol.Optional, vol.All]: def platform_node(cls) -> dict[vol.Optional, vol.All]:
"""Return a schema node for the platform.""" """Return a schema node for the platform."""
return { return {
vol.Optional(cls.PLATFORM_NAME): vol.All( vol.Optional(str(cls.PLATFORM)): vol.All(
cv.ensure_list, [cls.ENTITY_SCHEMA] cv.ensure_list, [cls.ENTITY_SCHEMA]
) )
} }
@ -291,7 +291,7 @@ class KNXPlatformSchema(ABC):
class BinarySensorSchema(KNXPlatformSchema): class BinarySensorSchema(KNXPlatformSchema):
"""Voluptuous schema for KNX binary sensors.""" """Voluptuous schema for KNX binary sensors."""
PLATFORM_NAME = SupportedPlatforms.BINARY_SENSOR.value PLATFORM = Platform.BINARY_SENSOR
CONF_STATE_ADDRESS = CONF_STATE_ADDRESS CONF_STATE_ADDRESS = CONF_STATE_ADDRESS
CONF_SYNC_STATE = CONF_SYNC_STATE CONF_SYNC_STATE = CONF_SYNC_STATE
@ -327,7 +327,7 @@ class BinarySensorSchema(KNXPlatformSchema):
class ButtonSchema(KNXPlatformSchema): class ButtonSchema(KNXPlatformSchema):
"""Voluptuous schema for KNX buttons.""" """Voluptuous schema for KNX buttons."""
PLATFORM_NAME = SupportedPlatforms.BUTTON.value PLATFORM = Platform.BUTTON
CONF_VALUE = "value" CONF_VALUE = "value"
DEFAULT_NAME = "KNX Button" DEFAULT_NAME = "KNX Button"
@ -388,7 +388,7 @@ class ButtonSchema(KNXPlatformSchema):
class ClimateSchema(KNXPlatformSchema): class ClimateSchema(KNXPlatformSchema):
"""Voluptuous schema for KNX climate devices.""" """Voluptuous schema for KNX climate devices."""
PLATFORM_NAME = SupportedPlatforms.CLIMATE.value PLATFORM = Platform.CLIMATE
CONF_ACTIVE_STATE_ADDRESS = "active_state_address" CONF_ACTIVE_STATE_ADDRESS = "active_state_address"
CONF_SETPOINT_SHIFT_ADDRESS = "setpoint_shift_address" CONF_SETPOINT_SHIFT_ADDRESS = "setpoint_shift_address"
@ -507,7 +507,7 @@ class ClimateSchema(KNXPlatformSchema):
class CoverSchema(KNXPlatformSchema): class CoverSchema(KNXPlatformSchema):
"""Voluptuous schema for KNX covers.""" """Voluptuous schema for KNX covers."""
PLATFORM_NAME = SupportedPlatforms.COVER.value PLATFORM = Platform.COVER
CONF_MOVE_LONG_ADDRESS = "move_long_address" CONF_MOVE_LONG_ADDRESS = "move_long_address"
CONF_MOVE_SHORT_ADDRESS = "move_short_address" CONF_MOVE_SHORT_ADDRESS = "move_short_address"
@ -562,7 +562,7 @@ class CoverSchema(KNXPlatformSchema):
class ExposeSchema(KNXPlatformSchema): class ExposeSchema(KNXPlatformSchema):
"""Voluptuous schema for KNX exposures.""" """Voluptuous schema for KNX exposures."""
PLATFORM_NAME = CONF_KNX_EXPOSE PLATFORM = CONF_KNX_EXPOSE
CONF_KNX_EXPOSE_TYPE = CONF_TYPE CONF_KNX_EXPOSE_TYPE = CONF_TYPE
CONF_KNX_EXPOSE_ATTRIBUTE = "attribute" CONF_KNX_EXPOSE_ATTRIBUTE = "attribute"
@ -599,7 +599,7 @@ class ExposeSchema(KNXPlatformSchema):
class FanSchema(KNXPlatformSchema): class FanSchema(KNXPlatformSchema):
"""Voluptuous schema for KNX fans.""" """Voluptuous schema for KNX fans."""
PLATFORM_NAME = SupportedPlatforms.FAN.value PLATFORM = Platform.FAN
CONF_STATE_ADDRESS = CONF_STATE_ADDRESS CONF_STATE_ADDRESS = CONF_STATE_ADDRESS
CONF_OSCILLATION_ADDRESS = "oscillation_address" CONF_OSCILLATION_ADDRESS = "oscillation_address"
@ -624,7 +624,7 @@ class FanSchema(KNXPlatformSchema):
class LightSchema(KNXPlatformSchema): class LightSchema(KNXPlatformSchema):
"""Voluptuous schema for KNX lights.""" """Voluptuous schema for KNX lights."""
PLATFORM_NAME = SupportedPlatforms.LIGHT.value PLATFORM = Platform.LIGHT
CONF_STATE_ADDRESS = CONF_STATE_ADDRESS CONF_STATE_ADDRESS = CONF_STATE_ADDRESS
CONF_BRIGHTNESS_ADDRESS = "brightness_address" CONF_BRIGHTNESS_ADDRESS = "brightness_address"
@ -764,7 +764,7 @@ class LightSchema(KNXPlatformSchema):
class NotifySchema(KNXPlatformSchema): class NotifySchema(KNXPlatformSchema):
"""Voluptuous schema for KNX notifications.""" """Voluptuous schema for KNX notifications."""
PLATFORM_NAME = SupportedPlatforms.NOTIFY.value PLATFORM = Platform.NOTIFY
DEFAULT_NAME = "KNX Notify" DEFAULT_NAME = "KNX Notify"
@ -779,7 +779,7 @@ class NotifySchema(KNXPlatformSchema):
class NumberSchema(KNXPlatformSchema): class NumberSchema(KNXPlatformSchema):
"""Voluptuous schema for KNX numbers.""" """Voluptuous schema for KNX numbers."""
PLATFORM_NAME = SupportedPlatforms.NUMBER.value PLATFORM = Platform.NUMBER
CONF_MAX = "max" CONF_MAX = "max"
CONF_MIN = "min" CONF_MIN = "min"
@ -810,7 +810,7 @@ class NumberSchema(KNXPlatformSchema):
class SceneSchema(KNXPlatformSchema): class SceneSchema(KNXPlatformSchema):
"""Voluptuous schema for KNX scenes.""" """Voluptuous schema for KNX scenes."""
PLATFORM_NAME = SupportedPlatforms.SCENE.value PLATFORM = Platform.SCENE
CONF_SCENE_NUMBER = "scene_number" CONF_SCENE_NUMBER = "scene_number"
@ -830,7 +830,7 @@ class SceneSchema(KNXPlatformSchema):
class SelectSchema(KNXPlatformSchema): class SelectSchema(KNXPlatformSchema):
"""Voluptuous schema for KNX selects.""" """Voluptuous schema for KNX selects."""
PLATFORM_NAME = SupportedPlatforms.SELECT.value PLATFORM = Platform.SELECT
CONF_OPTION = "option" CONF_OPTION = "option"
CONF_OPTIONS = "options" CONF_OPTIONS = "options"
@ -863,7 +863,7 @@ class SelectSchema(KNXPlatformSchema):
class SensorSchema(KNXPlatformSchema): class SensorSchema(KNXPlatformSchema):
"""Voluptuous schema for KNX sensors.""" """Voluptuous schema for KNX sensors."""
PLATFORM_NAME = SupportedPlatforms.SENSOR.value PLATFORM = Platform.SENSOR
CONF_ALWAYS_CALLBACK = "always_callback" CONF_ALWAYS_CALLBACK = "always_callback"
CONF_STATE_ADDRESS = CONF_STATE_ADDRESS CONF_STATE_ADDRESS = CONF_STATE_ADDRESS
@ -886,7 +886,7 @@ class SensorSchema(KNXPlatformSchema):
class SwitchSchema(KNXPlatformSchema): class SwitchSchema(KNXPlatformSchema):
"""Voluptuous schema for KNX switches.""" """Voluptuous schema for KNX switches."""
PLATFORM_NAME = SupportedPlatforms.SWITCH.value PLATFORM = Platform.SWITCH
CONF_INVERT = CONF_INVERT CONF_INVERT = CONF_INVERT
CONF_STATE_ADDRESS = CONF_STATE_ADDRESS CONF_STATE_ADDRESS = CONF_STATE_ADDRESS
@ -907,7 +907,7 @@ class SwitchSchema(KNXPlatformSchema):
class WeatherSchema(KNXPlatformSchema): class WeatherSchema(KNXPlatformSchema):
"""Voluptuous schema for KNX weather station.""" """Voluptuous schema for KNX weather station."""
PLATFORM_NAME = SupportedPlatforms.WEATHER.value PLATFORM = Platform.WEATHER
CONF_SYNC_STATE = CONF_SYNC_STATE CONF_SYNC_STATE = CONF_SYNC_STATE
CONF_KNX_TEMPERATURE_ADDRESS = "address_temperature" CONF_KNX_TEMPERATURE_ADDRESS = "address_temperature"

View File

@ -11,6 +11,7 @@ from homeassistant.const import (
CONF_NAME, CONF_NAME,
STATE_UNAVAILABLE, STATE_UNAVAILABLE,
STATE_UNKNOWN, STATE_UNKNOWN,
Platform,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -26,7 +27,6 @@ from .const import (
DATA_KNX_CONFIG, DATA_KNX_CONFIG,
DOMAIN, DOMAIN,
KNX_ADDRESS, KNX_ADDRESS,
SupportedPlatforms,
) )
from .knx_entity import KnxEntity from .knx_entity import KnxEntity
from .schema import SelectSchema from .schema import SelectSchema
@ -39,9 +39,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up select(s) for KNX platform.""" """Set up select(s) for KNX platform."""
xknx: XKNX = hass.data[DOMAIN].xknx xknx: XKNX = hass.data[DOMAIN].xknx
config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][ config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][Platform.SELECT]
SupportedPlatforms.SELECT.value
]
async_add_entities(KNXSelect(xknx, entity_config) for entity_config in config) async_add_entities(KNXSelect(xknx, entity_config) for entity_config in config)

View File

@ -12,12 +12,12 @@ from homeassistant.components.sensor import (
DEVICE_CLASSES, DEVICE_CLASSES,
SensorEntity, SensorEntity,
) )
from homeassistant.const import CONF_ENTITY_CATEGORY, CONF_NAME, CONF_TYPE from homeassistant.const import CONF_ENTITY_CATEGORY, CONF_NAME, CONF_TYPE, Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, StateType from homeassistant.helpers.typing import ConfigType, StateType
from .const import ATTR_SOURCE, DATA_KNX_CONFIG, DOMAIN, SupportedPlatforms from .const import ATTR_SOURCE, DATA_KNX_CONFIG, DOMAIN
from .knx_entity import KnxEntity from .knx_entity import KnxEntity
from .schema import SensorSchema from .schema import SensorSchema
@ -29,9 +29,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up sensor(s) for KNX platform.""" """Set up sensor(s) for KNX platform."""
xknx: XKNX = hass.data[DOMAIN].xknx xknx: XKNX = hass.data[DOMAIN].xknx
config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][ config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][Platform.SENSOR]
SupportedPlatforms.SENSOR.value
]
async_add_entities(KNXSensor(xknx, entity_config) for entity_config in config) async_add_entities(KNXSensor(xknx, entity_config) for entity_config in config)

View File

@ -14,19 +14,14 @@ from homeassistant.const import (
STATE_ON, STATE_ON,
STATE_UNAVAILABLE, STATE_UNAVAILABLE,
STATE_UNKNOWN, STATE_UNKNOWN,
Platform,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from .const import ( from .const import CONF_RESPOND_TO_READ, DATA_KNX_CONFIG, DOMAIN, KNX_ADDRESS
CONF_RESPOND_TO_READ,
DATA_KNX_CONFIG,
DOMAIN,
KNX_ADDRESS,
SupportedPlatforms,
)
from .knx_entity import KnxEntity from .knx_entity import KnxEntity
from .schema import SwitchSchema from .schema import SwitchSchema
@ -38,9 +33,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up switch(es) for KNX platform.""" """Set up switch(es) for KNX platform."""
xknx: XKNX = hass.data[DOMAIN].xknx xknx: XKNX = hass.data[DOMAIN].xknx
config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][ config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][Platform.SWITCH]
SupportedPlatforms.SWITCH.value
]
async_add_entities(KNXSwitch(xknx, entity_config) for entity_config in config) async_add_entities(KNXSwitch(xknx, entity_config) for entity_config in config)

View File

@ -6,12 +6,12 @@ from xknx.devices import Weather as XknxWeather
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.weather import WeatherEntity from homeassistant.components.weather import WeatherEntity
from homeassistant.const import CONF_ENTITY_CATEGORY, CONF_NAME, TEMP_CELSIUS from homeassistant.const import CONF_ENTITY_CATEGORY, CONF_NAME, TEMP_CELSIUS, Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from .const import DATA_KNX_CONFIG, DOMAIN, SupportedPlatforms from .const import DATA_KNX_CONFIG, DOMAIN
from .knx_entity import KnxEntity from .knx_entity import KnxEntity
from .schema import WeatherSchema from .schema import WeatherSchema
@ -23,9 +23,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up switch(es) for KNX platform.""" """Set up switch(es) for KNX platform."""
xknx: XKNX = hass.data[DOMAIN].xknx xknx: XKNX = hass.data[DOMAIN].xknx
config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][ config: list[ConfigType] = hass.data[DATA_KNX_CONFIG][Platform.WEATHER]
SupportedPlatforms.WEATHER.value
]
async_add_entities(KNXWeather(xknx, entity_config) for entity_config in config) async_add_entities(KNXWeather(xknx, entity_config) for entity_config in config)

View File

@ -26,7 +26,7 @@ async def test_binary_sensor_entity_category(hass: HomeAssistant, knx: KNXTestKi
"""Test KNX binary sensor entity category.""" """Test KNX binary sensor entity category."""
await knx.setup_integration( await knx.setup_integration(
{ {
BinarySensorSchema.PLATFORM_NAME: [ BinarySensorSchema.PLATFORM: [
{ {
CONF_NAME: "test_normal", CONF_NAME: "test_normal",
CONF_STATE_ADDRESS: "1/1/1", CONF_STATE_ADDRESS: "1/1/1",
@ -49,7 +49,7 @@ async def test_binary_sensor(hass: HomeAssistant, knx: KNXTestKit):
"""Test KNX binary sensor and inverted binary_sensor.""" """Test KNX binary sensor and inverted binary_sensor."""
await knx.setup_integration( await knx.setup_integration(
{ {
BinarySensorSchema.PLATFORM_NAME: [ BinarySensorSchema.PLATFORM: [
{ {
CONF_NAME: "test_normal", CONF_NAME: "test_normal",
CONF_STATE_ADDRESS: "1/1/1", CONF_STATE_ADDRESS: "1/1/1",
@ -104,7 +104,7 @@ async def test_binary_sensor_ignore_internal_state(
await knx.setup_integration( await knx.setup_integration(
{ {
BinarySensorSchema.PLATFORM_NAME: [ BinarySensorSchema.PLATFORM: [
{ {
CONF_NAME: "test_normal", CONF_NAME: "test_normal",
CONF_STATE_ADDRESS: "1/1/1", CONF_STATE_ADDRESS: "1/1/1",
@ -156,7 +156,7 @@ async def test_binary_sensor_counter(hass: HomeAssistant, knx: KNXTestKit):
await knx.setup_integration( await knx.setup_integration(
{ {
BinarySensorSchema.PLATFORM_NAME: [ BinarySensorSchema.PLATFORM: [
{ {
CONF_NAME: "test", CONF_NAME: "test",
CONF_STATE_ADDRESS: "2/2/2", CONF_STATE_ADDRESS: "2/2/2",
@ -223,7 +223,7 @@ async def test_binary_sensor_reset(hass: HomeAssistant, knx: KNXTestKit):
await knx.setup_integration( await knx.setup_integration(
{ {
BinarySensorSchema.PLATFORM_NAME: [ BinarySensorSchema.PLATFORM: [
{ {
CONF_NAME: "test", CONF_NAME: "test",
CONF_STATE_ADDRESS: "2/2/2", CONF_STATE_ADDRESS: "2/2/2",
@ -259,7 +259,7 @@ async def test_binary_sensor_restore_and_respond(hass, knx):
): ):
await knx.setup_integration( await knx.setup_integration(
{ {
BinarySensorSchema.PLATFORM_NAME: [ BinarySensorSchema.PLATFORM: [
{ {
CONF_NAME: "test", CONF_NAME: "test",
CONF_STATE_ADDRESS: _ADDRESS, CONF_STATE_ADDRESS: _ADDRESS,
@ -291,7 +291,7 @@ async def test_binary_sensor_restore_invert(hass, knx):
): ):
await knx.setup_integration( await knx.setup_integration(
{ {
BinarySensorSchema.PLATFORM_NAME: [ BinarySensorSchema.PLATFORM: [
{ {
CONF_NAME: "test", CONF_NAME: "test",
CONF_STATE_ADDRESS: _ADDRESS, CONF_STATE_ADDRESS: _ADDRESS,

View File

@ -21,7 +21,7 @@ async def test_button_simple(hass: HomeAssistant, knx: KNXTestKit):
events = async_capture_events(hass, "state_changed") events = async_capture_events(hass, "state_changed")
await knx.setup_integration( await knx.setup_integration(
{ {
ButtonSchema.PLATFORM_NAME: { ButtonSchema.PLATFORM: {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: "1/2/3", KNX_ADDRESS: "1/2/3",
} }
@ -57,7 +57,7 @@ async def test_button_raw(hass: HomeAssistant, knx: KNXTestKit):
"""Test KNX button with raw payload.""" """Test KNX button with raw payload."""
await knx.setup_integration( await knx.setup_integration(
{ {
ButtonSchema.PLATFORM_NAME: { ButtonSchema.PLATFORM: {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: "1/2/3", KNX_ADDRESS: "1/2/3",
CONF_PAYLOAD: False, CONF_PAYLOAD: False,
@ -76,7 +76,7 @@ async def test_button_type(hass: HomeAssistant, knx: KNXTestKit):
"""Test KNX button with encoded payload.""" """Test KNX button with encoded payload."""
await knx.setup_integration( await knx.setup_integration(
{ {
ButtonSchema.PLATFORM_NAME: { ButtonSchema.PLATFORM: {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: "1/2/3", KNX_ADDRESS: "1/2/3",
ButtonSchema.CONF_VALUE: 21.5, ButtonSchema.CONF_VALUE: 21.5,

View File

@ -11,7 +11,7 @@ async def test_fan_percent(hass: HomeAssistant, knx: KNXTestKit):
"""Test KNX fan with percentage speed.""" """Test KNX fan with percentage speed."""
await knx.setup_integration( await knx.setup_integration(
{ {
FanSchema.PLATFORM_NAME: { FanSchema.PLATFORM: {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: "1/2/3", KNX_ADDRESS: "1/2/3",
} }
@ -56,7 +56,7 @@ async def test_fan_step(hass: HomeAssistant, knx: KNXTestKit):
"""Test KNX fan with speed steps.""" """Test KNX fan with speed steps."""
await knx.setup_integration( await knx.setup_integration(
{ {
FanSchema.PLATFORM_NAME: { FanSchema.PLATFORM: {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: "1/2/3", KNX_ADDRESS: "1/2/3",
FanSchema.CONF_MAX_STEP: 4, FanSchema.CONF_MAX_STEP: 4,
@ -109,7 +109,7 @@ async def test_fan_oscillation(hass: HomeAssistant, knx: KNXTestKit):
"""Test KNX fan oscillation.""" """Test KNX fan oscillation."""
await knx.setup_integration( await knx.setup_integration(
{ {
FanSchema.PLATFORM_NAME: { FanSchema.PLATFORM: {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: "1/1/1", KNX_ADDRESS: "1/1/1",
FanSchema.CONF_OSCILLATION_ADDRESS: "2/2/2", FanSchema.CONF_OSCILLATION_ADDRESS: "2/2/2",

View File

@ -3,6 +3,7 @@ from __future__ import annotations
from datetime import timedelta from datetime import timedelta
from xknx.core import XknxConnectionState
from xknx.devices.light import Light as XknxLight from xknx.devices.light import Light as XknxLight
from homeassistant.components.knx.const import CONF_STATE_ADDRESS, KNX_ADDRESS from homeassistant.components.knx.const import CONF_STATE_ADDRESS, KNX_ADDRESS
@ -35,7 +36,7 @@ async def test_light_simple(hass: HomeAssistant, knx: KNXTestKit):
test_address = "1/1/1" test_address = "1/1/1"
await knx.setup_integration( await knx.setup_integration(
{ {
LightSchema.PLATFORM_NAME: { LightSchema.PLATFORM: {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: test_address, KNX_ADDRESS: test_address,
} }
@ -86,7 +87,7 @@ async def test_light_brightness(hass: HomeAssistant, knx: KNXTestKit):
test_brightness_state = "1/1/3" test_brightness_state = "1/1/3"
await knx.setup_integration( await knx.setup_integration(
{ {
LightSchema.PLATFORM_NAME: { LightSchema.PLATFORM: {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: test_address, KNX_ADDRESS: test_address,
LightSchema.CONF_BRIGHTNESS_ADDRESS: test_brightness, LightSchema.CONF_BRIGHTNESS_ADDRESS: test_brightness,
@ -96,6 +97,9 @@ async def test_light_brightness(hass: HomeAssistant, knx: KNXTestKit):
) )
# StateUpdater initialize state # StateUpdater initialize state
await knx.assert_read(test_brightness_state) await knx.assert_read(test_brightness_state)
await knx.xknx.connection_manager.connection_state_changed(
XknxConnectionState.CONNECTED
)
# turn on light via brightness # turn on light via brightness
await hass.services.async_call( await hass.services.async_call(
"light", "light",
@ -139,7 +143,7 @@ async def test_light_color_temp_absolute(hass: HomeAssistant, knx: KNXTestKit):
test_ct_state = "1/1/6" test_ct_state = "1/1/6"
await knx.setup_integration( await knx.setup_integration(
{ {
LightSchema.PLATFORM_NAME: [ LightSchema.PLATFORM: [
{ {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: test_address, KNX_ADDRESS: test_address,
@ -193,7 +197,7 @@ async def test_light_color_temp_relative(hass: HomeAssistant, knx: KNXTestKit):
test_ct_state = "1/1/6" test_ct_state = "1/1/6"
await knx.setup_integration( await knx.setup_integration(
{ {
LightSchema.PLATFORM_NAME: [ LightSchema.PLATFORM: [
{ {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: test_address, KNX_ADDRESS: test_address,
@ -251,7 +255,7 @@ async def test_light_hs_color(hass: HomeAssistant, knx: KNXTestKit):
test_sat_state = "1/1/8" test_sat_state = "1/1/8"
await knx.setup_integration( await knx.setup_integration(
{ {
LightSchema.PLATFORM_NAME: [ LightSchema.PLATFORM: [
{ {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: test_address, KNX_ADDRESS: test_address,
@ -335,7 +339,7 @@ async def test_light_xyy_color(hass: HomeAssistant, knx: KNXTestKit):
test_xyy_state = "1/1/6" test_xyy_state = "1/1/6"
await knx.setup_integration( await knx.setup_integration(
{ {
LightSchema.PLATFORM_NAME: [ LightSchema.PLATFORM: [
{ {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: test_address, KNX_ADDRESS: test_address,
@ -410,7 +414,7 @@ async def test_light_xyy_color_with_brightness(hass: HomeAssistant, knx: KNXTest
test_xyy_state = "1/1/6" test_xyy_state = "1/1/6"
await knx.setup_integration( await knx.setup_integration(
{ {
LightSchema.PLATFORM_NAME: [ LightSchema.PLATFORM: [
{ {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: test_address, KNX_ADDRESS: test_address,
@ -488,7 +492,7 @@ async def test_light_rgb_individual(hass: HomeAssistant, knx: KNXTestKit):
test_blue_state = "1/1/8" test_blue_state = "1/1/8"
await knx.setup_integration( await knx.setup_integration(
{ {
LightSchema.PLATFORM_NAME: [ LightSchema.PLATFORM: [
{ {
CONF_NAME: "test", CONF_NAME: "test",
LightSchema.CONF_INDIVIDUAL_COLORS: { LightSchema.CONF_INDIVIDUAL_COLORS: {
@ -636,7 +640,7 @@ async def test_light_rgbw_individual(hass: HomeAssistant, knx: KNXTestKit):
test_white_state = "1/1/10" test_white_state = "1/1/10"
await knx.setup_integration( await knx.setup_integration(
{ {
LightSchema.PLATFORM_NAME: [ LightSchema.PLATFORM: [
{ {
CONF_NAME: "test", CONF_NAME: "test",
LightSchema.CONF_INDIVIDUAL_COLORS: { LightSchema.CONF_INDIVIDUAL_COLORS: {
@ -810,7 +814,7 @@ async def test_light_rgb(hass: HomeAssistant, knx: KNXTestKit):
test_rgb_state = "1/1/6" test_rgb_state = "1/1/6"
await knx.setup_integration( await knx.setup_integration(
{ {
LightSchema.PLATFORM_NAME: [ LightSchema.PLATFORM: [
{ {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: test_address, KNX_ADDRESS: test_address,
@ -918,7 +922,7 @@ async def test_light_rgbw(hass: HomeAssistant, knx: KNXTestKit):
test_rgbw_state = "1/1/6" test_rgbw_state = "1/1/6"
await knx.setup_integration( await knx.setup_integration(
{ {
LightSchema.PLATFORM_NAME: [ LightSchema.PLATFORM: [
{ {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: test_address, KNX_ADDRESS: test_address,
@ -1031,7 +1035,7 @@ async def test_light_rgbw_brightness(hass: HomeAssistant, knx: KNXTestKit):
test_rgbw_state = "1/1/6" test_rgbw_state = "1/1/6"
await knx.setup_integration( await knx.setup_integration(
{ {
LightSchema.PLATFORM_NAME: [ LightSchema.PLATFORM: [
{ {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: test_address, KNX_ADDRESS: test_address,

View File

@ -16,7 +16,7 @@ async def test_number_set_value(hass: HomeAssistant, knx: KNXTestKit):
test_address = "1/1/1" test_address = "1/1/1"
await knx.setup_integration( await knx.setup_integration(
{ {
NumberSchema.PLATFORM_NAME: { NumberSchema.PLATFORM: {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: test_address, KNX_ADDRESS: test_address,
CONF_TYPE: "percent", CONF_TYPE: "percent",
@ -72,7 +72,7 @@ async def test_number_restore_and_respond(hass: HomeAssistant, knx: KNXTestKit):
): ):
await knx.setup_integration( await knx.setup_integration(
{ {
NumberSchema.PLATFORM_NAME: { NumberSchema.PLATFORM: {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: [test_address, test_passive_address], KNX_ADDRESS: [test_address, test_passive_address],
CONF_RESPOND_TO_READ: True, CONF_RESPOND_TO_READ: True,

View File

@ -19,7 +19,7 @@ async def test_activate_knx_scene(hass: HomeAssistant, knx: KNXTestKit):
"""Test KNX scene.""" """Test KNX scene."""
await knx.setup_integration( await knx.setup_integration(
{ {
SceneSchema.PLATFORM_NAME: [ SceneSchema.PLATFORM: [
{ {
CONF_NAME: "test", CONF_NAME: "test",
SceneSchema.CONF_SCENE_NUMBER: 24, SceneSchema.CONF_SCENE_NUMBER: 24,

View File

@ -28,7 +28,7 @@ async def test_select_dpt_2_simple(hass: HomeAssistant, knx: KNXTestKit):
test_address = "1/1/1" test_address = "1/1/1"
await knx.setup_integration( await knx.setup_integration(
{ {
SelectSchema.PLATFORM_NAME: { SelectSchema.PLATFORM: {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: test_address, KNX_ADDRESS: test_address,
CONF_SYNC_STATE: False, CONF_SYNC_STATE: False,
@ -105,7 +105,7 @@ async def test_select_dpt_2_restore(hass: HomeAssistant, knx: KNXTestKit):
): ):
await knx.setup_integration( await knx.setup_integration(
{ {
SelectSchema.PLATFORM_NAME: { SelectSchema.PLATFORM: {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: [test_address, test_passive_address], KNX_ADDRESS: [test_address, test_passive_address],
CONF_RESPOND_TO_READ: True, CONF_RESPOND_TO_READ: True,
@ -143,7 +143,7 @@ async def test_select_dpt_20_103_all_options(hass: HomeAssistant, knx: KNXTestKi
await knx.setup_integration( await knx.setup_integration(
{ {
SelectSchema.PLATFORM_NAME: { SelectSchema.PLATFORM: {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: [test_address, test_passive_address], KNX_ADDRESS: [test_address, test_passive_address],
CONF_STATE_ADDRESS: test_state_address, CONF_STATE_ADDRESS: test_state_address,

View File

@ -14,7 +14,7 @@ async def test_sensor(hass: HomeAssistant, knx: KNXTestKit):
await knx.setup_integration( await knx.setup_integration(
{ {
SensorSchema.PLATFORM_NAME: { SensorSchema.PLATFORM: {
CONF_NAME: "test", CONF_NAME: "test",
CONF_STATE_ADDRESS: "1/1/1", CONF_STATE_ADDRESS: "1/1/1",
CONF_TYPE: "current", # 2 byte unsigned int CONF_TYPE: "current", # 2 byte unsigned int
@ -47,7 +47,7 @@ async def test_always_callback(hass: HomeAssistant, knx: KNXTestKit):
events = async_capture_events(hass, "state_changed") events = async_capture_events(hass, "state_changed")
await knx.setup_integration( await knx.setup_integration(
{ {
SensorSchema.PLATFORM_NAME: [ SensorSchema.PLATFORM: [
{ {
CONF_NAME: "test_normal", CONF_NAME: "test_normal",
CONF_STATE_ADDRESS: "1/1/1", CONF_STATE_ADDRESS: "1/1/1",

View File

@ -17,7 +17,7 @@ async def test_switch_simple(hass: HomeAssistant, knx: KNXTestKit):
"""Test simple KNX switch.""" """Test simple KNX switch."""
await knx.setup_integration( await knx.setup_integration(
{ {
SwitchSchema.PLATFORM_NAME: { SwitchSchema.PLATFORM: {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: "1/2/3", KNX_ADDRESS: "1/2/3",
} }
@ -59,7 +59,7 @@ async def test_switch_state(hass: HomeAssistant, knx: KNXTestKit):
await knx.setup_integration( await knx.setup_integration(
{ {
SwitchSchema.PLATFORM_NAME: { SwitchSchema.PLATFORM: {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: _ADDRESS, KNX_ADDRESS: _ADDRESS,
CONF_STATE_ADDRESS: _STATE_ADDRESS, CONF_STATE_ADDRESS: _STATE_ADDRESS,
@ -122,7 +122,7 @@ async def test_switch_restore_and_respond(hass, knx):
): ):
await knx.setup_integration( await knx.setup_integration(
{ {
SwitchSchema.PLATFORM_NAME: { SwitchSchema.PLATFORM: {
CONF_NAME: "test", CONF_NAME: "test",
KNX_ADDRESS: _ADDRESS, KNX_ADDRESS: _ADDRESS,
CONF_RESPOND_TO_READ: True, CONF_RESPOND_TO_READ: True,

View File

@ -17,7 +17,7 @@ async def test_weather(hass: HomeAssistant, knx: KNXTestKit):
await knx.setup_integration( await knx.setup_integration(
{ {
WeatherSchema.PLATFORM_NAME: { WeatherSchema.PLATFORM: {
CONF_NAME: "test", CONF_NAME: "test",
WeatherSchema.CONF_KNX_WIND_ALARM_ADDRESS: "1/1/1", WeatherSchema.CONF_KNX_WIND_ALARM_ADDRESS: "1/1/1",
WeatherSchema.CONF_KNX_RAIN_ALARM_ADDRESS: "1/1/2", WeatherSchema.CONF_KNX_RAIN_ALARM_ADDRESS: "1/1/2",