mirror of
https://github.com/esphome/esphome.git
synced 2025-10-30 06:33:51 +00:00
[API] Sub devices and areas (#8544)
Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Co-authored-by: J. Nick Koston <nick+github@koston.org>
This commit is contained in:
10
tests/unit_tests/fixtures/core/config/area_id_collision.yaml
Normal file
10
tests/unit_tests/fixtures/core/config/area_id_collision.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
esphome:
|
||||
name: test-collision
|
||||
area:
|
||||
id: duplicate_id
|
||||
name: Area 1
|
||||
areas:
|
||||
- id: duplicate_id
|
||||
name: Area 2
|
||||
|
||||
host:
|
||||
@@ -0,0 +1,10 @@
|
||||
esphome:
|
||||
name: test
|
||||
areas:
|
||||
- id: test_2258
|
||||
name: "Area 1"
|
||||
- id: d6ka
|
||||
name: "Area 2"
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
@@ -0,0 +1,10 @@
|
||||
esphome:
|
||||
name: test
|
||||
devices:
|
||||
- id: duplicate_device
|
||||
name: "Device 1"
|
||||
- id: duplicate_device
|
||||
name: "Device 2"
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
@@ -0,0 +1,10 @@
|
||||
esphome:
|
||||
name: test
|
||||
devices:
|
||||
- id: test_2258
|
||||
name: "Device 1"
|
||||
- id: d6ka
|
||||
name: "Device 2"
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
@@ -0,0 +1,12 @@
|
||||
esphome:
|
||||
name: test
|
||||
areas:
|
||||
- id: valid_area
|
||||
name: "Valid Area"
|
||||
devices:
|
||||
- id: test_device
|
||||
name: "Test Device"
|
||||
area_id: nonexistent_area
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
@@ -0,0 +1,7 @@
|
||||
esphome:
|
||||
name: test-device-no-area
|
||||
devices:
|
||||
- id: test_device
|
||||
name: Test Device
|
||||
|
||||
host:
|
||||
@@ -0,0 +1,5 @@
|
||||
esphome:
|
||||
name: test-legacy-area
|
||||
area: Living Room
|
||||
|
||||
host:
|
||||
@@ -0,0 +1,22 @@
|
||||
esphome:
|
||||
name: test-multiple
|
||||
area:
|
||||
id: main_area
|
||||
name: Main Area
|
||||
areas:
|
||||
- id: area1
|
||||
name: Area 1
|
||||
- id: area2
|
||||
name: Area 2
|
||||
devices:
|
||||
- id: device1
|
||||
name: Device 1
|
||||
area_id: main_area
|
||||
- id: device2
|
||||
name: Device 2
|
||||
area_id: area1
|
||||
- id: device3
|
||||
name: Device 3
|
||||
area_id: area2
|
||||
|
||||
host:
|
||||
11
tests/unit_tests/fixtures/core/config/valid_area_device.yaml
Normal file
11
tests/unit_tests/fixtures/core/config/valid_area_device.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
esphome:
|
||||
name: test-valid-area
|
||||
areas:
|
||||
- id: bedroom_area
|
||||
name: Bedroom
|
||||
devices:
|
||||
- id: test_device
|
||||
name: Test Device
|
||||
area_id: bedroom_area
|
||||
|
||||
host:
|
||||
@@ -0,0 +1,13 @@
|
||||
esphome:
|
||||
name: test-duplicate
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
|
||||
sensor:
|
||||
- platform: template
|
||||
name: "Temperature"
|
||||
lambda: return 21.0;
|
||||
- platform: template
|
||||
name: "Temperature" # Duplicate - should fail
|
||||
lambda: return 22.0;
|
||||
@@ -0,0 +1,26 @@
|
||||
esphome:
|
||||
name: test-duplicate-devices
|
||||
devices:
|
||||
- id: device1
|
||||
name: "Device 1"
|
||||
- id: device2
|
||||
name: "Device 2"
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
|
||||
sensor:
|
||||
# Same name on different devices - should pass
|
||||
- platform: template
|
||||
device_id: device1
|
||||
name: "Temperature"
|
||||
lambda: return 21.0;
|
||||
- platform: template
|
||||
device_id: device2
|
||||
name: "Temperature"
|
||||
lambda: return 22.0;
|
||||
# Duplicate on same device - should fail
|
||||
- platform: template
|
||||
device_id: device1
|
||||
name: "Temperature"
|
||||
lambda: return 23.0;
|
||||
@@ -0,0 +1,20 @@
|
||||
esphome:
|
||||
name: test-different-platforms
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
|
||||
sensor:
|
||||
- platform: template
|
||||
name: "Status"
|
||||
lambda: return 1.0;
|
||||
|
||||
binary_sensor:
|
||||
- platform: template
|
||||
name: "Status" # Same name, different platform - should pass
|
||||
lambda: return true;
|
||||
|
||||
text_sensor:
|
||||
- platform: template
|
||||
name: "Status" # Same name, different platform - should pass
|
||||
lambda: return {"OK"};
|
||||
Reference in New Issue
Block a user