From 83b489b8ad681d597ddc9bc32554867b389e2a3d Mon Sep 17 00:00:00 2001 From: Marvin Wichmann Date: Sun, 28 Mar 2021 17:24:36 +0200 Subject: [PATCH 1/2] Remove Config v2 --- docs/configuration.md | 3 + test/config_tests/config_v1_test.py | 9 - .../resources/binary_sensor/invalid_1.yaml | 10 - .../resources/binary_sensor/invalid_2.yaml | 5 - .../resources/binary_sensor/invalid_3.yaml | 3 - .../resources/binary_sensor/invalid_4.yaml | 4 - .../resources/binary_sensor/invalid_5.yaml | 5 - .../resources/binary_sensor/valid_1.yaml | 10 - .../resources/binary_sensor/valid_2.yaml | 9 - .../resources/binary_sensor/valid_3.yaml | 5 - .../resources/binary_sensor/valid_4.yaml | 10 - .../resources/climate/invalid_1.yaml | 40 - .../resources/climate/invalid_2.yaml | 39 - .../resources/climate/invalid_3.yaml | 39 - .../resources/climate/valid_1.yaml | 40 - .../resources/climate/valid_2.yaml | 20 - .../resources/connection/invalid_1.yaml | 4 - .../resources/connection/invalid_2.yaml | 4 - .../resources/connection/invalid_3.yaml | 4 - .../resources/connection/valid_1.yaml | 4 - .../resources/connection/valid_2.yaml | 3 - .../resources/connection/valid_3.yaml | 1 - .../resources/cover/invalid_1.yaml | 20 - .../resources/cover/invalid_2.yaml | 17 - .../config_tests/resources/cover/valid_1.yaml | 20 - .../config_tests/resources/cover/valid_2.yaml | 4 - .../config_tests/resources/cover/valid_3.yaml | 15 - .../resources/datetime/invalid_1.yaml | 4 - .../resources/datetime/invalid_2.yaml | 3 - .../resources/datetime/valid_1.yaml | 4 - .../resources/datetime/valid_2.yaml | 4 - .../resources/datetime/valid_3.yaml | 4 - .../resources/expose/invalid_1.yaml | 2 - .../resources/expose/invalid_2.yaml | 2 - .../resources/expose/invalid_3.yaml | 2 - .../resources/expose/valid_1.yaml | 5 - .../resources/expose/valid_2.yaml | 3 - .../resources/expose/valid_3.yaml | 2 - .../config_tests/resources/fan/invalid_1.yaml | 5 - test/config_tests/resources/fan/valid_1.yaml | 6 - .../resources/light/invalid_1.yaml | 22 - .../resources/light/invalid_2.yaml | 21 - .../resources/light/invalid_3.yaml | 25 - .../config_tests/resources/light/valid_1.yaml | 22 - .../config_tests/resources/light/valid_2.yaml | 4 - .../config_tests/resources/light/valid_3.yaml | 12 - .../config_tests/resources/light/valid_4.yaml | 10 - .../config_tests/resources/light/valid_5.yaml | 10 - .../resources/light/valid_rgb.yaml | 24 - .../resources/light/valid_rgbw.yaml | 31 - .../resources/light/valid_rgbw_no_switch.yaml | 21 - .../resources/notification/invalid_1.yaml | 3 - .../resources/notification/valid_1.yaml | 4 - .../resources/notification/valid_2.yaml | 4 - .../resources/scene/invalid_1.yaml | 6 - .../resources/scene/invalid_2.yaml | 5 - .../resources/scene/invalid_3.yaml | 5 - .../config_tests/resources/scene/valid_1.yaml | 6 - .../config_tests/resources/scene/valid_2.yaml | 5 - .../resources/sensor/invalid_1.yaml | 5 - .../resources/sensor/valid_1.yaml | 6 - .../resources/sensor/valid_2.yaml | 5 - .../resources/switch/invalid_1.yaml | 6 - .../resources/switch/invalid_2.yaml | 6 - .../resources/switch/valid_1.yaml | 7 - .../resources/switch/valid_2.yaml | 3 - .../resources/weather/invalid_1.yaml | 39 - .../resources/weather/invalid_2.yaml | 40 - .../resources/weather/valid_1.yaml | 42 -- .../resources/weather/valid_2.yaml | 6 - .../resources/xknx/invalid_1.yaml | 197 ----- .../resources/xknx/invalid_2.yaml | 195 ----- .../resources/xknx/invalid_3.yaml | 194 ----- .../resources/xknx/invalid_4.yaml | 8 - .../resources/xknx/invalid_5.yaml | 7 - .../resources/xknx/invalid_6.yaml | 7 - .../resources/xknx/invalid_7.yaml | 7 - test/config_tests/resources/xknx/valid_1.yaml | 200 ----- test/config_tests/resources/xknx/valid_2.yaml | 197 ----- test/config_tests/resources/xknx/valid_3.yaml | 202 ------ test/config_tests/resources/xknx/valid_4.yaml | 2 - test/config_tests/schema_test.py | 93 --- test/config_tests/yaml_loader_test.py | 105 --- xknx/config/__init__.py | 30 - xknx/config/config.py | 37 +- xknx/config/config_validation.py | 117 --- xknx/config/entries/__init__.py | 1 - xknx/config/objects.py | 9 - xknx/config/schema.py | 683 ------------------ xknx/config/yaml_loader.py | 116 --- 90 files changed, 12 insertions(+), 3193 deletions(-) delete mode 100644 test/config_tests/resources/binary_sensor/invalid_1.yaml delete mode 100644 test/config_tests/resources/binary_sensor/invalid_2.yaml delete mode 100644 test/config_tests/resources/binary_sensor/invalid_3.yaml delete mode 100644 test/config_tests/resources/binary_sensor/invalid_4.yaml delete mode 100644 test/config_tests/resources/binary_sensor/invalid_5.yaml delete mode 100644 test/config_tests/resources/binary_sensor/valid_1.yaml delete mode 100644 test/config_tests/resources/binary_sensor/valid_2.yaml delete mode 100644 test/config_tests/resources/binary_sensor/valid_3.yaml delete mode 100644 test/config_tests/resources/binary_sensor/valid_4.yaml delete mode 100644 test/config_tests/resources/climate/invalid_1.yaml delete mode 100644 test/config_tests/resources/climate/invalid_2.yaml delete mode 100644 test/config_tests/resources/climate/invalid_3.yaml delete mode 100644 test/config_tests/resources/climate/valid_1.yaml delete mode 100644 test/config_tests/resources/climate/valid_2.yaml delete mode 100644 test/config_tests/resources/connection/invalid_1.yaml delete mode 100644 test/config_tests/resources/connection/invalid_2.yaml delete mode 100644 test/config_tests/resources/connection/invalid_3.yaml delete mode 100644 test/config_tests/resources/connection/valid_1.yaml delete mode 100644 test/config_tests/resources/connection/valid_2.yaml delete mode 100644 test/config_tests/resources/connection/valid_3.yaml delete mode 100644 test/config_tests/resources/cover/invalid_1.yaml delete mode 100644 test/config_tests/resources/cover/invalid_2.yaml delete mode 100644 test/config_tests/resources/cover/valid_1.yaml delete mode 100644 test/config_tests/resources/cover/valid_2.yaml delete mode 100644 test/config_tests/resources/cover/valid_3.yaml delete mode 100644 test/config_tests/resources/datetime/invalid_1.yaml delete mode 100644 test/config_tests/resources/datetime/invalid_2.yaml delete mode 100644 test/config_tests/resources/datetime/valid_1.yaml delete mode 100644 test/config_tests/resources/datetime/valid_2.yaml delete mode 100644 test/config_tests/resources/datetime/valid_3.yaml delete mode 100644 test/config_tests/resources/expose/invalid_1.yaml delete mode 100644 test/config_tests/resources/expose/invalid_2.yaml delete mode 100644 test/config_tests/resources/expose/invalid_3.yaml delete mode 100644 test/config_tests/resources/expose/valid_1.yaml delete mode 100644 test/config_tests/resources/expose/valid_2.yaml delete mode 100644 test/config_tests/resources/expose/valid_3.yaml delete mode 100644 test/config_tests/resources/fan/invalid_1.yaml delete mode 100644 test/config_tests/resources/fan/valid_1.yaml delete mode 100644 test/config_tests/resources/light/invalid_1.yaml delete mode 100644 test/config_tests/resources/light/invalid_2.yaml delete mode 100644 test/config_tests/resources/light/invalid_3.yaml delete mode 100644 test/config_tests/resources/light/valid_1.yaml delete mode 100644 test/config_tests/resources/light/valid_2.yaml delete mode 100644 test/config_tests/resources/light/valid_3.yaml delete mode 100644 test/config_tests/resources/light/valid_4.yaml delete mode 100644 test/config_tests/resources/light/valid_5.yaml delete mode 100644 test/config_tests/resources/light/valid_rgb.yaml delete mode 100644 test/config_tests/resources/light/valid_rgbw.yaml delete mode 100644 test/config_tests/resources/light/valid_rgbw_no_switch.yaml delete mode 100644 test/config_tests/resources/notification/invalid_1.yaml delete mode 100644 test/config_tests/resources/notification/valid_1.yaml delete mode 100644 test/config_tests/resources/notification/valid_2.yaml delete mode 100644 test/config_tests/resources/scene/invalid_1.yaml delete mode 100644 test/config_tests/resources/scene/invalid_2.yaml delete mode 100644 test/config_tests/resources/scene/invalid_3.yaml delete mode 100644 test/config_tests/resources/scene/valid_1.yaml delete mode 100644 test/config_tests/resources/scene/valid_2.yaml delete mode 100644 test/config_tests/resources/sensor/invalid_1.yaml delete mode 100644 test/config_tests/resources/sensor/valid_1.yaml delete mode 100644 test/config_tests/resources/sensor/valid_2.yaml delete mode 100644 test/config_tests/resources/switch/invalid_1.yaml delete mode 100644 test/config_tests/resources/switch/invalid_2.yaml delete mode 100644 test/config_tests/resources/switch/valid_1.yaml delete mode 100644 test/config_tests/resources/switch/valid_2.yaml delete mode 100644 test/config_tests/resources/weather/invalid_1.yaml delete mode 100644 test/config_tests/resources/weather/invalid_2.yaml delete mode 100644 test/config_tests/resources/weather/valid_1.yaml delete mode 100644 test/config_tests/resources/weather/valid_2.yaml delete mode 100644 test/config_tests/resources/xknx/invalid_1.yaml delete mode 100644 test/config_tests/resources/xknx/invalid_2.yaml delete mode 100644 test/config_tests/resources/xknx/invalid_3.yaml delete mode 100644 test/config_tests/resources/xknx/invalid_4.yaml delete mode 100644 test/config_tests/resources/xknx/invalid_5.yaml delete mode 100644 test/config_tests/resources/xknx/invalid_6.yaml delete mode 100644 test/config_tests/resources/xknx/invalid_7.yaml delete mode 100644 test/config_tests/resources/xknx/valid_1.yaml delete mode 100644 test/config_tests/resources/xknx/valid_2.yaml delete mode 100644 test/config_tests/resources/xknx/valid_3.yaml delete mode 100644 test/config_tests/resources/xknx/valid_4.yaml delete mode 100644 test/config_tests/schema_test.py delete mode 100644 test/config_tests/yaml_loader_test.py delete mode 100644 xknx/config/config_validation.py delete mode 100644 xknx/config/entries/__init__.py delete mode 100644 xknx/config/objects.py delete mode 100644 xknx/config/schema.py delete mode 100644 xknx/config/yaml_loader.py diff --git a/docs/configuration.md b/docs/configuration.md index a652186551..b29b73036c 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -7,6 +7,9 @@ has_children: true # Configuration +NOTE: Using `xknx.yaml` is no longer supported and the functionality will be removed in a future version. Instead, please +use standard python code or (if you are using Home Assistant) simply use the Home Assistant configuration to configure your KNX devices. + ## Overview XKNX is controlled via a configuration file. Per default the configuration file is named `xknx.yaml`. diff --git a/test/config_tests/config_v1_test.py b/test/config_tests/config_v1_test.py index ec56df5be2..26d433e304 100644 --- a/test/config_tests/config_v1_test.py +++ b/test/config_tests/config_v1_test.py @@ -122,15 +122,6 @@ def test_config_connection(self): ConfigV1(TestConfig.xknx).parse_connection(config) self.assertEqual(TestConfig.xknx.connection_config, expected_conn) - def test_version_2(self): - """Test connection section from config file.""" - # Replaces setting from xknx.yaml - test_config = """ - version: 2 - """ - config = yaml.safe_load(test_config) - self.assertRaises(NotImplementedError, Config(TestConfig.xknx).parse, config) - def test_config_invalid_connection(self): """Test invalid connection section from config file.""" diff --git a/test/config_tests/resources/binary_sensor/invalid_1.yaml b/test/config_tests/resources/binary_sensor/invalid_1.yaml deleted file mode 100644 index f328c3e101..0000000000 --- a/test/config_tests/resources/binary_sensor/invalid_1.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: "required key not provided .*state_address.*" -friendly_name: "" -address: - address: "2/2/2" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -context_timeout: 1 -device_class: 'light' -reset_after: 3000 # ms -ignore_internal_state: False \ No newline at end of file diff --git a/test/config_tests/resources/binary_sensor/invalid_2.yaml b/test/config_tests/resources/binary_sensor/invalid_2.yaml deleted file mode 100644 index 4fedac4bba..0000000000 --- a/test/config_tests/resources/binary_sensor/invalid_2.yaml +++ /dev/null @@ -1,5 +0,0 @@ -name: "required key not provided .*address.*" -context_timeout: 1 -device_class: 'light' -reset_after: 3000 # ms -ignore_internal_state: False diff --git a/test/config_tests/resources/binary_sensor/invalid_3.yaml b/test/config_tests/resources/binary_sensor/invalid_3.yaml deleted file mode 100644 index 9fd4341f64..0000000000 --- a/test/config_tests/resources/binary_sensor/invalid_3.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: "string value is None for dictionary value .*friendly_name.*" -friendly_name: -address: \ No newline at end of file diff --git a/test/config_tests/resources/binary_sensor/invalid_4.yaml b/test/config_tests/resources/binary_sensor/invalid_4.yaml deleted file mode 100644 index 0646f45fc6..0000000000 --- a/test/config_tests/resources/binary_sensor/invalid_4.yaml +++ /dev/null @@ -1,4 +0,0 @@ -name: "value should be a string for dictionary value .*friendly_name.*" -friendly_name: ["teer"] -address: - state_update: "expire 60" \ No newline at end of file diff --git a/test/config_tests/resources/binary_sensor/invalid_5.yaml b/test/config_tests/resources/binary_sensor/invalid_5.yaml deleted file mode 100644 index 3ebe3ba259..0000000000 --- a/test/config_tests/resources/binary_sensor/invalid_5.yaml +++ /dev/null @@ -1,5 +0,0 @@ -name: ".*is not a valid group address.*" -friendly_name: "" -address: - state_address: "2/2/2/2" - state_update: "expire 60" \ No newline at end of file diff --git a/test/config_tests/resources/binary_sensor/valid_1.yaml b/test/config_tests/resources/binary_sensor/valid_1.yaml deleted file mode 100644 index a1bf82b647..0000000000 --- a/test/config_tests/resources/binary_sensor/valid_1.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: "test_complete" -friendly_name: "" -address: - state_address: "1/2/7" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -context_timeout: 1 -device_class: 'light' -reset_after: 3000 # ms -ignore_internal_state: False \ No newline at end of file diff --git a/test/config_tests/resources/binary_sensor/valid_2.yaml b/test/config_tests/resources/binary_sensor/valid_2.yaml deleted file mode 100644 index 0f5c7118cc..0000000000 --- a/test/config_tests/resources/binary_sensor/valid_2.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: "test_no_friendly_name" -address: - state_address: "1/2/7" - state_update: "expire 60" - passive_state_addresses: -context_timeout: 1 -device_class: 'light' -reset_after: 3000 # ms -ignore_internal_state: 0 \ No newline at end of file diff --git a/test/config_tests/resources/binary_sensor/valid_3.yaml b/test/config_tests/resources/binary_sensor/valid_3.yaml deleted file mode 100644 index 8697f4db72..0000000000 --- a/test/config_tests/resources/binary_sensor/valid_3.yaml +++ /dev/null @@ -1,5 +0,0 @@ -name: "test_minimal" -friendly_name: "" -address: - state_address: "1/2/7" -ignore_internal_state: "on" \ No newline at end of file diff --git a/test/config_tests/resources/binary_sensor/valid_4.yaml b/test/config_tests/resources/binary_sensor/valid_4.yaml deleted file mode 100644 index ee567ab23f..0000000000 --- a/test/config_tests/resources/binary_sensor/valid_4.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: "livingroom_switch1" -friendly_name: "" -address: - state_address: "1/2/7" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -context_timeout: 1 -device_class: 'light' -reset_after: 3000 # ms -ignore_internal_state: "off" \ No newline at end of file diff --git a/test/config_tests/resources/climate/invalid_1.yaml b/test/config_tests/resources/climate/invalid_1.yaml deleted file mode 100644 index 7d9caa5c25..0000000000 --- a/test/config_tests/resources/climate/invalid_1.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: "value must be one of .*operation_modes.*" -friendly_name: "Bathroom" -target_temperature: - address: "4/0/0" - state_address: "4/0/1" - state_update: "expire 60" - min: -7 - max: 30 -setpoint_shift: - address: "4/0/2" - state_address: "4/0/3" - mode: DPT6010 - temperature_step: 0.1 - min: -6 - max: 6 -operation_mode: - address: "4/0/4" - state_address: "4/0/5" -binary_operation_mode: - frost_protection_address: "4/0/6" - comfort_address: "4/0/7" - night_address: "4/0/8" - standby_address: "5/0/0" -controller_status: - address: "4/0/9" - state_address: "4/0/10" -controller_mode: - address: "4/0/11" - state_address: "4/0/12" -heat_cool: - address: "4/0/13" - state_address: "4/0/14" - invert: False -operation_modes: - - "Heat" - - "sdfg" -on_off: - address: "4/0/15" - state_address: "4/0/16" - invert: False \ No newline at end of file diff --git a/test/config_tests/resources/climate/invalid_2.yaml b/test/config_tests/resources/climate/invalid_2.yaml deleted file mode 100644 index 9e1634f263..0000000000 --- a/test/config_tests/resources/climate/invalid_2.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: "required key not provided .*address.*" -friendly_name: "Bathroom" -target_temperature: - address: "4/0/0" - state_address: "4/0/1" - state_update: "expire 60" - min: -7 - max: 30 -setpoint_shift: - address: "4/0/2" - state_address: "4/0/3" - mode: DPT6010 - temperature_step: 0.1 - min: -6 - max: 6 -operation_mode: - state_address: "4/0/5" -binary_operation_mode: - frost_protection_address: "4/0/6" - comfort_address: "4/0/7" - night_address: "4/0/8" - standby_address: "5/0/0" -controller_status: - address: "4/0/9" - state_address: "4/0/10" -controller_mode: - address: "4/0/11" - state_address: "4/0/12" -heat_cool: - address: "4/0/13" - state_address: "4/0/14" - invert: False -operation_modes: - - "Heat" - - "sdfg" -on_off: - address: "4/0/15" - state_address: "4/0/16" - invert: False \ No newline at end of file diff --git a/test/config_tests/resources/climate/invalid_3.yaml b/test/config_tests/resources/climate/invalid_3.yaml deleted file mode 100644 index bc4d7b069f..0000000000 --- a/test/config_tests/resources/climate/invalid_3.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: "value must be one of .*mode.*" -friendly_name: "Bathroom" -target_temperature: - address: "4/0/0" - state_address: "4/0/1" - state_update: "expire 60" - min: -7 - max: 30 -setpoint_shift: - address: "4/0/2" - state_address: "4/0/3" - mode: DPT6011 - temperature_step: 0.1 - min: -6 - max: 6 -operation_mode: - state_address: "4/0/5" -binary_operation_mode: - frost_protection_address: "4/0/6" - comfort_address: "4/0/7" - night_address: "4/0/8" - standby_address: "5/0/0" -controller_status: - address: "4/0/9" - state_address: "4/0/10" -controller_mode: - address: "4/0/11" - state_address: "4/0/12" -heat_cool: - address: "4/0/13" - state_address: "4/0/14" - invert: False -operation_modes: - - "Heat" - - "sdfg" -on_off: - address: "4/0/15" - state_address: "4/0/16" - invert: False \ No newline at end of file diff --git a/test/config_tests/resources/climate/valid_1.yaml b/test/config_tests/resources/climate/valid_1.yaml deleted file mode 100644 index fd366ea671..0000000000 --- a/test/config_tests/resources/climate/valid_1.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: "bathroom" -friendly_name: "Bathroom" -target_temperature: - address: "4/0/0" - state_address: "4/0/1" - state_update: "expire 60" - min: -7 - max: 30 -setpoint_shift: - address: "4/0/2" - state_address: "4/0/3" - mode: DPT6010 - temperature_step: 0.1 - min: -6 - max: 6 -operation_mode: - address: "4/0/4" - state_address: "4/0/5" -binary_operation_mode: - frost_protection_address: "4/0/6" - comfort_address: "4/0/7" - night_address: "4/0/8" - standby_address: "5/0/0" -controller_status: - address: "4/0/9" - state_address: "4/0/10" -controller_mode: - address: "4/0/11" - state_address: "4/0/12" -heat_cool: - address: "4/0/13" - state_address: "4/0/14" - invert: False -operation_modes: - - "Heat" - - "Cool" -on_off: - address: "4/0/15" - state_address: "4/0/16" - invert: False \ No newline at end of file diff --git a/test/config_tests/resources/climate/valid_2.yaml b/test/config_tests/resources/climate/valid_2.yaml deleted file mode 100644 index 7c110b1487..0000000000 --- a/test/config_tests/resources/climate/valid_2.yaml +++ /dev/null @@ -1,20 +0,0 @@ -name: "bathroom" -friendly_name: "Bathroom" -target_temperature: - address: "4/0/0" - state_address: "4/0/1" - state_update: "expire 60" - min: -7 - max: 30 -setpoint_shift: - address: "4/0/2" - state_address: "4/0/3" - mode: DPT6010 - temperature_step: 0.1 - min: -6 - max: 6 -binary_operation_mode: - frost_protection_address: "4/0/6" - comfort_address: "4/0/7" - night_address: "4/0/8" - standby_address: "5/0/0" \ No newline at end of file diff --git a/test/config_tests/resources/connection/invalid_1.yaml b/test/config_tests/resources/connection/invalid_1.yaml deleted file mode 100644 index e53a418995..0000000000 --- a/test/config_tests/resources/connection/invalid_1.yaml +++ /dev/null @@ -1,4 +0,0 @@ -type: notavailable -local_ip: "192.168.0.201" -host: "192.168.0.202" -port: 1337 \ No newline at end of file diff --git a/test/config_tests/resources/connection/invalid_2.yaml b/test/config_tests/resources/connection/invalid_2.yaml deleted file mode 100644 index d9d1854d3d..0000000000 --- a/test/config_tests/resources/connection/invalid_2.yaml +++ /dev/null @@ -1,4 +0,0 @@ -type: tunneling -local_ip: "192.168.0.201" -host: "192.168.0.202" -port: 3245345345 \ No newline at end of file diff --git a/test/config_tests/resources/connection/invalid_3.yaml b/test/config_tests/resources/connection/invalid_3.yaml deleted file mode 100644 index f664a79264..0000000000 --- a/test/config_tests/resources/connection/invalid_3.yaml +++ /dev/null @@ -1,4 +0,0 @@ -type: tunneling -local_ip: "192.168.0.201" -host: 234234234 -port: 1337 \ No newline at end of file diff --git a/test/config_tests/resources/connection/valid_1.yaml b/test/config_tests/resources/connection/valid_1.yaml deleted file mode 100644 index 85973e9149..0000000000 --- a/test/config_tests/resources/connection/valid_1.yaml +++ /dev/null @@ -1,4 +0,0 @@ -type: TUNNELING -local_ip: "192.168.0.201" -host: "192.168.0.202" -port: 1337 \ No newline at end of file diff --git a/test/config_tests/resources/connection/valid_2.yaml b/test/config_tests/resources/connection/valid_2.yaml deleted file mode 100644 index 2919af0530..0000000000 --- a/test/config_tests/resources/connection/valid_2.yaml +++ /dev/null @@ -1,3 +0,0 @@ -type: ROUTING -host: "192.168.0.202" -port: 1337 \ No newline at end of file diff --git a/test/config_tests/resources/connection/valid_3.yaml b/test/config_tests/resources/connection/valid_3.yaml deleted file mode 100644 index 0a2767c9b0..0000000000 --- a/test/config_tests/resources/connection/valid_3.yaml +++ /dev/null @@ -1 +0,0 @@ -type: AUTO \ No newline at end of file diff --git a/test/config_tests/resources/cover/invalid_1.yaml b/test/config_tests/resources/cover/invalid_1.yaml deleted file mode 100644 index ac1135d27e..0000000000 --- a/test/config_tests/resources/cover/invalid_1.yaml +++ /dev/null @@ -1,20 +0,0 @@ -name: "invalid boolean value.*" -friendly_name: "Livingroom TV" -long_movement: - address: "3/3/3" - invert: Tasdasdrue -short_movement: - address: "3/3/4" - invert: True -stop_address: "3/3/5" -position: - address: "3/3/6" - state_address: "3/3/7" - state_update: "expire 60" - invert: True -angle: - address: "3/3/8" - state_address: "3/3/9" - invert: True -travelling_time_up: 50 -travelling_time_down: 30 \ No newline at end of file diff --git a/test/config_tests/resources/cover/invalid_2.yaml b/test/config_tests/resources/cover/invalid_2.yaml deleted file mode 100644 index be568e13bd..0000000000 --- a/test/config_tests/resources/cover/invalid_2.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: "required key.*" -friendly_name: "Livingroom TV" -short_movement: - address: "3/3/4" - invert: True -stop_address: "3/3/5" -position: - address: "3/3/6" - state_address: "3/3/7" - state_update: "expire 60" - invert: True -angle: - address: "3/3/8" - state_address: "3/3/9" - invert: True -travelling_time_up: 50 -travelling_time_down: 30 \ No newline at end of file diff --git a/test/config_tests/resources/cover/valid_1.yaml b/test/config_tests/resources/cover/valid_1.yaml deleted file mode 100644 index 13ee8183e3..0000000000 --- a/test/config_tests/resources/cover/valid_1.yaml +++ /dev/null @@ -1,20 +0,0 @@ -name: "livingroom_tv" -friendly_name: "Livingroom TV" -long_movement: - address: "3/3/3" - invert: True -short_movement: - address: "3/3/4" - invert: True -stop_address: "3/3/5" -position: - address: "3/3/6" - state_address: "3/3/7" - state_update: "expire 60" - invert: True -angle: - address: "3/3/8" - state_address: "3/3/9" - invert: True -travelling_time_up: 50 -travelling_time_down: 30 \ No newline at end of file diff --git a/test/config_tests/resources/cover/valid_2.yaml b/test/config_tests/resources/cover/valid_2.yaml deleted file mode 100644 index d203aa0d33..0000000000 --- a/test/config_tests/resources/cover/valid_2.yaml +++ /dev/null @@ -1,4 +0,0 @@ -name: "livingroom_tv" -friendly_name: "Livingroom TV" -long_movement: - address: "3/3/3" \ No newline at end of file diff --git a/test/config_tests/resources/cover/valid_3.yaml b/test/config_tests/resources/cover/valid_3.yaml deleted file mode 100644 index f8f9d1a8eb..0000000000 --- a/test/config_tests/resources/cover/valid_3.yaml +++ /dev/null @@ -1,15 +0,0 @@ -name: "livingroom_tv" -friendly_name: "Livingroom TV" -long_movement: - address: "3/3/3" - invert: True -short_movement: - address: "3/3/4" - invert: True -position: - address: "3/3/6" - state_address: "3/3/7" - state_update: "expire 60" - invert: True -travelling_time_up: 50 -travelling_time_down: 30 \ No newline at end of file diff --git a/test/config_tests/resources/datetime/invalid_1.yaml b/test/config_tests/resources/datetime/invalid_1.yaml deleted file mode 100644 index 71d599529b..0000000000 --- a/test/config_tests/resources/datetime/invalid_1.yaml +++ /dev/null @@ -1,4 +0,0 @@ -name: "value must be one of .*broadcast_type.*" -time: - address: "8/4/4" - broadcast_type: sdaf \ No newline at end of file diff --git a/test/config_tests/resources/datetime/invalid_2.yaml b/test/config_tests/resources/datetime/invalid_2.yaml deleted file mode 100644 index f0f8ab77bf..0000000000 --- a/test/config_tests/resources/datetime/invalid_2.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: "required key not provided .*address.*" -time: - broadcast_type: TIME \ No newline at end of file diff --git a/test/config_tests/resources/datetime/valid_1.yaml b/test/config_tests/resources/datetime/valid_1.yaml deleted file mode 100644 index e7bdc7efdc..0000000000 --- a/test/config_tests/resources/datetime/valid_1.yaml +++ /dev/null @@ -1,4 +0,0 @@ -name: "Generaltime" -time: - address: "8/4/4" - broadcast_type: DATETIME \ No newline at end of file diff --git a/test/config_tests/resources/datetime/valid_2.yaml b/test/config_tests/resources/datetime/valid_2.yaml deleted file mode 100644 index 23467b6e05..0000000000 --- a/test/config_tests/resources/datetime/valid_2.yaml +++ /dev/null @@ -1,4 +0,0 @@ -name: "Generaltime" -time: - address: "8/4/4" - broadcast_type: TIME \ No newline at end of file diff --git a/test/config_tests/resources/datetime/valid_3.yaml b/test/config_tests/resources/datetime/valid_3.yaml deleted file mode 100644 index ef97290c9f..0000000000 --- a/test/config_tests/resources/datetime/valid_3.yaml +++ /dev/null @@ -1,4 +0,0 @@ -name: "Generaltime" -time: - address: "8/4/4" - broadcast_type: DATE \ No newline at end of file diff --git a/test/config_tests/resources/expose/invalid_1.yaml b/test/config_tests/resources/expose/invalid_1.yaml deleted file mode 100644 index 4161cdfb66..0000000000 --- a/test/config_tests/resources/expose/invalid_1.yaml +++ /dev/null @@ -1,2 +0,0 @@ -type: 'invalid' -address: '0/3/1' \ No newline at end of file diff --git a/test/config_tests/resources/expose/invalid_2.yaml b/test/config_tests/resources/expose/invalid_2.yaml deleted file mode 100644 index 1a13fdaf07..0000000000 --- a/test/config_tests/resources/expose/invalid_2.yaml +++ /dev/null @@ -1,2 +0,0 @@ -type: 'asgfddsagf' -address: '0/3/1' \ No newline at end of file diff --git a/test/config_tests/resources/expose/invalid_3.yaml b/test/config_tests/resources/expose/invalid_3.yaml deleted file mode 100644 index 42b8f1f11e..0000000000 --- a/test/config_tests/resources/expose/invalid_3.yaml +++ /dev/null @@ -1,2 +0,0 @@ -type: 'string' -entity_id: test.test \ No newline at end of file diff --git a/test/config_tests/resources/expose/valid_1.yaml b/test/config_tests/resources/expose/valid_1.yaml deleted file mode 100644 index 276784311d..0000000000 --- a/test/config_tests/resources/expose/valid_1.yaml +++ /dev/null @@ -1,5 +0,0 @@ -type: 'percentU8' -entity_id: 'light.office' -attribute: 'brightness' -default: 0 -address: '0/3/1' \ No newline at end of file diff --git a/test/config_tests/resources/expose/valid_2.yaml b/test/config_tests/resources/expose/valid_2.yaml deleted file mode 100644 index 84ba8dd3db..0000000000 --- a/test/config_tests/resources/expose/valid_2.yaml +++ /dev/null @@ -1,3 +0,0 @@ -type: 'binary' -entity_id: 'light.office' -address: '0/3/1' \ No newline at end of file diff --git a/test/config_tests/resources/expose/valid_3.yaml b/test/config_tests/resources/expose/valid_3.yaml deleted file mode 100644 index 2ee7e65834..0000000000 --- a/test/config_tests/resources/expose/valid_3.yaml +++ /dev/null @@ -1,2 +0,0 @@ -type: 'time' -address: '0/3/1' \ No newline at end of file diff --git a/test/config_tests/resources/fan/invalid_1.yaml b/test/config_tests/resources/fan/invalid_1.yaml deleted file mode 100644 index d14849c7b7..0000000000 --- a/test/config_tests/resources/fan/invalid_1.yaml +++ /dev/null @@ -1,5 +0,0 @@ -name: "required key.*" -friendly_name: "Fan office" -speed: - state_address: "2/8/5" - state_update: "expire 60" \ No newline at end of file diff --git a/test/config_tests/resources/fan/valid_1.yaml b/test/config_tests/resources/fan/valid_1.yaml deleted file mode 100644 index ce08620eb6..0000000000 --- a/test/config_tests/resources/fan/valid_1.yaml +++ /dev/null @@ -1,6 +0,0 @@ -name: "office" -friendly_name: "Fan office" -speed: - address: "2/7/4" - state_address: "2/8/5" - state_update: "expire 60" \ No newline at end of file diff --git a/test/config_tests/resources/light/invalid_1.yaml b/test/config_tests/resources/light/invalid_1.yaml deleted file mode 100644 index de11d5ceec..0000000000 --- a/test/config_tests/resources/light/invalid_1.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: "value must be one of .*mode.*" -friendly_name: "Office" -switch: - address: "2/1/5" - state_address: "2/4/5" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -brightness: - address: "2/5/5" - state_address: "2/5/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -rgbw: - address: "2/4/5" - state_address: "2/4/6" -color_temperature: - address: "2/5/7" - state_address: "2/5/8" - state_update: "expire 60" - mode: absoluteasd - min_kelvin: 2550 - max_kelvin: 6200 \ No newline at end of file diff --git a/test/config_tests/resources/light/invalid_2.yaml b/test/config_tests/resources/light/invalid_2.yaml deleted file mode 100644 index 2ecdf3244b..0000000000 --- a/test/config_tests/resources/light/invalid_2.yaml +++ /dev/null @@ -1,21 +0,0 @@ -name: "required key not provided .*address.*" -friendly_name: "Office" -switch: - state_address: "2/4/5" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -brightness: - address: "2/5/5" - state_address: "2/5/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -rgbw: - address: "2/4/5" - state_address: "2/4/6" -color_temperature: - address: "2/5/7" - state_address: "2/5/8" - state_update: "expire 60" - mode: relative - min_kelvin: 2550 - max_kelvin: 6200 \ No newline at end of file diff --git a/test/config_tests/resources/light/invalid_3.yaml b/test/config_tests/resources/light/invalid_3.yaml deleted file mode 100644 index 3b261fd698..0000000000 --- a/test/config_tests/resources/light/invalid_3.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: "two or more values in the same group of exclusion 'color' @ .*" -friendly_name: "Office" -switch: - address: "2/1/5" - state_address: "2/4/5" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -brightness: - address: "2/5/5" - state_address: "2/5/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -rgbw: - address: "2/4/5" - state_address: "2/4/6" -color: - address: "2/4/5" - state_address: "2/4/6" -color_temperature: - address: "2/5/7" - state_address: "2/5/8" - state_update: "expire 60" - mode: absolute - min_kelvin: 2550 - max_kelvin: 6200 \ No newline at end of file diff --git a/test/config_tests/resources/light/valid_1.yaml b/test/config_tests/resources/light/valid_1.yaml deleted file mode 100644 index a885e76b1e..0000000000 --- a/test/config_tests/resources/light/valid_1.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: "office" -friendly_name: "Office" -switch: - address: "2/1/5" - state_address: "2/4/5" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -brightness: - address: "2/5/5" - state_address: "2/5/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -rgbw: - address: "2/4/5" - state_address: "2/4/6" -color_temperature: - address: "2/5/7" - state_address: "2/5/8" - state_update: "expire 60" - mode: ABSOLUTE - min_kelvin: 2550 - max_kelvin: 6200 \ No newline at end of file diff --git a/test/config_tests/resources/light/valid_2.yaml b/test/config_tests/resources/light/valid_2.yaml deleted file mode 100644 index 67c69486d3..0000000000 --- a/test/config_tests/resources/light/valid_2.yaml +++ /dev/null @@ -1,4 +0,0 @@ -name: "office" -friendly_name: "Office" -switch: - address: "2/1/5" \ No newline at end of file diff --git a/test/config_tests/resources/light/valid_3.yaml b/test/config_tests/resources/light/valid_3.yaml deleted file mode 100644 index f2c591a631..0000000000 --- a/test/config_tests/resources/light/valid_3.yaml +++ /dev/null @@ -1,12 +0,0 @@ -name: "office" -friendly_name: "Office" -switch: - address: "2/1/5" - state_address: "2/4/5" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -brightness: - address: "2/5/5" - state_address: "2/5/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] diff --git a/test/config_tests/resources/light/valid_4.yaml b/test/config_tests/resources/light/valid_4.yaml deleted file mode 100644 index ca2b270f59..0000000000 --- a/test/config_tests/resources/light/valid_4.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: "office" -friendly_name: "Office" -switch: - address: "2/1/5" - state_address: "2/4/5" -color_temperature: - address: "2/5/7" - state_address: "2/5/8" - state_update: "expire 60" - mode: RELATIVE \ No newline at end of file diff --git a/test/config_tests/resources/light/valid_5.yaml b/test/config_tests/resources/light/valid_5.yaml deleted file mode 100644 index 6e480fff4b..0000000000 --- a/test/config_tests/resources/light/valid_5.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: "office" -friendly_name: "Office" -switch: - address: "2/1/5" - state_address: "2/4/5" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -color: - address: "2/4/5" - state_address: "2/4/6" \ No newline at end of file diff --git a/test/config_tests/resources/light/valid_rgb.yaml b/test/config_tests/resources/light/valid_rgb.yaml deleted file mode 100644 index d93861d86d..0000000000 --- a/test/config_tests/resources/light/valid_rgb.yaml +++ /dev/null @@ -1,24 +0,0 @@ -name: "office" -friendly_name: "Office" -individual_colors: - red: - switch: - address: "2/1/5" - state_address: "2/4/5" - brightness: - address: "2/5/7" - state_address: "2/5/8" - green: - switch: - address: "2/1/5" - state_address: "2/4/5" - brightness: - address: "2/5/7" - state_address: "2/5/8" - blue: - switch: - address: "2/1/5" - state_address: "2/4/5" - brightness: - address: "2/5/7" - state_address: "2/5/8" diff --git a/test/config_tests/resources/light/valid_rgbw.yaml b/test/config_tests/resources/light/valid_rgbw.yaml deleted file mode 100644 index 47d1ad430a..0000000000 --- a/test/config_tests/resources/light/valid_rgbw.yaml +++ /dev/null @@ -1,31 +0,0 @@ -name: "office" -friendly_name: "Office" -individual_colors: - white: - switch: - address: "2/1/5" - state_address: "2/4/5" - brightness: - address: "2/5/7" - state_address: "2/5/8" - red: - switch: - address: "2/1/5" - state_address: "2/4/5" - brightness: - address: "2/5/7" - state_address: "2/5/8" - green: - switch: - address: "2/1/5" - state_address: "2/4/5" - brightness: - address: "2/5/7" - state_address: "2/5/8" - blue: - switch: - address: "2/1/5" - state_address: "2/4/5" - brightness: - address: "2/5/7" - state_address: "2/5/8" diff --git a/test/config_tests/resources/light/valid_rgbw_no_switch.yaml b/test/config_tests/resources/light/valid_rgbw_no_switch.yaml deleted file mode 100644 index 8b1a79344f..0000000000 --- a/test/config_tests/resources/light/valid_rgbw_no_switch.yaml +++ /dev/null @@ -1,21 +0,0 @@ -name: "office" -friendly_name: "Office" -switch: - address: "2/1/5" -individual_colors: - white: - brightness: - address: "2/5/7" - state_address: "2/5/8" - red: - brightness: - address: "2/5/7" - state_address: "2/5/8" - green: - brightness: - address: "2/5/7" - state_address: "2/5/8" - blue: - brightness: - address: "2/5/7" - state_address: "2/5/8" diff --git a/test/config_tests/resources/notification/invalid_1.yaml b/test/config_tests/resources/notification/invalid_1.yaml deleted file mode 100644 index 61f9addb99..0000000000 --- a/test/config_tests/resources/notification/invalid_1.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: "required key not .*address.*" -address: - state_address: "2/7/2" \ No newline at end of file diff --git a/test/config_tests/resources/notification/valid_1.yaml b/test/config_tests/resources/notification/valid_1.yaml deleted file mode 100644 index eb02b88892..0000000000 --- a/test/config_tests/resources/notification/valid_1.yaml +++ /dev/null @@ -1,4 +0,0 @@ -name: notification -address: - address: "2/7/1" - state_address: "2/7/2" \ No newline at end of file diff --git a/test/config_tests/resources/notification/valid_2.yaml b/test/config_tests/resources/notification/valid_2.yaml deleted file mode 100644 index 5e831105d6..0000000000 --- a/test/config_tests/resources/notification/valid_2.yaml +++ /dev/null @@ -1,4 +0,0 @@ -name: notification -address: - address: 34 - state_address: "2/7/2" \ No newline at end of file diff --git a/test/config_tests/resources/scene/invalid_1.yaml b/test/config_tests/resources/scene/invalid_1.yaml deleted file mode 100644 index 1ff1e6fa92..0000000000 --- a/test/config_tests/resources/scene/invalid_1.yaml +++ /dev/null @@ -1,6 +0,0 @@ -name: "not a valid value for .*state_update.*" -friendly_name: "test" -scene: - address: "7/0/1" - scene_number: 23 - state_update: True \ No newline at end of file diff --git a/test/config_tests/resources/scene/invalid_2.yaml b/test/config_tests/resources/scene/invalid_2.yaml deleted file mode 100644 index b9297e4d72..0000000000 --- a/test/config_tests/resources/scene/invalid_2.yaml +++ /dev/null @@ -1,5 +0,0 @@ -name: "value must be at most .*scene_number.*" -friendly_name: "test" -scene: - address: "7/0/1" - scene_number: 65 diff --git a/test/config_tests/resources/scene/invalid_3.yaml b/test/config_tests/resources/scene/invalid_3.yaml deleted file mode 100644 index 7a7c4cf832..0000000000 --- a/test/config_tests/resources/scene/invalid_3.yaml +++ /dev/null @@ -1,5 +0,0 @@ -name: "value must be at least .*scene_number.*" -friendly_name: "test" -scene: - address: "7/0/1" - scene_number: 0 diff --git a/test/config_tests/resources/scene/valid_1.yaml b/test/config_tests/resources/scene/valid_1.yaml deleted file mode 100644 index ec227cc955..0000000000 --- a/test/config_tests/resources/scene/valid_1.yaml +++ /dev/null @@ -1,6 +0,0 @@ -name: romantic -friendly_name: "Romantic" -scene: - address: "7/0/1" - scene_number: 23 - state_update: False # default False \ No newline at end of file diff --git a/test/config_tests/resources/scene/valid_2.yaml b/test/config_tests/resources/scene/valid_2.yaml deleted file mode 100644 index 4c0d9518b0..0000000000 --- a/test/config_tests/resources/scene/valid_2.yaml +++ /dev/null @@ -1,5 +0,0 @@ -name: romantic -friendly_name: "Romantic" -scene: - address: "7/0/1" - scene_number: 64 diff --git a/test/config_tests/resources/sensor/invalid_1.yaml b/test/config_tests/resources/sensor/invalid_1.yaml deleted file mode 100644 index 5f1fbc135f..0000000000 --- a/test/config_tests/resources/sensor/invalid_1.yaml +++ /dev/null @@ -1,5 +0,0 @@ -name: "required key .*" -friendly_name: "Bathroom Valve" -sensor: - state_update: "expire 60" - type: "percent" \ No newline at end of file diff --git a/test/config_tests/resources/sensor/valid_1.yaml b/test/config_tests/resources/sensor/valid_1.yaml deleted file mode 100644 index 025ee1502b..0000000000 --- a/test/config_tests/resources/sensor/valid_1.yaml +++ /dev/null @@ -1,6 +0,0 @@ -name: "valve_bath" -friendly_name: "Bathroom Valve" -sensor: - state_address: "9/9/9" - state_update: "expire 60" - type: "percent" \ No newline at end of file diff --git a/test/config_tests/resources/sensor/valid_2.yaml b/test/config_tests/resources/sensor/valid_2.yaml deleted file mode 100644 index 266cf08ee2..0000000000 --- a/test/config_tests/resources/sensor/valid_2.yaml +++ /dev/null @@ -1,5 +0,0 @@ -name: "valve_bath" -friendly_name: "Bathroom Valve" -sensor: - state_address: "9/9/9" - type: "binary" \ No newline at end of file diff --git a/test/config_tests/resources/switch/invalid_1.yaml b/test/config_tests/resources/switch/invalid_1.yaml deleted file mode 100644 index 704557a8f7..0000000000 --- a/test/config_tests/resources/switch/invalid_1.yaml +++ /dev/null @@ -1,6 +0,0 @@ -name: "required key not provided .*address.*" -friendly_name: "Kitchen Switch" -switch: - state_address: "2/4/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] \ No newline at end of file diff --git a/test/config_tests/resources/switch/invalid_2.yaml b/test/config_tests/resources/switch/invalid_2.yaml deleted file mode 100644 index aee09480ad..0000000000 --- a/test/config_tests/resources/switch/invalid_2.yaml +++ /dev/null @@ -1,6 +0,0 @@ -name: "extra keys not allowed .*" -friendly_name: "Kitchen Switch" -switch: - address: "2/2/2" - state_address: "2/4/6" - passive_state_adsdresses: ["8/8/8"] \ No newline at end of file diff --git a/test/config_tests/resources/switch/valid_1.yaml b/test/config_tests/resources/switch/valid_1.yaml deleted file mode 100644 index d3b26faadc..0000000000 --- a/test/config_tests/resources/switch/valid_1.yaml +++ /dev/null @@ -1,7 +0,0 @@ -name: "valid" -friendly_name: "Kitchen Switch" -switch: - address: 23 - state_address: "2/4" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] \ No newline at end of file diff --git a/test/config_tests/resources/switch/valid_2.yaml b/test/config_tests/resources/switch/valid_2.yaml deleted file mode 100644 index 2a568908bd..0000000000 --- a/test/config_tests/resources/switch/valid_2.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: "valid" -switch: - address: 23 \ No newline at end of file diff --git a/test/config_tests/resources/weather/invalid_1.yaml b/test/config_tests/resources/weather/invalid_1.yaml deleted file mode 100644 index 70cc9450c3..0000000000 --- a/test/config_tests/resources/weather/invalid_1.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: "required key not provided .*temperature.*" -friendly_name: "Home" -brightness_south: - state_address: "7/0/1" - state_update: "expire 60" -brightness_west: - state_address: "7/0/2" - state_update: "expire 60" -brightness_east: - state_address: "7/0/3" - state_update: "expire 60" -brightness_north: - state_address: "7/0/11" - state_update: "expire 60" -rain_alarm: - state_address: "7/0/11" - state_update: "expire 60" -frost_alarm: - state_address: "7/0/4" - state_update: "expire 60" -wind_alarm: - state_address: "7/0/5" - state_update: "expire 60" -wind_speed: - state_address: "7/0/6" - state_update: "expire 60" -wind_bearing: - state_address: "7/0/7" - state_update: "expire 60" -day_night: - state_address: "7/0/8" - state_update: "expire 60" -air_pressure: - state_address: "7/0/9" - state_update: "expire 60" -humidity: - state_address: "7/0/10" - state_update: "expire 60" -create_sensors: True \ No newline at end of file diff --git a/test/config_tests/resources/weather/invalid_2.yaml b/test/config_tests/resources/weather/invalid_2.yaml deleted file mode 100644 index 08bbe74a62..0000000000 --- a/test/config_tests/resources/weather/invalid_2.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: "required key not provided .*state_address.*" -friendly_name: "Home" -temperature: - state_address: "7/3/3" -brightness_south: - state_address: "7/0/1" - state_update: "expire 60" -brightness_west: - state_address: "7/0/2" - state_update: "expire 60" -brightness_east: - state_address: "7/0/3" - state_update: "expire 60" -brightness_north: - state_address: "7/0/11" - state_update: "expire 60" -rain_alarm: - state_update: "expire 60" -frost_alarm: - state_address: "7/0/4" - state_update: "expire 60" -wind_alarm: - state_address: "7/0/5" - state_update: "expire 60" -wind_speed: - state_address: "7/0/6" - state_update: "expire 60" -wind_bearing: - state_address: "7/0/7" - state_update: "expire 60" -day_night: - state_address: "7/0/8" - state_update: "expire 60" -air_pressure: - state_address: "7/0/9" - state_update: "expire 60" -humidity: - state_address: "7/0/10" - state_update: "expire 60" -create_sensors: True \ No newline at end of file diff --git a/test/config_tests/resources/weather/valid_1.yaml b/test/config_tests/resources/weather/valid_1.yaml deleted file mode 100644 index 5f4468695c..0000000000 --- a/test/config_tests/resources/weather/valid_1.yaml +++ /dev/null @@ -1,42 +0,0 @@ -name: home -friendly_name: "Home" -temperature: - state_address: "7/0/0" - state_update: "expire 60" -brightness_south: - state_address: "7/0/1" - state_update: "expire 60" -brightness_west: - state_address: "7/0/2" - state_update: "expire 60" -brightness_east: - state_address: "7/0/3" - state_update: "expire 60" -brightness_north: - state_address: "7/0/11" - state_update: "expire 60" -rain_alarm: - state_address: "7/0/11" - state_update: "expire 60" -frost_alarm: - state_address: "7/0/4" - state_update: "expire 60" -wind_alarm: - state_address: "7/0/5" - state_update: "expire 60" -wind_speed: - state_address: "7/0/6" - state_update: "expire 60" -wind_bearing: - state_address: "7/0/7" - state_update: "expire 60" -day_night: - state_address: "7/0/8" - state_update: "expire 60" -air_pressure: - state_address: "7/0/9" - state_update: "expire 60" -humidity: - state_address: "7/0/10" - state_update: "expire 60" -create_sensors: True \ No newline at end of file diff --git a/test/config_tests/resources/weather/valid_2.yaml b/test/config_tests/resources/weather/valid_2.yaml deleted file mode 100644 index 5d9f989685..0000000000 --- a/test/config_tests/resources/weather/valid_2.yaml +++ /dev/null @@ -1,6 +0,0 @@ -name: home -friendly_name: "Home" -temperature: - state_address: "7/0/0" - state_update: "expire 60" -create_sensors: "off" \ No newline at end of file diff --git a/test/config_tests/resources/xknx/invalid_1.yaml b/test/config_tests/resources/xknx/invalid_1.yaml deleted file mode 100644 index 404663f67b..0000000000 --- a/test/config_tests/resources/xknx/invalid_1.yaml +++ /dev/null @@ -1,197 +0,0 @@ -version: "2" -own_address: "15.15.249" -rate_limit: 18 -log_directory: "/tmp/" -fire_event: True -fire_event_filter: ["1/0/*", "6/2,3,4-6/*"] -multicast_group: '224.1.2.3' -multicast_port: 1337 -connection: # optional - type: fdgsdfgsdfg -binary_sensor: - - name: "livingroom_switch1" - friendly_name: "" - address: - state_address: "1/2/7" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - context_timeout: 1 - device_class: 'light' - reset_after: 3000 # ms - ignore_internal_state: False -switch: - - name: "kitchen" - friendly_name: "Kitchen Switch" - switch: - address: "2/4/5" - state_address: "2/4/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -light: - - name: "office" - friendly_name: "Office" - switch: - address: "2/1/5" - state_address: "2/4/5" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - brightness: - address: "2/5/5" - state_address: "2/5/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - rgbw: - address: "2/4/5" - state_address: "2/4/6" - color_temperature: - address: "2/5/7" - state_address: "2/5/8" - state_update: "expire 60" - mode: absolute - min_kelvin: 2550 - max_kelvin: 6200 -fan: - - name: "office" - friendly_name: "Fan office" - speed: - address: "2/7/4" - state_address: "2/8/5" - state_update: "expire 60" -cover: - - name: "livingroom_tv" - friendly_name: "Livingroom TV" - long_movement: - address: "3/3/3" - invert: True - short_movement: - address: "3/3/4" - invert: True - stop_address: "3/3/5" - position: - address: "3/3/6" - state_address: "3/3/7" - state_update: "expire 60" - invert: True - angle: - address: "3/3/8" - state_address: "3/3/9" - invert: True - travelling_time_up: 50 - travelling_time_down: 30 -climate: - - name: "bathroom" - friendly_name: "Bathroom" - target_temperature: - address: "4/0/0" - state_address: "4/0/1" - state_update: "expire 60" - min: -7 - max: 30 - setpoint_shift: - address: "4/0/2" - state_address: "4/0/3" - mode: DPT6010 - temperature_step: 0.1 - min: -6 - max: 6 - operation_mode: - address: "4/0/4" - state_address: "4/0/5" - binary_operation_mode: - frost_protection_address: "4/0/6" - comfort_address: "4/0/7" - night_address: "4/0/8" - standby_address: "5/0/0" - controller_status: - address: "4/0/9" - state_address: "4/0/10" - controller_mode: - address: "4/0/11" - state_address: "4/0/12" - heat_cool: - address: "4/0/13" - state_address: "4/0/14" - operation_modes: - - "Heat" - - "Cool" - on_off: - address: "4/0/15" - state_address: "4/0/16" - invert: False -weather: - - name: home - friendly_name: "Home" - temperature: - state_address: "7/0/0" - state_update: "expire 60" - brightness_south: - state_address: "7/0/1" - state_update: "expire 60" - brightness_west: - state_address: "7/0/2" - state_update: "expire 60" - brightness_east: - state_address: "7/0/3" - state_update: "expire 60" - brightness_north: - state_address: "7/0/11" - state_update: "expire 60" - rain_alarm: - state_address: "7/0/11" - state_update: "expire 60" - frost_alarm: - state_address: "7/0/4" - state_update: "expire 60" - wind_alarm: - state_address: "7/0/5" - state_update: "expire 60" - wind_speed: - state_address: "7/0/6" - state_update: "expire 60" - wind_bearing: - state_address: "7/0/7" - state_update: "expire 60" - day_night: - state_address: "7/0/8" - state_update: "expire 60" - air_pressure: - state_address: "7/0/9" - state_update: "expire 60" - humidity: - state_address: "7/0/10" - state_update: "expire 60" - create_sensors: True -datetime: - - name: "Generaltime" - time: - address: "8/4/4" - broadcast_type: DATETIME -notification: - - name: notification - address: - address: "2/7/1" - state_address: "2/7/2" -scene: - - name: romantic - friendly_name: "Romantic" - scene: - address: "7/0/1" - scene_number: 23 - state_update: False # default False -expose_sensor: - - type: 'temperature' - entity_id: 'sensor.owm_temperature' - address: '0/0/3' - - type: 'percentU8' - entity_id: 'light.office' - attribute: 'brightness' - default: 0 - address: '0/3/1' -sensor: - - name: "valve_bath" - friendly_name: "Bathroom Valve" - sensor: - state_address: "9/9/9" - state_update: "expire 60" - type: "percent" - diff --git a/test/config_tests/resources/xknx/invalid_2.yaml b/test/config_tests/resources/xknx/invalid_2.yaml deleted file mode 100644 index a74bbb190f..0000000000 --- a/test/config_tests/resources/xknx/invalid_2.yaml +++ /dev/null @@ -1,195 +0,0 @@ -version: "2" -own_address: "15.15.249" -rate_limit: 18 -log_directory: "/tmp/" -fire_event: True -fire_event_filter: ["1/0/*", "6/2,3,4-6/*"] -multicast_group: '224.1.2.3' -multicast_port: 133744 -binary_sensor: - - name: "livingroom_switch1" - friendly_name: "" - address: - state_address: "1/2/7" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - context_timeout: 1 - device_class: 'light' - reset_after: 3000 # ms - ignore_internal_state: False -switch: - - name: "kitchen" - friendly_name: "Kitchen Switch" - switch: - address: "2/4/5" - state_address: "2/4/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -light: - - name: "office" - friendly_name: "Office" - switch: - address: "2/1/5" - state_address: "2/4/5" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - brightness: - address: "2/5/5" - state_address: "2/5/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - rgbw: - address: "2/4/5" - state_address: "2/4/6" - color_temperature: - address: "2/5/7" - state_address: "2/5/8" - state_update: "expire 60" - mode: absolute - min_kelvin: 2550 - max_kelvin: 6200 -fan: - - name: "office" - friendly_name: "Fan office" - speed: - address: "2/7/4" - state_address: "2/8/5" - state_update: "expire 60" -cover: - - name: "livingroom_tv" - friendly_name: "Livingroom TV" - long_movement: - address: "3/3/3" - invert: True - short_movement: - address: "3/3/4" - invert: True - stop_address: "3/3/5" - position: - address: "3/3/6" - state_address: "3/3/7" - state_update: "expire 60" - invert: True - angle: - address: "3/3/8" - state_address: "3/3/9" - invert: True - travelling_time_up: 50 - travelling_time_down: 30 -climate: - - name: "bathroom" - friendly_name: "Bathroom" - target_temperature: - address: "4/0/0" - state_address: "4/0/1" - state_update: "expire 60" - min: -7 - max: 30 - setpoint_shift: - address: "4/0/2" - state_address: "4/0/3" - mode: DPT6010 - temperature_step: 0.1 - min: -6 - max: 6 - operation_mode: - address: "4/0/4" - state_address: "4/0/5" - binary_operation_mode: - frost_protection_address: "4/0/6" - comfort_address: "4/0/7" - night_address: "4/0/8" - standby_address: "5/0/0" - controller_status: - address: "4/0/9" - state_address: "4/0/10" - controller_mode: - address: "4/0/11" - state_address: "4/0/12" - heat_cool: - address: "4/0/13" - state_address: "4/0/14" - operation_modes: - - "Heat" - - "Cool" - on_off: - address: "4/0/15" - state_address: "4/0/16" - invert: False -weather: - - name: home - friendly_name: "Home" - temperature: - state_address: "7/0/0" - state_update: "expire 60" - brightness_south: - state_address: "7/0/1" - state_update: "expire 60" - brightness_west: - state_address: "7/0/2" - state_update: "expire 60" - brightness_east: - state_address: "7/0/3" - state_update: "expire 60" - brightness_north: - state_address: "7/0/11" - state_update: "expire 60" - rain_alarm: - state_address: "7/0/11" - state_update: "expire 60" - frost_alarm: - state_address: "7/0/4" - state_update: "expire 60" - wind_alarm: - state_address: "7/0/5" - state_update: "expire 60" - wind_speed: - state_address: "7/0/6" - state_update: "expire 60" - wind_bearing: - state_address: "7/0/7" - state_update: "expire 60" - day_night: - state_address: "7/0/8" - state_update: "expire 60" - air_pressure: - state_address: "7/0/9" - state_update: "expire 60" - humidity: - state_address: "7/0/10" - state_update: "expire 60" - create_sensors: True -datetime: - - name: "Generaltime" - time: - address: "8/4/4" - broadcast_type: DATETIME -notification: - - name: notification - address: - address: "2/7/1" - state_address: "2/7/2" -scene: - - name: romantic - friendly_name: "Romantic" - scene: - address: "7/0/1" - scene_number: 23 - state_update: False # default False -expose_sensor: - - type: 'temperature' - entity_id: 'sensor.owm_temperature' - address: '0/0/3' - - type: 'percentU8' - entity_id: 'light.office' - attribute: 'brightness' - default: 0 - address: '0/3/1' -sensor: - - name: "valve_bath" - friendly_name: "Bathroom Valve" - sensor: - state_address: "9/9/9" - state_update: "expire 60" - type: "percent" - diff --git a/test/config_tests/resources/xknx/invalid_3.yaml b/test/config_tests/resources/xknx/invalid_3.yaml deleted file mode 100644 index bf1ce14d3b..0000000000 --- a/test/config_tests/resources/xknx/invalid_3.yaml +++ /dev/null @@ -1,194 +0,0 @@ -version: "2" -own_address: "15.15.249" -rate_limit: 18 -log_directory: "/tmp/" -fire_event: True -fire_event_filter: ["1/0/*", "6/2,3,4-6/*"] -multicast_group: '224.1.2.3' -multicast_port: 1337 -binary_sensor: - - name: "livingroom_switch1" - friendly_name: "" - address: - state_address: "1/2/7" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - context_timeout: 1 - device_class: 'light' - reset_after: 3000 # ms - ignore_internal_state: False -switch: - - name: "kitchen" - friendly_name: "Kitchen Switch" - switch: - address: "2/4/5" - state_address: "2/4/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -light: - - friendly_name: "Office" # name missing - switch: - address: "2/1/5" - state_address: "2/4/5" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - brightness: - address: "2/5/5" - state_address: "2/5/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - rgbw: - address: "2/4/5" - state_address: "2/4/6" - color_temperature: - address: "2/5/7" - state_address: "2/5/8" - state_update: "expire 60" - mode: absolute - min_kelvin: 2550 - max_kelvin: 6200 -fan: - - name: "office" - friendly_name: "Fan office" - speed: - address: "2/7/4" - state_address: "2/8/5" - state_update: "expire 60" -cover: - - name: "livingroom_tv" - friendly_name: "Livingroom TV" - long_movement: - address: "3/3/3" - invert: True - short_movement: - address: "3/3/4" - invert: True - stop_address: "3/3/5" - position: - address: "3/3/6" - state_address: "3/3/7" - state_update: "expire 60" - invert: True - angle: - address: "3/3/8" - state_address: "3/3/9" - invert: True - travelling_time_up: 50 - travelling_time_down: 30 -climate: - - name: "bathroom" - friendly_name: "Bathroom" - target_temperature: - address: "4/0/0" - state_address: "4/0/1" - state_update: "expire 60" - min: -7 - max: 30 - setpoint_shift: - address: "4/0/2" - state_address: "4/0/3" - mode: DPT6010 - temperature_step: 0.1 - min: -6 - max: 6 - operation_mode: - address: "4/0/4" - state_address: "4/0/5" - binary_operation_mode: - frost_protection_address: "4/0/6" - comfort_address: "4/0/7" - night_address: "4/0/8" - standby_address: "5/0/0" - controller_status: - address: "4/0/9" - state_address: "4/0/10" - controller_mode: - address: "4/0/11" - state_address: "4/0/12" - heat_cool: - address: "4/0/13" - state_address: "4/0/14" - operation_modes: - - "Heat" - - "Cool" - on_off: - address: "4/0/15" - state_address: "4/0/16" - invert: False -weather: - - name: home - friendly_name: "Home" - temperature: - state_address: "7/0/0" - state_update: "expire 60" - brightness_south: - state_address: "7/0/1" - state_update: "expire 60" - brightness_west: - state_address: "7/0/2" - state_update: "expire 60" - brightness_east: - state_address: "7/0/3" - state_update: "expire 60" - brightness_north: - state_address: "7/0/11" - state_update: "expire 60" - rain_alarm: - state_address: "7/0/11" - state_update: "expire 60" - frost_alarm: - state_address: "7/0/4" - state_update: "expire 60" - wind_alarm: - state_address: "7/0/5" - state_update: "expire 60" - wind_speed: - state_address: "7/0/6" - state_update: "expire 60" - wind_bearing: - state_address: "7/0/7" - state_update: "expire 60" - day_night: - state_address: "7/0/8" - state_update: "expire 60" - air_pressure: - state_address: "7/0/9" - state_update: "expire 60" - humidity: - state_address: "7/0/10" - state_update: "expire 60" - create_sensors: True -datetime: - - name: "Generaltime" - time: - address: "8/4/4" - broadcast_type: DATETIME -notification: - - name: notification - address: - address: "2/7/1" - state_address: "2/7/2" -scene: - - name: romantic - friendly_name: "Romantic" - scene: - address: "7/0/1" - scene_number: 23 - state_update: False # default False -expose_sensor: - - type: 'temperature' - entity_id: 'sensor.owm_temperature' - address: '0/0/3' - - type: 'percentU8' - entity_id: 'light.office' - attribute: 'brightness' - default: 0 - address: '0/3/1' -sensor: - - name: "valve_bath" - friendly_name: "Bathroom Valve" - sensor: - state_address: "9/9/9" - state_update: "expire 60" - type: "percent" - diff --git a/test/config_tests/resources/xknx/invalid_4.yaml b/test/config_tests/resources/xknx/invalid_4.yaml deleted file mode 100644 index b46d51ad2f..0000000000 --- a/test/config_tests/resources/xknx/invalid_4.yaml +++ /dev/null @@ -1,8 +0,0 @@ -version: "2" -own_address: "15.15.s" -rate_limit: 18 -log_directory: "/tmp/" -fire_event: True -fire_event_filter: ["1/0/*", "6/2,3,4-6/*"] -multicast_group: '224.1.2.3' -multicast_port: 1337 \ No newline at end of file diff --git a/test/config_tests/resources/xknx/invalid_5.yaml b/test/config_tests/resources/xknx/invalid_5.yaml deleted file mode 100644 index 3cdee55f75..0000000000 --- a/test/config_tests/resources/xknx/invalid_5.yaml +++ /dev/null @@ -1,7 +0,0 @@ -version: "2" -rate_limit: 18 -log_directory: "/tmp/not-existent-dir-23423432" -fire_event: True -fire_event_filter: ["1/0/*", "6/2,3,4-6/*"] -multicast_group: '224.1.2.3' -multicast_port: 1337 \ No newline at end of file diff --git a/test/config_tests/resources/xknx/invalid_6.yaml b/test/config_tests/resources/xknx/invalid_6.yaml deleted file mode 100644 index 9c355acd2b..0000000000 --- a/test/config_tests/resources/xknx/invalid_6.yaml +++ /dev/null @@ -1,7 +0,0 @@ -version: "2" -rate_limit: 18 -log_directory: -fire_event: True -fire_event_filter: ["1/0/*", "6/2,3,4-6/*"] -multicast_group: '224.1.2.3' -multicast_port: 1337 \ No newline at end of file diff --git a/test/config_tests/resources/xknx/invalid_7.yaml b/test/config_tests/resources/xknx/invalid_7.yaml deleted file mode 100644 index 30d82e7337..0000000000 --- a/test/config_tests/resources/xknx/invalid_7.yaml +++ /dev/null @@ -1,7 +0,0 @@ -version: "2" -rate_limit: 18 -log_directory: "/root" -fire_event: True -fire_event_filter: ["1/0/*", "6/2,3,4-6/*"] -multicast_group: '224.1.2.3' -multicast_port: 1337 \ No newline at end of file diff --git a/test/config_tests/resources/xknx/valid_1.yaml b/test/config_tests/resources/xknx/valid_1.yaml deleted file mode 100644 index 6348d6543f..0000000000 --- a/test/config_tests/resources/xknx/valid_1.yaml +++ /dev/null @@ -1,200 +0,0 @@ -version: "2" -own_address: "15.15.249" -rate_limit: 18 -log_directory: "/tmp/" -fire_event: True -fire_event_filter: ["1/0/*", "6/2,3,4-6/*"] -multicast_group: '224.1.2.3' -multicast_port: 1337 -connection: # optional - type: TUNNELING # or routing|auto - local_ip: "192.168.0.201" - host: "192.168.0.202" - port: 1337 -binary_sensor: - - name: "livingroom_switch1" - friendly_name: "" - address: - state_address: "1/2/7" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - context_timeout: 1 - device_class: 'light' - reset_after: 3000 # ms - ignore_internal_state: False -switch: - - name: "kitchen" - friendly_name: "Kitchen Switch" - switch: - address: "2/4/5" - state_address: "2/4/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -light: - - name: "office" - friendly_name: "Office" - switch: - address: "2/1/5" - state_address: "2/4/5" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - brightness: - address: "2/5/5" - state_address: "2/5/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - rgbw: - address: "2/4/5" - state_address: "2/4/6" - color_temperature: - address: "2/5/7" - state_address: "2/5/8" - state_update: "expire 60" - mode: ABSOLUTE - min_kelvin: 2550 - max_kelvin: 6200 -fan: - - name: "office" - friendly_name: "Fan office" - speed: - address: "2/7/4" - state_address: "2/8/5" - state_update: "expire 60" -cover: - - name: "livingroom_tv" - friendly_name: "Livingroom TV" - long_movement: - address: "3/3/3" - invert: True - short_movement: - address: "3/3/4" - invert: True - stop_address: "3/3/5" - position: - address: "3/3/6" - state_address: "3/3/7" - state_update: "expire 60" - invert: True - angle: - address: "3/3/8" - state_address: "3/3/9" - invert: True - travelling_time_up: 50 - travelling_time_down: 30 -climate: - - name: "bathroom" - friendly_name: "Bathroom" - target_temperature: - address: "4/0/0" - state_address: "4/0/1" - state_update: "expire 60" - min: -7 - max: 30 - setpoint_shift: - address: "4/0/2" - state_address: "4/0/3" - mode: DPT6010 - temperature_step: 0.1 - min: -6 - max: 6 - operation_mode: - address: "4/0/4" - state_address: "4/0/5" - binary_operation_mode: - frost_protection_address: "4/0/6" - comfort_address: "4/0/7" - night_address: "4/0/8" - standby_address: "5/0/0" - controller_status: - address: "4/0/9" - state_address: "4/0/10" - controller_mode: - address: "4/0/11" - state_address: "4/0/12" - heat_cool: - address: "4/0/13" - state_address: "4/0/14" - operation_modes: - - "Heat" - - "Cool" - on_off: - address: "4/0/15" - state_address: "4/0/16" - invert: False -weather: - - name: home - friendly_name: "Home" - temperature: - state_address: "7/0/0" - state_update: "expire 60" - brightness_south: - state_address: "7/0/1" - state_update: "expire 60" - brightness_west: - state_address: "7/0/2" - state_update: "expire 60" - brightness_east: - state_address: "7/0/3" - state_update: "expire 60" - brightness_north: - state_address: "7/0/11" - state_update: "expire 60" - rain_alarm: - state_address: "7/0/11" - state_update: "expire 60" - frost_alarm: - state_address: "7/0/4" - state_update: "expire 60" - wind_alarm: - state_address: "7/0/5" - state_update: "expire 60" - wind_speed: - state_address: "7/0/6" - state_update: "expire 60" - wind_bearing: - state_address: "7/0/7" - state_update: "expire 60" - day_night: - state_address: "7/0/8" - state_update: "expire 60" - air_pressure: - state_address: "7/0/9" - state_update: "expire 60" - humidity: - state_address: "7/0/10" - state_update: "expire 60" - create_sensors: True -datetime: - - name: "Generaltime" - time: - address: "8/4/4" - broadcast_type: DATETIME -notification: - - name: notification - address: - address: "2/7/1" - state_address: "2/7/2" -scene: - - name: romantic - friendly_name: "Romantic" - scene: - address: "7/0/1" - scene_number: 23 - state_update: False # default False -expose_sensor: - - type: 'temperature' - entity_id: 'sensor.owm_temperature' - address: '0/0/3' - - type: 'percentU8' - entity_id: 'light.office' - attribute: 'brightness' - default: 0 - address: '0/3/1' -sensor: - - name: "valve_bath" - friendly_name: "Bathroom Valve" - sensor: - state_address: "9/9/9" - state_update: "expire 60" - type: "percent" - diff --git a/test/config_tests/resources/xknx/valid_2.yaml b/test/config_tests/resources/xknx/valid_2.yaml deleted file mode 100644 index 8251c18304..0000000000 --- a/test/config_tests/resources/xknx/valid_2.yaml +++ /dev/null @@ -1,197 +0,0 @@ -version: "2" -own_address: "15.15.249" -rate_limit: 18 -log_directory: "/tmp/" -fire_event: True -fire_event_filter: ["1/0/*", "6/2,3,4-6/*"] -multicast_group: '224.1.2.3' -multicast_port: 1337 -connection: # optional - type: AUTO -binary_sensor: - - name: "livingroom_switch1" - friendly_name: "" - address: - state_address: "1/2/7" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - context_timeout: 1 - device_class: 'light' - reset_after: 3000 # ms - ignore_internal_state: False -switch: - - name: "kitchen" - friendly_name: "Kitchen Switch" - switch: - address: "2/4/5" - state_address: "2/4/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -light: - - name: "office" - friendly_name: "Office" - switch: - address: "2/1/5" - state_address: "2/4/5" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - brightness: - address: "2/5/5" - state_address: "2/5/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - rgbw: - address: "2/4/5" - state_address: "2/4/6" - color_temperature: - address: "2/5/7" - state_address: "2/5/8" - state_update: "expire 60" - mode: ABSOLUTE - min_kelvin: 2550 - max_kelvin: 6200 -fan: - - name: "office" - friendly_name: "Fan office" - speed: - address: "2/7/4" - state_address: "2/8/5" - state_update: "expire 60" -cover: - - name: "livingroom_tv" - friendly_name: "Livingroom TV" - long_movement: - address: "3/3/3" - invert: True - short_movement: - address: "3/3/4" - invert: True - stop_address: "3/3/5" - position: - address: "3/3/6" - state_address: "3/3/7" - state_update: "expire 60" - invert: True - angle: - address: "3/3/8" - state_address: "3/3/9" - invert: True - travelling_time_up: 50 - travelling_time_down: 30 -climate: - - name: "bathroom" - friendly_name: "Bathroom" - target_temperature: - address: "4/0/0" - state_address: "4/0/1" - state_update: "expire 60" - min: -7 - max: 30 - setpoint_shift: - address: "4/0/2" - state_address: "4/0/3" - mode: DPT6010 - temperature_step: 0.1 - min: -6 - max: 6 - operation_mode: - address: "4/0/4" - state_address: "4/0/5" - binary_operation_mode: - frost_protection_address: "4/0/6" - comfort_address: "4/0/7" - night_address: "4/0/8" - standby_address: "5/0/0" - controller_status: - address: "4/0/9" - state_address: "4/0/10" - controller_mode: - address: "4/0/11" - state_address: "4/0/12" - heat_cool: - address: "4/0/13" - state_address: "4/0/14" - operation_modes: - - "Heat" - - "Cool" - on_off: - address: "4/0/15" - state_address: "4/0/16" - invert: False -weather: - - name: home - friendly_name: "Home" - temperature: - state_address: "7/0/0" - state_update: "expire 60" - brightness_south: - state_address: "7/0/1" - state_update: "expire 60" - brightness_west: - state_address: "7/0/2" - state_update: "expire 60" - brightness_east: - state_address: "7/0/3" - state_update: "expire 60" - brightness_north: - state_address: "7/0/11" - state_update: "expire 60" - rain_alarm: - state_address: "7/0/11" - state_update: "expire 60" - frost_alarm: - state_address: "7/0/4" - state_update: "expire 60" - wind_alarm: - state_address: "7/0/5" - state_update: "expire 60" - wind_speed: - state_address: "7/0/6" - state_update: "expire 60" - wind_bearing: - state_address: "7/0/7" - state_update: "expire 60" - day_night: - state_address: "7/0/8" - state_update: "expire 60" - air_pressure: - state_address: "7/0/9" - state_update: "expire 60" - humidity: - state_address: "7/0/10" - state_update: "expire 60" - create_sensors: True -datetime: - - name: "Generaltime" - time: - address: "8/4/4" - broadcast_type: DATETIME -notification: - - name: notification - address: - address: "2/7/1" - state_address: "2/7/2" -scene: - - name: romantic - friendly_name: "Romantic" - scene: - address: "7/0/1" - scene_number: 23 - state_update: False # default False -expose_sensor: - - type: 'temperature' - entity_id: 'sensor.owm_temperature' - address: '0/0/3' - - type: 'percentU8' - entity_id: 'light.office' - attribute: 'brightness' - default: 0 - address: '0/3/1' -sensor: - - name: "valve_bath" - friendly_name: "Bathroom Valve" - sensor: - state_address: "9/9/9" - state_update: "expire 60" - type: "percent" - diff --git a/test/config_tests/resources/xknx/valid_3.yaml b/test/config_tests/resources/xknx/valid_3.yaml deleted file mode 100644 index d100cf604d..0000000000 --- a/test/config_tests/resources/xknx/valid_3.yaml +++ /dev/null @@ -1,202 +0,0 @@ -version: "2" -own_address: "15.15.249" -rate_limit: 18 -log_directory: "/tmp/" -fire_event: True -fire_event_filter: ["1/0/*", "6/2,3,4-6/*"] -multicast_group: '224.1.2.3' -multicast_port: 1337 -binary_sensor: - - name: "livingroom_switch1" - friendly_name: "" - address: - state_address: "1/2/7" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - context_timeout: 1 - device_class: 'light' - reset_after: 3000 # ms - ignore_internal_state: False -switch: - - name: "kitchen" - friendly_name: "Kitchen Switch" - switch: - address: "2/4/5" - state_address: "2/4/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - - name: "asdadad" - friendly_name: "Kitchen Switch" - switch: - address: "2/4/5" - state_address: "2/4/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] -light: - - name: "office" - friendly_name: "Office" - switch: - address: "2/1/5" - state_address: "2/4/5" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - brightness: - address: "2/5/5" - state_address: "2/5/6" - state_update: "expire 60" - passive_state_addresses: ["8/8/8"] - rgbw: - address: "2/4/5" - state_address: "2/4/6" - color_temperature: - address: "2/5/7" - state_address: "2/5/8" - state_update: "expire 60" - mode: ABSOLUTE - min_kelvin: 2550 - max_kelvin: 6200 -fan: - - name: "office" - friendly_name: "Fan office" - speed: - address: "2/7/4" - state_address: "2/8/5" - state_update: "expire 60" -cover: - - name: "livingroom_tv" - friendly_name: "Livingroom TV" - long_movement: - address: "3/3/3" - invert: True - short_movement: - address: "3/3/4" - invert: True - stop_address: "3/3/5" - position: - address: "3/3/6" - state_address: "3/3/7" - state_update: "expire 60" - invert: True - angle: - address: "3/3/8" - state_address: "3/3/9" - invert: True - travelling_time_up: 50 - travelling_time_down: 30 -climate: - - name: "bathroom" - friendly_name: "Bathroom" - target_temperature: - address: "4/0/0" - state_address: "4/0/1" - state_update: "expire 60" - min: -7 - max: 30 - setpoint_shift: - address: "4/0/2" - state_address: "4/0/3" - mode: DPT6010 - temperature_step: 0.1 - min: -6 - max: 6 - operation_mode: - address: "4/0/4" - state_address: "4/0/5" - binary_operation_mode: - frost_protection_address: "4/0/6" - comfort_address: "4/0/7" - night_address: "4/0/8" - standby_address: "5/0/0" - controller_status: - address: "4/0/9" - state_address: "4/0/10" - controller_mode: - address: "4/0/11" - state_address: "4/0/12" - heat_cool: - address: "4/0/13" - state_address: "4/0/14" - operation_modes: - - "Heat" - - "Cool" - on_off: - address: "4/0/15" - state_address: "4/0/16" - invert: False -weather: - - name: home - friendly_name: "Home" - temperature: - state_address: "7/0/0" - state_update: "expire 60" - brightness_south: - state_address: "7/0/1" - state_update: "expire 60" - brightness_west: - state_address: "7/0/2" - state_update: "expire 60" - brightness_east: - state_address: "7/0/3" - state_update: "expire 60" - brightness_north: - state_address: "7/0/11" - state_update: "expire 60" - rain_alarm: - state_address: "7/0/11" - state_update: "expire 60" - frost_alarm: - state_address: "7/0/4" - state_update: "expire 60" - wind_alarm: - state_address: "7/0/5" - state_update: "expire 60" - wind_speed: - state_address: "7/0/6" - state_update: "expire 60" - wind_bearing: - state_address: "7/0/7" - state_update: "expire 60" - day_night: - state_address: "7/0/8" - state_update: "expire 60" - air_pressure: - state_address: "7/0/9" - state_update: "expire 60" - humidity: - state_address: "7/0/10" - state_update: "expire 60" - create_sensors: True -datetime: - - name: "Generaltime" - time: - address: "8/4/4" - broadcast_type: DATETIME -notification: - - name: notification - address: - address: "2/7/1" - state_address: "2/7/2" -scene: - - name: romantic - friendly_name: "Romantic" - scene: - address: "7/0/1" - scene_number: 23 - state_update: False # default False -expose_sensor: - - type: 'temperature' - entity_id: 'sensor.owm_temperature' - address: '0/0/3' - - type: 'percentU8' - entity_id: 'light.office' - attribute: 'brightness' - default: 0 - address: '0/3/1' -sensor: - - name: "valve_bath" - friendly_name: "Bathroom Valve" - sensor: - state_address: "9/9/9" - state_update: "expire 60" - type: "percent" - diff --git a/test/config_tests/resources/xknx/valid_4.yaml b/test/config_tests/resources/xknx/valid_4.yaml deleted file mode 100644 index 7249499284..0000000000 --- a/test/config_tests/resources/xknx/valid_4.yaml +++ /dev/null @@ -1,2 +0,0 @@ -version: "2" - diff --git a/test/config_tests/schema_test.py b/test/config_tests/schema_test.py deleted file mode 100644 index 2c289fe8ab..0000000000 --- a/test/config_tests/schema_test.py +++ /dev/null @@ -1,93 +0,0 @@ -"""Unit test for schema validation.""" -import glob -import os -from typing import List -import unittest - -from pytest import raises -import voluptuous as vol -from xknx.config import ( - BinarySensorSchema, - ClimateSchema, - ConnectionSchema, - CoverSchema, - DateTimeSchema, - ExposeSchema, - FanSchema, - LightSchema, - NotificationSchema, - SceneSchema, - SensorSchema, - SwitchSchema, - WeatherSchema, - XKNXSchema, -) -import yaml - -TEST_CONFIG_PATH = "test/config_tests/resources" - -CONFIG_MAPPING = [ - ("binary_sensor", BinarySensorSchema.SCHEMA), - ("climate", ClimateSchema.SCHEMA), - ("connection", ConnectionSchema.SCHEMA), - ("cover", CoverSchema.SCHEMA), - ("datetime", DateTimeSchema.SCHEMA), - ("expose", ExposeSchema.SCHEMA), - ("fan", FanSchema.SCHEMA), - ("light", LightSchema.SCHEMA), - ("notification", NotificationSchema.SCHEMA), - ("scene", SceneSchema.SCHEMA), - ("sensor", SensorSchema.SCHEMA), - ("switch", SwitchSchema.SCHEMA), - ("weather", WeatherSchema.SCHEMA), - ("xknx", XKNXSchema.SCHEMA), -] - - -# pylint: disable=too-many-public-methods,invalid-name -class TestSchema(unittest.TestCase): - """Test class for Schema logic.""" - - # - # Get files in directory - # - @staticmethod - def get_files(directory, valid=False) -> List: - file_pattern = "invalid" if not valid else "valid" - - _list: List = glob.glob( - f"{TEST_CONFIG_PATH}{os.sep}{directory}{os.sep}{file_pattern}*.yaml" - ) - result = [] - for file in _list: - with open(file) as filehandle: - config = yaml.safe_load(filehandle) - matcher = config.get("name", ".*") - result.append((file, config, matcher)) - - return result - - # - # Test all valid schemas in the resources directory. - # - def test_schema_valid(self): - """Test valid schemas from config file.""" - - for entry, schema in CONFIG_MAPPING: - _list = TestSchema.get_files(entry, True) - for file, config, matcher in _list: - # print(f"Testing {file} from {entry}.") - self.assertIsNotNone(schema(config)) - - # - # Test all invalid schemas in the resources directory - # - def test_schema_invalid(self): - """Test invalid schemas from config file.""" - - for entry, schema in CONFIG_MAPPING: - _list = TestSchema.get_files(entry) - for file, config, matches in _list: - with raises(vol.Invalid, match=matches): - print(f"Testing {file} from {entry}.") - schema(config) diff --git a/test/config_tests/yaml_loader_test.py b/test/config_tests/yaml_loader_test.py deleted file mode 100644 index 33cafdb84d..0000000000 --- a/test/config_tests/yaml_loader_test.py +++ /dev/null @@ -1,105 +0,0 @@ -import io -import os -from unittest.mock import patch - -import pytest -from xknx.config.yaml_loader import SafeLineLoader, load_yaml -from xknx.exceptions import XKNXException -import yaml - -from test.util import patch_yaml_files - - -def test_simple_list(): - """Test simple list.""" - conf = "config:\n - simple\n - list" - with io.StringIO(conf) as file: - doc = yaml.load(file, Loader=SafeLineLoader) - assert doc["config"] == ["simple", "list"] - - -def test_simple_dict(): - """Test simple dict.""" - conf = "key: value" - with io.StringIO(conf) as file: - doc = yaml.load(file, Loader=SafeLineLoader) - assert doc["key"] == "value" - - -@patch("xknx.config.yaml_loader.open", create=True) -def test_load_yaml_encoding_error(mock_open): - """Test raising a UnicodeDecodeError.""" - mock_open.side_effect = UnicodeDecodeError("", b"", 1, 0, "") - with pytest.raises(XKNXException): - load_yaml("test") - - -@patch("xknx.config.yaml_loader.open", create=True) -def test_load_yaml_loading_error(mock_open): - """Test raising a YAMLError.""" - mock_open.side_effect = yaml.error.YAMLError - with pytest.raises(XKNXException): - load_yaml("test") - - -@patch("xknx.config.yaml_loader.os.walk") -def test_include_dir_list(mock_walk): - """Test include dir list yaml.""" - mock_walk.return_value = [["/test", [], ["two.yaml", "one.yaml"]]] - - with patch_yaml_files({"/test/one.yaml": "one", "/test/two.yaml": "two"}): - conf = "key: !include_dir_list /test" - with io.StringIO(conf) as file: - doc = yaml.load(file, Loader=SafeLineLoader) - assert doc["key"] == sorted(["one", "two"]) - - -def test_environment_variable(): - """Test config file with environment variable.""" - os.environ["XKNX_HOST"] = "192.168.30.32" - conf = "host: !env_var XKNX_HOST" - with io.StringIO(conf) as file: - doc = yaml.load(file, Loader=SafeLineLoader) - assert doc["host"] == "192.168.30.32" - del os.environ["XKNX_HOST"] - - -def test_environment_variable_default(): - """Test config file with default value for environment variable.""" - conf = "host: !env_var XKNX_HOST 127.0.0.1" - with io.StringIO(conf) as file: - doc = yaml.load(file, Loader=SafeLineLoader) - assert doc["host"] == "127.0.0.1" - - -def test_invalid_environment_variable(): - """Test config file with no environment variable sat.""" - conf = "host: !env_var XKNX_HOST" - with pytest.raises(XKNXException): - with io.StringIO(conf) as file: - yaml.load(file, Loader=SafeLineLoader) - - -def test_include_yaml(): - """Test include yaml.""" - with patch_yaml_files({"test.yaml": "value"}): - conf = "key: !include test.yaml" - with io.StringIO(conf) as file: - doc = yaml.load(file, Loader=SafeLineLoader) - assert doc["key"] == "value" - - with patch_yaml_files({"test.yaml": None}): - conf = "key: !include test.yaml" - with io.StringIO(conf) as file: - doc = yaml.load(file, Loader=SafeLineLoader) - assert doc["key"] == {} - - -def test_include_yaml_error(): - """Test include yaml error.""" - with patch_yaml_files({"test.yaml": "value"}): - conf = "key: !include test2.yaml" - with io.StringIO(conf) as file: - with pytest.raises(XKNXException): - doc = yaml.load(file, Loader=SafeLineLoader) - assert doc["key"] == "value" diff --git a/xknx/config/__init__.py b/xknx/config/__init__.py index acc699862b..8e2b142827 100644 --- a/xknx/config/__init__.py +++ b/xknx/config/__init__.py @@ -2,38 +2,8 @@ # flake8: noqa from .config import Config from .config_v1 import ConfigV1 -from .schema import ( - BinarySensorSchema, - ClimateSchema, - ConnectionSchema, - CoverSchema, - DateTimeSchema, - ExposeSchema, - FanSchema, - LightSchema, - NotificationSchema, - SceneSchema, - SensorSchema, - SwitchSchema, - WeatherSchema, - XKNXSchema, -) __all__ = [ "Config", "ConfigV1", - "BinarySensorSchema", - "ClimateSchema", - "ConnectionSchema", - "CoverSchema", - "DateTimeSchema", - "ExposeSchema", - "FanSchema", - "LightSchema", - "NotificationSchema", - "SceneSchema", - "SensorSchema", - "SwitchSchema", - "WeatherSchema", - "XKNXSchema", ] diff --git a/xknx/config/config.py b/xknx/config/config.py index c3d149bb97..bdef7715fd 100644 --- a/xknx/config/config.py +++ b/xknx/config/config.py @@ -4,12 +4,12 @@ * it will parse the given file * and add the found devices to the devies vector of XKNX. """ -from enum import Enum import logging -from typing import TYPE_CHECKING, Any, Dict +from typing import TYPE_CHECKING + +import yaml from .config_v1 import ConfigV1 -from .yaml_loader import load_yaml if TYPE_CHECKING: from xknx.xknx import XKNX @@ -17,13 +17,6 @@ logger = logging.getLogger("xknx.log") -class Version(Enum): - """The used xknx.yaml structure version.""" - - VERSION_1 = 1 - VERSION_2 = 2 - - class Config: """Class for parsing xknx.yaml.""" @@ -34,21 +27,9 @@ def __init__(self, xknx: "XKNX") -> None: def read(self, file: str = "xknx.yaml") -> None: """Read config.""" logger.debug("Reading %s", file) - doc = load_yaml(file) - assert isinstance(doc, dict) - self.parse(doc) - - @staticmethod - def parse_version(doc: Dict[str, Any]) -> Version: - """Parse the version of the xknx.yaml.""" - if "version" in doc: - return Version(doc["version"]) - return Version.VERSION_1 - - def parse(self, doc: Dict[str, Any]) -> None: - """Parse the config from the YAML.""" - version = Config.parse_version(doc) - if version is Version.VERSION_1: - ConfigV1(xknx=self.xknx).parse(doc) - elif version is Version.VERSION_2: - raise NotImplementedError("Version 2 not yet implemented.") + try: + with open(file) as filehandle: + doc = yaml.safe_load(filehandle) + ConfigV1(xknx=self.xknx).parse(doc) + except FileNotFoundError as ex: + logger.error("Error while reading %s: %s", file, ex) diff --git a/xknx/config/config_validation.py b/xknx/config/config_validation.py deleted file mode 100644 index 3d33e1ac9f..0000000000 --- a/xknx/config/config_validation.py +++ /dev/null @@ -1,117 +0,0 @@ -"""Helper functions for config validation.""" -from enum import Enum -from numbers import Number -import os -import re -from typing import Any, List, Type, TypeVar, Union - -import voluptuous as vol -from xknx.dpt import DPTBase -from xknx.telegram import GroupAddress, IndividualAddress - -# pylint: disable=invalid-name -# typing typevar -T = TypeVar("T") - - -positive_int = vol.All(vol.Coerce(int), vol.Range(min=0)) -port = vol.All(vol.Coerce(int), vol.Range(min=1, max=65535)) - - -def string(value: Any) -> str: - """Coerce value to string, except for None.""" - if value is None: - raise vol.Invalid("string value is None") - if isinstance(value, (list, dict)): - raise vol.Invalid("value should be a string") - - return str(value) - - -def boolean(value: Any) -> bool: - """Validate and coerce a boolean value.""" - if isinstance(value, bool): - return value - if isinstance(value, str): - value = value.lower().strip() - if value in ("1", "true", "yes", "on", "enable"): - return True - if value in ("0", "false", "no", "off", "disable"): - return False - elif isinstance(value, Number): - # type ignore: https://github.com/python/mypy/issues/3186 - return value != 0 # type: ignore - raise vol.Invalid(f"invalid boolean value {value}") - - -def ensure_list(value: Union[T, List[T], None]) -> List[T]: - """Wrap value in list if it is not one.""" - if value is None: - return [] - return value if isinstance(value, list) else [value] - - -def ensure_group_address(value: str) -> str: - """Ensure value is a valid KNX group address.""" - value = str(value) - if value.isdigit() and 0 <= int(value) <= GroupAddress.MAX_FREE: - return value - - if not GroupAddress.ADDRESS_RE.match(value): - raise vol.Invalid(f"{value} is not a valid group address") - - return value - - -def ensure_individual_address(value: str) -> str: - """Ensure value is a valid individual address.""" - value = str(value) - if not IndividualAddress.ADDRESS_RE.match(value): - raise vol.Invalid(f"{value} is not a valid individual address") - - return value - - -def isdir(value: Any) -> str: - """Validate that the value is an existing dir.""" - if value is None: - raise vol.Invalid("not a directory") - dir_in = os.path.expanduser(str(value)) - - if not os.path.isdir(dir_in): - raise vol.Invalid("not a directory") - if not os.access(dir_in, os.W_OK): - raise vol.Invalid("directory not writable") - return dir_in - - -def enum(value: Type[Enum]) -> vol.All: - """Create validator for specified enum.""" - return vol.All(vol.In(value.__members__), value.__getitem__) - - -def sensor_value_type(value: T) -> T: - """Validate sensor type.""" - if DPTBase.parse_transcoder(value): - return value - - if value.lower() in ["binary", "time", "datetime", "date"]: - return str(value) - - raise vol.Invalid(f"invalid value type {value}") - - -VALID_ENTITY_ID = re.compile(r"^(?!.+__)(?!_)[\da-z_]+(? bool: - """Test if an entity ID is a valid format. - - Format: . where both are slugs. - """ - return VALID_ENTITY_ID.match(entity_id) is not None - - -def match_all(value: T) -> T: - """Validate that matches all values.""" - return value diff --git a/xknx/config/entries/__init__.py b/xknx/config/entries/__init__.py deleted file mode 100644 index 1f9fc3ad20..0000000000 --- a/xknx/config/entries/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Support for dedicated config entries.""" diff --git a/xknx/config/objects.py b/xknx/config/objects.py deleted file mode 100644 index cae957740e..0000000000 --- a/xknx/config/objects.py +++ /dev/null @@ -1,9 +0,0 @@ -"""Custom yaml object types.""" - - -class NodeListClass(list): - """Wrapper class to be able to add attributes on a list.""" - - -class NodeStrClass(str): - """Wrapper class to be able to add attributes on a string.""" diff --git a/xknx/config/schema.py b/xknx/config/schema.py deleted file mode 100644 index 904c971af6..0000000000 --- a/xknx/config/schema.py +++ /dev/null @@ -1,683 +0,0 @@ -"""Config validation.""" -from enum import Enum - -import voluptuous as vol - -from ..devices.climate import SetpointShiftMode -from ..devices.light import ColorTempModes -from ..io import DEFAULT_MCAST_GRP, DEFAULT_MCAST_PORT -from ..remote_value.remote_value_datetime import DateTimeType -from .config_validation import ( - boolean, - ensure_group_address, - ensure_individual_address, - ensure_list, - enum, - isdir, - match_all, - port, - positive_int, - sensor_value_type, - string, - valid_entity_id, -) - -CONF_STATE_UPDATE = "state_update" -CONF_ADDRESS = "address" -CONF_STATE_ADDRESS = "state_address" -CONF_SWITCH = "switch" - - -class ConnectionType(Enum): - """Connection type to use.""" - - TUNNELING = "tunneling" - ROUTING = "routing" - AUTO = "auto" - - -class RemoteValueSchema: - """Schema validation for remote value configuration.""" - - CONF_PASSIVE_GROUP_ADDRESSES = "passive_state_addresses" - CONF_INVERT = "invert" - - DEFAULT_STATE_UPDATE = "expire 60" - - SCHEMA = vol.Schema( - { - vol.Optional(CONF_ADDRESS): ensure_group_address, - vol.Optional(CONF_STATE_ADDRESS): ensure_group_address, - vol.Optional(CONF_STATE_UPDATE, default=DEFAULT_STATE_UPDATE): vol.Any( - vol.All(vol.Coerce(int), vol.Range(min=2, max=1440)), - boolean, - string, - ), - vol.Optional(CONF_PASSIVE_GROUP_ADDRESSES): ensure_list, - } - ) - - SCHEMA_INVERTABLE = SCHEMA.extend( - {vol.Optional(CONF_INVERT, default=False): boolean} - ) - - -class BaseDeviceSchema: - """Schema validation for all devices.""" - - CONF_NAME = "name" - CONF_FRIENDLY_NAME = "friendly_name" - - SCHEMA = vol.Schema( - { - vol.Required(CONF_NAME): string, - vol.Optional(CONF_FRIENDLY_NAME): string, - } - ) - - -class ConnectionSchema: - """Voluptuous schema for KNX connection.""" - - CONF_TYPE = "type" - CONF_LOCAL_IP = "local_ip" - CONF_HOST = "host" - CONF_PORT = "port" - - SCHEMA = vol.Schema( - { - vol.Required(CONF_TYPE): enum(ConnectionType), - vol.Optional(CONF_PORT, default=DEFAULT_MCAST_PORT): port, - vol.Optional(CONF_LOCAL_IP): string, - vol.Optional(CONF_HOST): string, - } - ) - - -## -# Device schemas -## - - -class SwitchSchema: - """Schema validation for switches.""" - - CONF_RESET_AFTER = "reset_after" - - SCHEMA = BaseDeviceSchema.SCHEMA.extend( - { - vol.Required(CONF_SWITCH): RemoteValueSchema.SCHEMA.extend( - {vol.Required(CONF_ADDRESS): ensure_group_address} - ), - vol.Optional(CONF_RESET_AFTER): float, - } - ) - - -class BinarySensorSchema: - """Schema validation for binary sensors.""" - - CONF_IGNORE_INTERNAL_STATE = "ignore_internal_state" - CONF_CONTEXT_TIMEOUT = "context_timeout" - CONF_RESET_AFTER = "reset_after" - CONF_DEVICE_CLASS = "device_class" - - SCHEMA = BaseDeviceSchema.SCHEMA.extend( - { - vol.Required(CONF_ADDRESS): RemoteValueSchema.SCHEMA.extend( - { - vol.Remove(CONF_ADDRESS): ensure_group_address, - vol.Required(CONF_STATE_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_IGNORE_INTERNAL_STATE, default=True): boolean, - vol.Optional(CONF_CONTEXT_TIMEOUT, default=1.0): vol.All( - vol.Coerce(float), vol.Range(min=0, max=10) - ), - vol.Optional(CONF_DEVICE_CLASS): string, - vol.Optional(CONF_RESET_AFTER): positive_int, - } - ) - - -class LightSchema: - """Voluptuous schema for KNX lights.""" - - CONF_BRIGHTNESS = "brightness" - CONF_RGBW = "rgbw" - CONF_COLOR_TEMPERATURE = "color_temperature" - CONF_COLOR = "color" - CONF_INDIVIDUAL_COLORS = "individual_colors" - - CONF_COLOR_TEMP_MODE = "mode" - CONF_MIN_KELVIN = "min_kelvin" - CONF_MAX_KELVIN = "max_kelvin" - - CONF_RED = "red" - CONF_GREEN = "green" - CONF_BLUE = "blue" - CONF_WHITE = "white" - - DEFAULT_COLOR_TEMP_MODE = "absolute" - DEFAULT_MIN_KELVIN = 2700 # 370 mireds - DEFAULT_MAX_KELVIN = 6000 # 166 mireds - - COLOR_SCHEMA = vol.Schema( - { - vol.Optional(CONF_SWITCH): RemoteValueSchema.SCHEMA, - vol.Required(CONF_BRIGHTNESS): RemoteValueSchema.SCHEMA.extend( - {vol.Required(CONF_ADDRESS): ensure_group_address} - ), - } - ) - - SCHEMA = vol.All( - BaseDeviceSchema.SCHEMA.extend( - { - vol.Optional(CONF_SWITCH): RemoteValueSchema.SCHEMA.extend( - {vol.Required(CONF_ADDRESS): ensure_group_address} - ), - vol.Optional(CONF_BRIGHTNESS): RemoteValueSchema.SCHEMA.extend( - {vol.Required(CONF_ADDRESS): ensure_group_address} - ), - vol.Exclusive(CONF_RGBW, "color"): RemoteValueSchema.SCHEMA.extend( - {vol.Required(CONF_ADDRESS): ensure_group_address} - ), - vol.Exclusive(CONF_COLOR, "color"): RemoteValueSchema.SCHEMA.extend( - {vol.Required(CONF_ADDRESS): ensure_group_address} - ), - vol.Exclusive(CONF_INDIVIDUAL_COLORS, "color"): { - vol.Inclusive(CONF_RED, "colors"): COLOR_SCHEMA, - vol.Inclusive(CONF_GREEN, "colors"): COLOR_SCHEMA, - vol.Inclusive(CONF_BLUE, "colors"): COLOR_SCHEMA, - vol.Optional(CONF_WHITE): COLOR_SCHEMA, - }, - vol.Optional(CONF_COLOR_TEMPERATURE): RemoteValueSchema.SCHEMA.extend( - { - vol.Required(CONF_ADDRESS): ensure_group_address, - vol.Optional( - CONF_COLOR_TEMP_MODE, default=DEFAULT_COLOR_TEMP_MODE - ): enum(ColorTempModes), - vol.Optional( - CONF_MIN_KELVIN, default=DEFAULT_MIN_KELVIN - ): vol.All(vol.Coerce(int), vol.Range(min=1)), - vol.Optional( - CONF_MAX_KELVIN, default=DEFAULT_MAX_KELVIN - ): vol.All(vol.Coerce(int), vol.Range(min=1)), - } - ), - }, - ), - vol.Any( - vol.Schema( - { - vol.Required(CONF_SWITCH): RemoteValueSchema.SCHEMA.extend( - {vol.Required(CONF_ADDRESS): object} - ) - }, - extra=vol.ALLOW_EXTRA, - ), - vol.Schema( - { - vol.Required(CONF_INDIVIDUAL_COLORS): { - vol.Required(CONF_RED): { - vol.Required(CONF_SWITCH): { - vol.Required(CONF_ADDRESS): object - } - }, - vol.Required(CONF_GREEN): { - vol.Required(CONF_SWITCH): { - vol.Required(CONF_ADDRESS): object - } - }, - vol.Required(CONF_BLUE): { - vol.Required(CONF_SWITCH): { - vol.Required(CONF_ADDRESS): object - } - }, - }, - }, - extra=vol.ALLOW_EXTRA, - ), - ), - ) - - -class FanSchema: - """Voluptuous schema for KNX fans.""" - - CONF_SPEED = "speed" - - SCHEMA = BaseDeviceSchema.SCHEMA.extend( - { - vol.Required(CONF_SPEED): RemoteValueSchema.SCHEMA.extend( - { - vol.Required(CONF_ADDRESS): ensure_group_address, - } - ), - } - ) - - -class CoverSchema: - """Voluptuous schema for KNX covers.""" - - CONF_LONG_MOVEMENT = "long_movement" - CONF_SHORT_MOVEMENT = "short_movement" - CONF_STOP_ADDRESS = "stop_address" - CONF_POSITION = "position" - CONF_ANGLE = "angle" - CONF_TRAVELLING_TIME_DOWN = "travelling_time_down" - CONF_TRAVELLING_TIME_UP = "travelling_time_up" - - DEFAULT_TRAVEL_TIME = 25 - - SCHEMA = BaseDeviceSchema.SCHEMA.extend( - { - vol.Required( - CONF_LONG_MOVEMENT - ): RemoteValueSchema.SCHEMA_INVERTABLE.extend( - { - vol.Required(CONF_ADDRESS): ensure_group_address, - vol.Remove(CONF_STATE_ADDRESS): ensure_group_address, - } - ), - vol.Optional( - CONF_SHORT_MOVEMENT - ): RemoteValueSchema.SCHEMA_INVERTABLE.extend( - { - vol.Required(CONF_ADDRESS): ensure_group_address, - vol.Remove(CONF_STATE_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_STOP_ADDRESS): ensure_group_address, - vol.Optional(CONF_POSITION): RemoteValueSchema.SCHEMA_INVERTABLE.extend( - {vol.Required(CONF_ADDRESS): ensure_group_address} - ), - vol.Optional(CONF_ANGLE): RemoteValueSchema.SCHEMA_INVERTABLE.extend( - {vol.Required(CONF_ADDRESS): ensure_group_address} - ), - vol.Optional( - CONF_TRAVELLING_TIME_DOWN, default=DEFAULT_TRAVEL_TIME - ): positive_int, - vol.Optional( - CONF_TRAVELLING_TIME_UP, default=DEFAULT_TRAVEL_TIME - ): positive_int, - } - ) - - -class ClimateSchema: - """Voluptuous schema for KNX climates.""" - - CONF_TARGET_TEMPERATURE = "target_temperature" - CONF_SETPOINT_SHIFT = "setpoint_shift" - CONF_SETPOINT_SHIFT_MODE = "mode" - CONF_TEMPERATURE_STEP = "temperature_step" - CONF_MIN_TEMP = "min" - CONF_MAX_TEMP = "max" - CONF_OPERATION_MODE = "operation_mode" - CONF_BINARY_OPERATION_MODE = "binary_operation_mode" - CONF_CONTROLLER_STATUS = "controller_status" - CONF_CONTROLLER_MODE = "controller_mode" - CONF_HEAT_COOL = "heat_cool" - CONF_OPERATION_MODES = "operation_modes" - CONF_ON_OFF = "on_off" - CONF_CREATE_TEMPERATURE_SENSORS = "create_temperature_sensors" - - CONF_FROST_PROTECTION_ADDRESS = "frost_protection_address" - CONF_NIGHT_ADDRESS = "night_address" - CONF_COMFORT_ADDRESS = "comfort_address" - CONF_STANDBY_ADDRESS = "standby_address" - - # Map KNX operation modes to HA modes. This list might not be complete. - OPERATION_MODES = { - # Map DPT 20.105 HVAC control modes - "Auto": None, - "Heat": None, - "Cool": None, - "Off": None, - "Fan only": None, - "Dry": None, - } - - PRESET_MODES = { - # Map DPT 20.102 HVAC operating modes to HA presets - "Frost Protection": None, - "Night": None, - "Standby": None, - "Comfort": None, - } - - DEFAULT_SETPOINT_SHIFT_MODE = "DPT6010" - DEFAULT_SETPOINT_SHIFT_MAX = 6 - DEFAULT_SETPOINT_SHIFT_MIN = -6 - DEFAULT_TEMPERATURE_STEP = 0.1 - - SCHEMA = BaseDeviceSchema.SCHEMA.extend( - { - vol.Required(CONF_TARGET_TEMPERATURE): RemoteValueSchema.SCHEMA.extend( - { - vol.Required(CONF_STATE_ADDRESS): ensure_group_address, - vol.Optional(CONF_MIN_TEMP): vol.Coerce(float), - vol.Optional(CONF_MAX_TEMP): vol.Coerce(float), - } - ), - vol.Optional(CONF_SETPOINT_SHIFT): RemoteValueSchema.SCHEMA.extend( - { - vol.Required(CONF_ADDRESS): ensure_group_address, - vol.Required(CONF_STATE_ADDRESS): ensure_group_address, - vol.Optional( - CONF_SETPOINT_SHIFT_MODE, default=DEFAULT_SETPOINT_SHIFT_MODE - ): enum(SetpointShiftMode), - vol.Optional( - CONF_MIN_TEMP, default=DEFAULT_SETPOINT_SHIFT_MIN - ): vol.All(int, vol.Range(min=-32, max=0)), - vol.Optional( - CONF_MAX_TEMP, default=DEFAULT_SETPOINT_SHIFT_MAX - ): vol.All(int, vol.Range(min=0, max=32)), - vol.Optional( - CONF_TEMPERATURE_STEP, default=DEFAULT_TEMPERATURE_STEP - ): vol.All(float, vol.Range(min=0, max=2)), - } - ), - vol.Optional(CONF_OPERATION_MODE): RemoteValueSchema.SCHEMA.extend( - { - vol.Required(CONF_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_CONTROLLER_STATUS): RemoteValueSchema.SCHEMA.extend( - { - vol.Required(CONF_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_CONTROLLER_MODE): RemoteValueSchema.SCHEMA.extend( - { - vol.Required(CONF_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_HEAT_COOL): RemoteValueSchema.SCHEMA_INVERTABLE.extend( - { - vol.Required(CONF_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_ON_OFF): RemoteValueSchema.SCHEMA_INVERTABLE.extend( - { - vol.Required(CONF_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_BINARY_OPERATION_MODE): vol.Schema( - { - vol.Optional(CONF_FROST_PROTECTION_ADDRESS): ensure_group_address, - vol.Optional(CONF_COMFORT_ADDRESS): ensure_group_address, - vol.Optional(CONF_NIGHT_ADDRESS): ensure_group_address, - vol.Optional(CONF_STANDBY_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_OPERATION_MODES): vol.All( - ensure_list, [vol.In({**OPERATION_MODES, **PRESET_MODES})] - ), - vol.Optional(CONF_CREATE_TEMPERATURE_SENSORS, default=False): boolean, - } - ) - - -class WeatherSchema: - """Voluptuous schema for KNX weather devices.""" - - CONF_TEMPERATURE = "temperature" - CONF_BRIGHTNESS_SOUTH = "brightness_south" - CONF_BRIGHTNESS_NORTH = "brightness_north" - CONF_BRIGHTNESS_EAST = "brightness_east" - CONF_BRIGHTNESS_WEST = "brightness_west" - CONF_RAIN_ALARM = "rain_alarm" - CONF_WIND_ALARM = "wind_alarm" - CONF_FROST_ALARM = "frost_alarm" - CONF_WIND_SPEED = "wind_speed" - CONF_WIND_BEARING = "wind_bearing" - CONF_DAY_NIGHT = "day_night" - CONF_AIR_PRESSURE = "air_pressure" - CONF_HUMIDITY = "humidity" - CONF_CREATE_SENSORS = "create_sensors" - - SCHEMA = BaseDeviceSchema.SCHEMA.extend( - { - vol.Required(CONF_TEMPERATURE): RemoteValueSchema.SCHEMA.extend( - { - vol.Remove(CONF_ADDRESS): ensure_group_address, - vol.Required(CONF_STATE_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_BRIGHTNESS_SOUTH): RemoteValueSchema.SCHEMA.extend( - { - vol.Remove(CONF_ADDRESS): ensure_group_address, - vol.Required(CONF_STATE_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_BRIGHTNESS_NORTH): RemoteValueSchema.SCHEMA.extend( - { - vol.Remove(CONF_ADDRESS): ensure_group_address, - vol.Required(CONF_STATE_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_BRIGHTNESS_EAST): RemoteValueSchema.SCHEMA.extend( - { - vol.Remove(CONF_ADDRESS): ensure_group_address, - vol.Required(CONF_STATE_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_BRIGHTNESS_WEST): RemoteValueSchema.SCHEMA.extend( - { - vol.Remove(CONF_ADDRESS): ensure_group_address, - vol.Required(CONF_STATE_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_RAIN_ALARM): RemoteValueSchema.SCHEMA.extend( - { - vol.Remove(CONF_ADDRESS): ensure_group_address, - vol.Required(CONF_STATE_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_WIND_ALARM): RemoteValueSchema.SCHEMA.extend( - { - vol.Remove(CONF_ADDRESS): ensure_group_address, - vol.Required(CONF_STATE_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_FROST_ALARM): RemoteValueSchema.SCHEMA.extend( - { - vol.Remove(CONF_ADDRESS): ensure_group_address, - vol.Required(CONF_STATE_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_WIND_SPEED): RemoteValueSchema.SCHEMA.extend( - { - vol.Remove(CONF_ADDRESS): ensure_group_address, - vol.Required(CONF_STATE_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_WIND_BEARING): RemoteValueSchema.SCHEMA.extend( - { - vol.Remove(CONF_ADDRESS): ensure_group_address, - vol.Required(CONF_STATE_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_DAY_NIGHT): RemoteValueSchema.SCHEMA.extend( - { - vol.Remove(CONF_ADDRESS): ensure_group_address, - vol.Required(CONF_STATE_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_AIR_PRESSURE): RemoteValueSchema.SCHEMA.extend( - { - vol.Remove(CONF_ADDRESS): ensure_group_address, - vol.Required(CONF_STATE_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_HUMIDITY): RemoteValueSchema.SCHEMA.extend( - { - vol.Remove(CONF_ADDRESS): ensure_group_address, - vol.Required(CONF_STATE_ADDRESS): ensure_group_address, - } - ), - vol.Optional(CONF_CREATE_SENSORS, default=False): boolean, - } - ) - - -class DateTimeSchema: - """Voluptuous schema for KNX date time devices.""" - - CONF_TIME = "time" - CONF_BROADCAST_TYPE = "broadcast_type" - - SCHEMA = BaseDeviceSchema.SCHEMA.extend( - { - vol.Required(CONF_TIME): RemoteValueSchema.SCHEMA.extend( - { - vol.Required(CONF_ADDRESS): ensure_group_address, - vol.Remove(CONF_STATE_ADDRESS): ensure_group_address, - vol.Optional(CONF_BROADCAST_TYPE, default=DateTimeType.TIME): enum( - DateTimeType - ), - } - ), - } - ) - - -class SceneSchema: - """Voluptuous schema for KNX scenes.""" - - CONF_SCENE = "scene" - CONF_SCENE_NUMBER = "scene_number" - - SCHEMA = BaseDeviceSchema.SCHEMA.extend( - { - vol.Required(CONF_SCENE): RemoteValueSchema.SCHEMA.extend( - { - vol.Required(CONF_ADDRESS): ensure_group_address, - vol.Remove(CONF_STATE_ADDRESS): ensure_group_address, - vol.Optional(CONF_STATE_UPDATE, default=False): False, - vol.Required(CONF_SCENE_NUMBER): vol.All( - vol.Coerce(int), vol.Range(min=1, max=64) - ), - } - ), - } - ) - - -class NotificationSchema: - """Voluptuous schema for KNX notifications.""" - - SCHEMA = BaseDeviceSchema.SCHEMA.extend( - { - vol.Required(CONF_ADDRESS): RemoteValueSchema.SCHEMA.extend( - { - vol.Required(CONF_ADDRESS): ensure_group_address, - } - ), - } - ) - - -class ExposeSchema: - """Voluptuous schema for KNX exposures.""" - - CONF_TYPE = "type" - CONF_ENTITY_ID = "entity_id" # HA only - CONF_ATTRIBUTE = "attribute" - CONF_DEFAULT = "default" - CONF_NAME = "name" - - SCHEMA = BaseDeviceSchema.SCHEMA.extend( - { - vol.Remove(CONF_NAME): False, - vol.Required(CONF_ADDRESS): ensure_group_address, - vol.Required(CONF_TYPE): sensor_value_type, - vol.Optional(CONF_DEFAULT): match_all, - vol.Optional(CONF_ATTRIBUTE): string, - vol.Optional(CONF_ENTITY_ID): valid_entity_id, - } - ) - - -class SensorSchema: - """Voluptuous schema for KNX sensors.""" - - CONF_TYPE = "type" - CONF_SENSOR = "sensor" - - SCHEMA = BaseDeviceSchema.SCHEMA.extend( - { - vol.Required(CONF_SENSOR): RemoteValueSchema.SCHEMA.extend( - { - vol.Required(CONF_STATE_ADDRESS): ensure_group_address, - vol.Remove(CONF_ADDRESS): ensure_group_address, - vol.Required(CONF_TYPE): sensor_value_type, - } - ), - } - ) - - -class XKNXSchema: - """Voloptuous schema for XKNX config.""" - - CONF_OWN_ADDRESS = "own_address" - CONF_RATE_LIMIT = "rate_limit" - CONF_VERSION = "version" - CONF_LOG_DIRECTORY = "log_directory" - CONF_FIRE_EVENT = "fire_event" - CONF_FIRE_EVENT_FILTER = "fire_event_filter" - CONF_MULTICAST_GROUP = "multicast_group" - CONF_MULTICAST_PORT = "multicast_port" - - CONF_CONNECTION = "connection" - CONF_BINARY_SENSOR = "binary_sensor" - CONF_SWITCH = "switch" - CONF_LIGHT = "light" - CONF_FAN = "fan" - CONF_COVER = "cover" - CONF_CLIMATE = "climate" - CONF_WEATHER = "weather" - CONF_DATETIME = "datetime" - CONF_NOTIFICATION = "notification" - CONF_SCENE = "scene" - CONF_EXPOSE = "expose_sensor" - CONF_SENSOR = "sensor" - - SCHEMA = vol.Schema( - { - vol.Optional(CONF_RATE_LIMIT, default=20): vol.All( - vol.Coerce(int), vol.Range(min=0, max=100) - ), - vol.Optional(CONF_VERSION, default=2): string, - vol.Optional(CONF_OWN_ADDRESS): ensure_individual_address, - vol.Optional(CONF_LOG_DIRECTORY): isdir, - vol.Inclusive(CONF_FIRE_EVENT, "fire_ev"): boolean, - vol.Inclusive(CONF_FIRE_EVENT_FILTER, "fire_ev"): vol.All( - ensure_list, [string] - ), - vol.Optional(CONF_MULTICAST_GROUP, default=DEFAULT_MCAST_GRP): string, - vol.Optional(CONF_MULTICAST_PORT, default=DEFAULT_MCAST_PORT): port, - vol.Optional(CONF_CONNECTION): ConnectionSchema.SCHEMA, - vol.Optional(CONF_BINARY_SENSOR): vol.All( - ensure_list, [BinarySensorSchema.SCHEMA] - ), - vol.Optional(CONF_SWITCH): vol.All(ensure_list, [SwitchSchema.SCHEMA]), - vol.Optional(CONF_LIGHT): vol.All(ensure_list, [LightSchema.SCHEMA]), - vol.Optional(CONF_FAN): vol.All(ensure_list, [FanSchema.SCHEMA]), - vol.Optional(CONF_COVER): vol.All(ensure_list, [CoverSchema.SCHEMA]), - vol.Optional(CONF_CLIMATE): vol.All(ensure_list, [ClimateSchema.SCHEMA]), - vol.Optional(CONF_WEATHER): vol.All(ensure_list, [WeatherSchema.SCHEMA]), - vol.Optional(CONF_DATETIME): vol.All(ensure_list, [DateTimeSchema.SCHEMA]), - vol.Optional(CONF_NOTIFICATION): vol.All( - ensure_list, [NotificationSchema.SCHEMA] - ), - vol.Optional(CONF_SCENE): vol.All(ensure_list, [SceneSchema.SCHEMA]), - vol.Optional(CONF_EXPOSE): vol.All(ensure_list, [ExposeSchema.SCHEMA]), - vol.Optional(CONF_SENSOR): vol.All(ensure_list, [SensorSchema.SCHEMA]), - } - ) diff --git a/xknx/config/yaml_loader.py b/xknx/config/yaml_loader.py deleted file mode 100644 index ef298f23e8..0000000000 --- a/xknx/config/yaml_loader.py +++ /dev/null @@ -1,116 +0,0 @@ -"""Custom YAML loader.""" -from collections import OrderedDict -import fnmatch -import logging -import os -from typing import Dict, Iterator, List, TypeVar, Union - -from xknx.config.objects import NodeListClass, NodeStrClass -from xknx.exceptions import XKNXException -import yaml - -logger = logging.getLogger("xknx.log") - -JSON_TYPE = Union[List, Dict, str] # pylint: disable=invalid-name -DICT_T = TypeVar("DICT_T", bound=Dict) # pylint: disable=invalid-name - - -class SafeLineLoader(yaml.SafeLoader): - """Loader class that keeps track of line numbers.""" - - def compose_node(self, parent: yaml.nodes.Node, index: int) -> yaml.nodes.Node: - """Annotate a node with the first line it was seen.""" - last_line: int = self.line - node: yaml.nodes.Node = super().compose_node(parent, index) - node.__line__ = last_line + 1 # type: ignore - return node - - -def _add_reference(obj, loader: SafeLineLoader, node: yaml.nodes.Node): # type: ignore - """Add file reference information to an object.""" - if isinstance(obj, list): - obj = NodeListClass(obj) - if isinstance(obj, str): - obj = NodeStrClass(obj) - setattr(obj, "__config_file__", loader.name) - setattr(obj, "__line__", node.start_mark.line) - return obj - - -def load_yaml(fname: str) -> JSON_TYPE: - """Load a YAML file.""" - try: - with open(fname, encoding="utf-8") as conf_file: - # If configuration file is empty YAML returns None - # We convert that to an empty dict - return yaml.load(conf_file, Loader=SafeLineLoader) or OrderedDict() - except yaml.YAMLError as exc: - logger.error(str(exc)) - raise XKNXException(exc) from exc - except UnicodeDecodeError as exc: - logger.error("Unable to read file %s: %s", fname, exc) - raise XKNXException(exc) from exc - - -def _include_yaml(loader: SafeLineLoader, node: yaml.nodes.Node) -> JSON_TYPE: - """Load another YAML file and embeds it using the !include tag. - - Example: - device_tracker: !include device_tracker.yaml - - """ - fname = os.path.join(os.path.dirname(loader.name), node.value) - try: - return _add_reference(load_yaml(fname), loader, node) - except FileNotFoundError as exc: - raise XKNXException(f"{node.start_mark}: Unable to read file {fname}.") from exc - - -def _is_file_valid(name: str) -> bool: - """Decide if a file is valid.""" - return not name.startswith(".") - - -def _find_files(directory: str, pattern: str) -> Iterator[str]: - """Recursively load files in a directory.""" - for root, dirs, files in os.walk(directory, topdown=True): - dirs[:] = [d for d in dirs if _is_file_valid(d)] - for basename in sorted(files): - if _is_file_valid(basename) and fnmatch.fnmatch(basename, pattern): - filename = os.path.join(root, basename) - yield filename - - -def _construct_seq(loader: SafeLineLoader, node: yaml.nodes.Node) -> JSON_TYPE: - """Add line number and file name to Load YAML sequence.""" - (obj,) = loader.construct_yaml_seq(node) - return _add_reference(obj, loader, node) - - -def _include_dir_list_yaml( - loader: SafeLineLoader, node: yaml.nodes.Node -) -> List[JSON_TYPE]: - """Load multiple files from directory as a list.""" - loc = os.path.join(os.path.dirname(loader.name), node.value) - return [load_yaml(f) for f in _find_files(loc, "*.yaml")] - - -def _env_var_yaml(loader: SafeLineLoader, node: yaml.nodes.Node) -> str: - """Load environment variables and embed it into the configuration YAML.""" - args = node.value.split() - - # Check for a default value - if len(args) > 1: - return os.getenv(args[0], " ".join(args[1:])) - if args[0] in os.environ: - return os.environ[args[0]] - logger.error("Environment variable %s not defined", node.value) - raise XKNXException(node.value) - - -SafeLineLoader.add_constructor("!include", _include_yaml) -SafeLineLoader.add_constructor( - yaml.resolver.BaseResolver.DEFAULT_SEQUENCE_TAG, _construct_seq -) -SafeLineLoader.add_constructor("!env_var", _env_var_yaml) -SafeLineLoader.add_constructor("!include_dir_list", _include_dir_list_yaml) From bf436ebcf112138ddb77d54bb12986e08f7d4f96 Mon Sep 17 00:00:00 2001 From: Marvin Wichmann Date: Sun, 28 Mar 2021 17:50:10 +0200 Subject: [PATCH 2/2] Review: Pylint & remove leftover --- setup.cfg | 6 +----- test/util.py | 36 ------------------------------------ 2 files changed, 1 insertion(+), 41 deletions(-) delete mode 100644 test/util.py diff --git a/setup.cfg b/setup.cfg index 07789cfe72..438846ad53 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,8 +37,4 @@ python_version = 3.8 strict = true warn_unreachable = true implicit_reexport = true -ignore_missing_imports = true - -# untyped modules -[mypy-xknx.config.config_validation,xknx.config.objects,xknx.config.yaml_loader] -ignore_errors = true \ No newline at end of file +ignore_missing_imports = true \ No newline at end of file diff --git a/test/util.py b/test/util.py deleted file mode 100644 index 538a19cb6d..0000000000 --- a/test/util.py +++ /dev/null @@ -1,36 +0,0 @@ -"""Utility functions for testing.""" -from io import StringIO -import logging -from unittest.mock import patch - -from xknx.config import yaml_loader - -logger = logging.getLogger("xknx.log") - - -def patch_yaml_files(files_dict, endswith=True): - """Patch load_yaml with a dictionary of yaml files.""" - # match using endswith, start search with longest string - matchlist = sorted(list(files_dict.keys()), key=len) if endswith else [] - - def mock_open_f(fname, **_): - """Mock open() in the yaml module, used by load_yaml.""" - # Return the mocked file on full match - if fname in files_dict: - logger.debug("patch_yaml_files match %s", fname) - res = StringIO(files_dict[fname]) - setattr(res, "name", fname) - return res - - # Match using endswith - for ends in matchlist: - if fname.endswith(ends): - logger.debug("patch_yaml_files end match %s: %s", ends, fname) - res = StringIO(files_dict[ends]) - setattr(res, "name", fname) - return res - - # Not found - raise FileNotFoundError(f"File not found: {fname}") - - return patch.object(yaml_loader, "open", mock_open_f, create=True)