1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-13 15:23:49 +01:00
This commit is contained in:
J. Nick Koston
2025-10-09 15:50:30 -10:00
parent 420d227221
commit 1ae99b4f52
2 changed files with 17 additions and 10 deletions

View File

@@ -48,6 +48,10 @@ PACKAGE_DEPENDENCIES = {
# Add more package dependencies here as needed # Add more package dependencies here as needed
} }
# Bus types that can be defined directly in config files
# Components defining these directly cannot be grouped (they create unique bus IDs)
DIRECT_BUS_TYPES = ("i2c", "spi", "uart", "modbus")
# Base bus components - these ARE the bus implementations and should not # Base bus components - these ARE the bus implementations and should not
# be flagged as needing migration since they are the platform/base components # be flagged as needing migration since they are the platform/base components
BASE_BUS_COMPONENTS = { BASE_BUS_COMPONENTS = {
@@ -213,10 +217,10 @@ def analyze_yaml_file(yaml_file: Path) -> dict[str, Any]:
result["has_extend_remove"] = _contains_extend_or_remove(data) result["has_extend_remove"] = _contains_extend_or_remove(data)
# Check if buses are defined directly (not via packages) # Check if buses are defined directly (not via packages)
# Components that define i2c, spi, or uart directly in test files # Components that define i2c, spi, uart, or modbus directly in test files
# cannot be grouped because they create unique bus IDs # cannot be grouped because they create unique bus IDs
if isinstance(data, dict): if isinstance(data, dict):
for bus_type in ("i2c", "spi", "uart"): for bus_type in DIRECT_BUS_TYPES:
if bus_type in data: if bus_type in data:
result["has_direct_bus_config"] = True result["has_direct_bus_config"] = True
break break

View File

@@ -72,14 +72,17 @@ def extract_packages_from_yaml(data: dict) -> dict[str, str]:
# Dictionary format: packages: {name: value} # Dictionary format: packages: {name: value}
for name, value in packages_value.items(): for name, value in packages_value.items():
# Only include common bus packages, ignore component-specific ones # Only include common bus packages, ignore component-specific ones
if name in common_bus_packages: if name not in common_bus_packages:
packages[name] = str(value) continue
# Also track package dependencies (e.g., modbus includes uart) packages[name] = str(value)
if name in PACKAGE_DEPENDENCIES: # Also track package dependencies (e.g., modbus includes uart)
for dep in PACKAGE_DEPENDENCIES[name]: if name not in PACKAGE_DEPENDENCIES:
if dep in common_bus_packages: continue
# Mark as included via dependency for dep in PACKAGE_DEPENDENCIES[name]:
packages[f"_dep_{dep}"] = f"(included via {name})" if dep not in common_bus_packages:
continue
# Mark as included via dependency
packages[f"_dep_{dep}"] = f"(included via {name})"
return packages return packages