added complete support for packages?
This commit is contained in:
1 parent
ac82a4c96c
commit
f95dd75198
19 files changed
+365
-47
No files matched your search
@@ -0,0 +1,23 @@
|
||||
- id: "ui1"
|
||||
alias: UI 1
|
||||
description: Example
|
||||
mode: single
|
||||
trigger:
|
||||
- platform: homeassistant
|
||||
event: start
|
||||
condition: []
|
||||
action:
|
||||
- service: counter.increment
|
||||
data: {}
|
||||
target:
|
||||
entity_id: counter.up_times
|
||||
- id: "ui2"
|
||||
alias: UI 2
|
||||
description: ""
|
||||
trigger:
|
||||
- platform: sun
|
||||
event: sunrise
|
||||
offset: 0
|
||||
condition: []
|
||||
action: []
|
||||
mode: single
|
||||
@@ -0,0 +1,31 @@
|
||||
# Loads default set of integrations. Do not remove.
|
||||
default_config:
|
||||
|
||||
# Text to speech
|
||||
tts:
|
||||
- platform: google_translate
|
||||
|
||||
# automation manual: !include_dir_list ./automations/include_dir_list
|
||||
# automation ui: !include automations/ui.yaml
|
||||
# automation: !include automations/base.yaml
|
||||
# automation cools: !include_dir_merge_list automations/include_dir_merge_list
|
||||
script: !include scripts.yaml
|
||||
scene: !include scenes.yaml
|
||||
|
||||
automation:
|
||||
- id: "inline-auto"
|
||||
alias: inline-auto
|
||||
description: Example package auto
|
||||
mode: single
|
||||
trigger:
|
||||
- platform: homeassistant
|
||||
event: start
|
||||
condition: []
|
||||
action:
|
||||
- service: counter.increment
|
||||
data: {}
|
||||
target:
|
||||
entity_id: counter.up_times
|
||||
|
||||
homeassistant:
|
||||
packages: !include packages.yaml
|
||||
@@ -0,0 +1,2 @@
|
||||
ha: !include packages/ha.yaml
|
||||
sub: !include_dir_named packages/sub
|
||||
@@ -0,0 +1 @@
|
||||
automation: !include ../automations/ui.yaml
|
||||
@@ -0,0 +1,13 @@
|
||||
- id: "package2"
|
||||
alias: package ha
|
||||
description: Example package auto
|
||||
mode: single
|
||||
trigger:
|
||||
- platform: homeassistant
|
||||
event: start
|
||||
condition: []
|
||||
action:
|
||||
- service: counter.increment
|
||||
data: {}
|
||||
target:
|
||||
entity_id: counter.up_times
|
||||
@@ -0,0 +1,23 @@
|
||||
- id: "ui1"
|
||||
alias: UI 1
|
||||
description: Example
|
||||
mode: single
|
||||
trigger:
|
||||
- platform: homeassistant
|
||||
event: start
|
||||
condition: []
|
||||
action:
|
||||
- service: counter.increment
|
||||
data: {}
|
||||
target:
|
||||
entity_id: counter.up_times
|
||||
- id: "ui2"
|
||||
alias: UI 2
|
||||
description: ""
|
||||
trigger:
|
||||
- platform: sun
|
||||
event: sunrise
|
||||
offset: 0
|
||||
condition: []
|
||||
action: []
|
||||
mode: single
|
||||
@@ -0,0 +1,31 @@
|
||||
# Loads default set of integrations. Do not remove.
|
||||
default_config:
|
||||
|
||||
# Text to speech
|
||||
tts:
|
||||
- platform: google_translate
|
||||
|
||||
# automation manual: !include_dir_list ./automations/include_dir_list
|
||||
# automation ui: !include automations/ui.yaml
|
||||
# automation: !include automations/base.yaml
|
||||
# automation cools: !include_dir_merge_list automations/include_dir_merge_list
|
||||
script: !include scripts.yaml
|
||||
scene: !include scenes.yaml
|
||||
|
||||
automation:
|
||||
- id: "inline-auto"
|
||||
alias: inline-auto
|
||||
description: Example package auto
|
||||
mode: single
|
||||
trigger:
|
||||
- platform: homeassistant
|
||||
event: start
|
||||
condition: []
|
||||
action:
|
||||
- service: counter.increment
|
||||
data: {}
|
||||
target:
|
||||
entity_id: counter.up_times
|
||||
|
||||
homeassistant:
|
||||
packages: !include packages.yaml
|
||||
@@ -0,0 +1,17 @@
|
||||
ha: !include packages/ha.yaml
|
||||
sub: !include_dir_merge_named packages/sub
|
||||
secret_ones:
|
||||
automation:
|
||||
- id: "inline-package-auto"
|
||||
alias: package ha
|
||||
description: Example package auto
|
||||
mode: single
|
||||
trigger:
|
||||
- platform: homeassistant
|
||||
event: start
|
||||
condition: []
|
||||
action:
|
||||
- service: counter.increment
|
||||
data: {}
|
||||
target:
|
||||
entity_id: counter.up_times
|
||||
@@ -0,0 +1 @@
|
||||
automation: !include ../automations/ui.yaml
|
||||
@@ -0,0 +1,14 @@
|
||||
automation:
|
||||
- id: "package2"
|
||||
alias: package ha
|
||||
description: Example package auto
|
||||
mode: single
|
||||
trigger:
|
||||
- platform: homeassistant
|
||||
event: start
|
||||
condition: []
|
||||
action:
|
||||
- service: counter.increment
|
||||
data: {}
|
||||
target:
|
||||
entity_id: counter.up_times
|
||||
@@ -7,9 +7,9 @@ from fastapi.testclient import TestClient
|
||||
from src.api.app import make_app
|
||||
from src.automations.types import Automation, ExtenededAutomation
|
||||
from tests.utils import (
|
||||
HA_CONFIG10_EXAMPLE,
|
||||
HA_CONFIG2_EXAMPLE,
|
||||
HA_CONFIG6_EXAMPLE,
|
||||
HA_CONFIG10_EXAMPLE,
|
||||
get_example_automation_loader,
|
||||
)
|
||||
|
||||
@@ -389,7 +389,7 @@ class automation_update_split_config_tests(automation_update_tests):
|
||||
|
||||
class automation_update_split_config_and_inline_config_tests(automation_update_tests):
|
||||
test_params = {
|
||||
"total": 3,
|
||||
"total": 4,
|
||||
"modify_item": 0,
|
||||
"consitency_tests": {},
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ from tests.utils import (
|
||||
HA_CONFIG8_EXAMPLE,
|
||||
HA_CONFIG9_EXAMPLE,
|
||||
HA_CONFIG10_EXAMPLE,
|
||||
HA_CONFIG11_EXAMPLE,
|
||||
HA_CONFIG12_EXAMPLE,
|
||||
HA_CONFIG_EXAMPLE,
|
||||
)
|
||||
|
||||
@@ -153,9 +155,11 @@ class loader_tests(TestCase):
|
||||
(HA_CONFIG5_EXAMPLE, 3),
|
||||
(HA_CONFIG6_EXAMPLE, 4),
|
||||
(HA_CONFIG7_EXAMPLE, 1),
|
||||
(HA_CONFIG8_EXAMPLE, 1),
|
||||
(HA_CONFIG8_EXAMPLE, 2),
|
||||
(HA_CONFIG9_EXAMPLE, 1),
|
||||
(HA_CONFIG10_EXAMPLE, 2),
|
||||
(HA_CONFIG10_EXAMPLE, 3),
|
||||
(HA_CONFIG11_EXAMPLE, 3),
|
||||
(HA_CONFIG12_EXAMPLE, 4),
|
||||
]:
|
||||
with self.subTest(config_name=ha_path.name, expected=expected):
|
||||
hass_config = HassConfig(ha_path)
|
||||
|
||||
@@ -14,6 +14,8 @@ from tests.utils import (
|
||||
HA_CONFIG6_EXAMPLE,
|
||||
HA_CONFIG8_EXAMPLE,
|
||||
HA_CONFIG10_EXAMPLE,
|
||||
HA_CONFIG11_EXAMPLE,
|
||||
HA_CONFIG12_EXAMPLE,
|
||||
HA_CONFIG_EXAMPLE,
|
||||
create_copy_of_example_config,
|
||||
)
|
||||
@@ -324,11 +326,53 @@ class manager_tests(TestWithDB):
|
||||
{},
|
||||
)
|
||||
|
||||
def test_load_pacakges(self):
|
||||
def test_load_pacakges_include_dir_named(self):
|
||||
_, automation_manager = self.get_manager(HA_CONFIG8_EXAMPLE)
|
||||
automation_manager.reload()
|
||||
auto = automation_manager.get("package-sub")
|
||||
self.assertEqual(auto.configuration_key, ["pacakage2"])
|
||||
|
||||
with self.subTest(name="inline"):
|
||||
auto = automation_manager.get("package-sub")
|
||||
self.assertEqual(auto.source_file_type, "inline")
|
||||
self.assertEqual(auto.source_file, "packages/sub/package2.yaml")
|
||||
self.assertEqual(auto.configuration_key, ["automation"])
|
||||
|
||||
with self.subTest(name="sub !inlcude"):
|
||||
auto = automation_manager.get("ui1")
|
||||
self.assertEqual(auto.source_file, "automations/ui.yaml")
|
||||
self.assertEqual(auto.source_file_type, "list")
|
||||
self.assertEqual(auto.configuration_key, [])
|
||||
|
||||
def test_load_pacakges_include_dir_merge_named(self):
|
||||
_, automation_manager = self.get_manager(HA_CONFIG10_EXAMPLE)
|
||||
automation_manager.reload()
|
||||
|
||||
with self.subTest(name="inline"):
|
||||
auto = automation_manager.get("package2")
|
||||
self.assertEqual(auto.source_file_type, "inline")
|
||||
self.assertEqual(auto.source_file, "packages/sub/package2.yaml")
|
||||
self.assertEqual(auto.configuration_key, ["package2", "automation"])
|
||||
|
||||
with self.subTest(name="sub !inlcude"):
|
||||
auto = automation_manager.get("ui1")
|
||||
self.assertEqual(auto.source_file, "automations/ui.yaml")
|
||||
self.assertEqual(auto.source_file_type, "list")
|
||||
self.assertEqual(auto.configuration_key, ["ha"])
|
||||
|
||||
def test_load_pacakges_include(self):
|
||||
_, automation_manager = self.get_manager(HA_CONFIG11_EXAMPLE)
|
||||
automation_manager.reload()
|
||||
|
||||
with self.subTest(name="inline"):
|
||||
auto = automation_manager.get("package2")
|
||||
self.assertEqual(auto.source_file_type, "list")
|
||||
self.assertEqual(auto.source_file, "packages/sub/automation.yaml")
|
||||
self.assertEqual(auto.configuration_key, ["sub"])
|
||||
|
||||
with self.subTest(name="sub !inlcude"):
|
||||
auto = automation_manager.get("ui1")
|
||||
self.assertEqual(auto.source_file, "automations/ui.yaml")
|
||||
self.assertEqual(auto.source_file_type, "list")
|
||||
self.assertEqual(auto.configuration_key, ["ha"])
|
||||
|
||||
def test_load_inline_auto(self):
|
||||
_, automation_manager = self.get_manager(HA_CONFIG10_EXAMPLE)
|
||||
@@ -336,3 +380,19 @@ class manager_tests(TestWithDB):
|
||||
auto = automation_manager.get("inline-auto")
|
||||
self.assertEqual(auto.source_file_type, "inline")
|
||||
self.assertEqual(auto.configuration_key, ["automation"])
|
||||
|
||||
def test_load_pacakges_nested_include_dir_merge_named(self):
|
||||
_, automation_manager = self.get_manager(HA_CONFIG12_EXAMPLE)
|
||||
automation_manager.reload()
|
||||
|
||||
with self.subTest(name="inline"):
|
||||
auto = automation_manager.get("package2")
|
||||
self.assertEqual(auto.source_file_type, "inline")
|
||||
self.assertEqual(auto.source_file, "packages/sub/automation.yaml")
|
||||
self.assertEqual(auto.configuration_key, ["automation"])
|
||||
|
||||
with self.subTest(name="sub !inlcude"):
|
||||
auto = automation_manager.get("ui1")
|
||||
self.assertEqual(auto.source_file, "automations/ui.yaml")
|
||||
self.assertEqual(auto.source_file_type, "list")
|
||||
self.assertEqual(auto.configuration_key, ["ha"])
|
||||
@@ -51,9 +51,3 @@ class loader_tests(TestCase):
|
||||
with self.subTest(name=folder.name):
|
||||
hass_config = HassConfig(folder)
|
||||
assert isinstance(hass_config.homeassistant, dict)
|
||||
|
||||
def test_load_packages(self):
|
||||
for folder in SAMPLES_FOLDER.iterdir():
|
||||
with self.subTest(name=folder.name):
|
||||
hass_config = HassConfig(folder)
|
||||
assert isinstance(hass_config.pacakges, dict)
|
||||
@@ -20,6 +20,8 @@ HA_CONFIG7_EXAMPLE = SAMPLES_FOLDER / "config-7"
|
||||
HA_CONFIG8_EXAMPLE = SAMPLES_FOLDER / "config-8"
|
||||
HA_CONFIG9_EXAMPLE = SAMPLES_FOLDER / "config-9"
|
||||
HA_CONFIG10_EXAMPLE = SAMPLES_FOLDER / "config-10"
|
||||
HA_CONFIG11_EXAMPLE = SAMPLES_FOLDER / "config-11"
|
||||
HA_CONFIG12_EXAMPLE = SAMPLES_FOLDER / "config-12"
|
||||
|
||||
|
||||
def get_example_automation_loader(
|
||||
|
||||
Reference in new issue
Block a user