mirror of
https://github.com/esphome/esphome.git
synced 2025-08-10 20:29:24 +00:00
make areas and devices consistant
This commit is contained in:
@@ -844,8 +844,8 @@ CONF_STILL_THRESHOLD = "still_threshold"
|
||||
CONF_STOP = "stop"
|
||||
CONF_STOP_ACTION = "stop_action"
|
||||
CONF_STORE_BASELINE = "store_baseline"
|
||||
CONF_SUB_AREAS = "sub_areas"
|
||||
CONF_SUB_DEVICES = "sub_devices"
|
||||
CONF_AREAS = "areas"
|
||||
CONF_DEVICES = "devices"
|
||||
CONF_SUBNET = "subnet"
|
||||
CONF_SUBSCRIBE_QOS = "subscribe_qos"
|
||||
CONF_SUBSTITUTIONS = "substitutions"
|
||||
|
@@ -8,10 +8,12 @@ import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_AREA,
|
||||
CONF_AREA_ID,
|
||||
CONF_AREAS,
|
||||
CONF_BUILD_PATH,
|
||||
CONF_COMMENT,
|
||||
CONF_COMPILE_PROCESS_LIMIT,
|
||||
CONF_DEBUG_SCHEDULER,
|
||||
CONF_DEVICES,
|
||||
CONF_ESPHOME,
|
||||
CONF_FRIENDLY_NAME,
|
||||
CONF_ID,
|
||||
@@ -28,8 +30,6 @@ from esphome.const import (
|
||||
CONF_PLATFORMIO_OPTIONS,
|
||||
CONF_PRIORITY,
|
||||
CONF_PROJECT,
|
||||
CONF_SUB_AREAS,
|
||||
CONF_SUB_DEVICES,
|
||||
CONF_TRIGGER_ID,
|
||||
CONF_VERSION,
|
||||
KEY_CORE,
|
||||
@@ -186,7 +186,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
cv.Optional(
|
||||
CONF_COMPILE_PROCESS_LIMIT, default=_compile_process_limit_default
|
||||
): cv.int_range(min=1, max=get_usable_cpu_count()),
|
||||
cv.Optional(CONF_SUB_AREAS, default=[]): cv.ensure_list(
|
||||
cv.Optional(CONF_AREAS, default=[]): cv.ensure_list(
|
||||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(CONF_ID): cv.declare_id(Area),
|
||||
@@ -194,7 +194,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
}
|
||||
),
|
||||
),
|
||||
cv.Optional(CONF_SUB_DEVICES, default=[]): cv.ensure_list(
|
||||
cv.Optional(CONF_DEVICES, default=[]): cv.ensure_list(
|
||||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(CONF_ID): cv.declare_id(Device),
|
||||
@@ -486,9 +486,9 @@ async def to_code(config):
|
||||
cg.add_define("USE_AREAS")
|
||||
|
||||
# Process sub-devices and areas
|
||||
if sub_devices := config.get(CONF_SUB_DEVICES):
|
||||
if sub_devices := config.get(CONF_DEVICES):
|
||||
# Process areas first
|
||||
if sub_areas := config.get(CONF_SUB_AREAS):
|
||||
if sub_areas := config.get(CONF_AREAS):
|
||||
for area_conf in sub_areas:
|
||||
area = cg.new_Pvariable(area_conf[CONF_ID])
|
||||
area_id = fnv1a_32bit_hash(str(area_conf[CONF_ID]))
|
||||
|
@@ -84,7 +84,8 @@
|
||||
#define USE_SELECT
|
||||
#define USE_SENSOR
|
||||
#define USE_STATUS_LED
|
||||
#define USE_SUB_DEVICE
|
||||
#define USE_DEVICES
|
||||
#define USE_AREAS
|
||||
#define USE_SWITCH
|
||||
#define USE_TEXT
|
||||
#define USE_TEXT_SENSOR
|
||||
|
@@ -19,16 +19,16 @@ esphome:
|
||||
version: "1.1"
|
||||
on_update:
|
||||
logger.log: on_update
|
||||
sub_areas:
|
||||
areas:
|
||||
- id: another_area
|
||||
name: Another area
|
||||
sub_devices:
|
||||
devices:
|
||||
- id: other_device
|
||||
name: Another device
|
||||
area_id: another_area
|
||||
- id: test_device
|
||||
name: Test device in main area
|
||||
area_id: testing_area # Reference the main area (not in sub_areas)
|
||||
area_id: testing_area # Reference the main area (not in areas)
|
||||
- id: no_area_device
|
||||
name: Device without area # This device has no area_id
|
||||
|
||||
|
Reference in New Issue
Block a user