Merge branch 'protect_entity_setters' into integration

This commit is contained in:
J. Nick Koston
2026-03-06 11:19:02 -10:00
2 changed files with 8 additions and 4 deletions
+3 -3
View File
@@ -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)
+5 -1
View File
@@ -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))