auto-sync: 2026-04-15 14:30:01

This commit is contained in:
Stream
2026-04-15 14:30:01 +03:00
parent a89d1285d2
commit 31661cd3de
2 changed files with 98 additions and 46 deletions

View File

@@ -58,10 +58,23 @@ def sanitize_entity_id(entity_id: str) -> str:
return entity_id.replace(".", "_")
# Cyrillic transliteration table
_CYRILLIC_MAP = {
'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd', 'е': 'e', 'ё': 'yo',
'ж': 'zh', 'з': 'z', 'и': 'i', 'й': 'y', 'к': 'k', 'л': 'l', 'м': 'm',
'н': 'n', 'о': 'o', 'п': 'p', 'р': 'r', 'с': 's', 'т': 't', 'у': 'u',
'ф': 'f', 'х': 'kh', 'ц': 'ts', 'ч': 'ch', 'ш': 'sh', 'щ': 'shch',
'ъ': '', 'ы': 'y', 'ь': '', 'э': 'e', 'ю': 'yu', 'я': 'ya',
}
def sanitize_area_name(name: str) -> str:
"""Convert area name to safe sensor suffix."""
"""Convert area name to safe sensor suffix (Latin only)."""
s = name.lower().strip()
s = re.sub(r"[^a-zа-яё0-9_]", "_", s)
# Transliterate Cyrillic to Latin
s = ''.join(_CYRILLIC_MAP.get(ch, ch) for ch in s)
# Keep only a-z, 0-9, _; replace everything else
s = re.sub(r"[^a-z0-9_]", "_", s)
s = re.sub(r"_+", "_", s)
return s.strip("_")