mirror of
https://github.com/esphome/esphome.git
synced 2026-09-16 17:48:40 +00:00
Merge branch 'protect_entity_setters' into integration
This commit is contained in:
@@ -250,11 +250,11 @@ def _describe_packed_flags(config: ConfigType, entity_category: int) -> str:
|
||||
cat_name := entity_cat_keys[entity_category]
|
||||
):
|
||||
parts.append(f"category:{cat_name}")
|
||||
if dc := config.get(CONF_DEVICE_CLASS):
|
||||
if config.get(_KEY_DC_IDX) and (dc := config.get(CONF_DEVICE_CLASS)):
|
||||
parts.append(f"dc:{_sanitize_comment(dc)}")
|
||||
if uom := config.get(CONF_UNIT_OF_MEASUREMENT):
|
||||
if config.get(_KEY_UOM_IDX) and (uom := config.get(CONF_UNIT_OF_MEASUREMENT)):
|
||||
parts.append(f"uom:{_sanitize_comment(uom)}")
|
||||
if icon := config.get(CONF_ICON):
|
||||
if config.get(_KEY_ICON_IDX) and (icon := config.get(CONF_ICON)):
|
||||
parts.append(f"icon:{_sanitize_comment(icon)}")
|
||||
return ", ".join(parts)
|
||||
|
||||
|
||||
@@ -9,7 +9,11 @@ INTERNAL_BIT = 1 << 24
|
||||
|
||||
def extract_packed_value(main_cpp: str, var_name: str) -> int:
|
||||
"""Extract the third (packed) argument from a configure_entity_ call."""
|
||||
pattern = rf"{re.escape(var_name)}->configure_entity_\([^,]+,\s*\w+,\s*(\d+)\)"
|
||||
pattern = (
|
||||
rf"{re.escape(var_name)}->configure_entity_\("
|
||||
r'"(?:\\.|[^"\\])*"'
|
||||
r",\s*\w+,\s*(\d+)\)"
|
||||
)
|
||||
match = re.search(pattern, main_cpp)
|
||||
assert match, f"configure_entity_ call not found for {var_name}"
|
||||
return int(match.group(1))
|
||||
|
||||
Reference in New Issue
Block a user