|
@@ -14,6 +14,7 @@ from custom_components.tuya_local.helpers.device_config import (
|
|
|
def error_location(entity):
|
|
def error_location(entity):
|
|
|
return f"::error file=custom_components/tuya_local/devices/{entity._device.config},line={entity._config.__line__}:"
|
|
return f"::error file=custom_components/tuya_local/devices/{entity._device.config},line={entity._config.__line__}:"
|
|
|
|
|
|
|
|
|
|
+
|
|
|
def main() -> int:
|
|
def main() -> int:
|
|
|
with open("custom_components/tuya_local/translations/en.json", "r") as f:
|
|
with open("custom_components/tuya_local/translations/en.json", "r") as f:
|
|
|
english = json.load(f)["entity"]
|
|
english = json.load(f)["entity"]
|
|
@@ -22,38 +23,35 @@ def main() -> int:
|
|
|
device = TuyaDeviceConfig(config)
|
|
device = TuyaDeviceConfig(config)
|
|
|
for entity in device.all_entities():
|
|
for entity in device.all_entities():
|
|
|
key = entity.translation_key
|
|
key = entity.translation_key
|
|
|
- where = location(entity)
|
|
|
|
|
|
|
+ where = error_location(entity)
|
|
|
if key and (
|
|
if key and (
|
|
|
- entity.entity not in english
|
|
|
|
|
- or key not in english[entity.entity]
|
|
|
|
|
|
|
+ entity.entity not in english or key not in english[entity.entity]
|
|
|
):
|
|
):
|
|
|
print(f"{where}: translation_key {key} does not exist")
|
|
print(f"{where}: translation_key {key} does not exist")
|
|
|
- detected +=1
|
|
|
|
|
|
|
+ detected += 1
|
|
|
continue
|
|
continue
|
|
|
|
|
|
|
|
if entity.name is None:
|
|
if entity.name is None:
|
|
|
continue
|
|
continue
|
|
|
slug = slugify(entity.name)
|
|
slug = slugify(entity.name)
|
|
|
- cls = entity.class
|
|
|
|
|
|
|
+ cls = entity.device_class
|
|
|
|
|
|
|
|
if cls is not None and key is None and cls == slug:
|
|
if cls is not None and key is None and cls == slug:
|
|
|
print(f"{where}: Entity name {entity.name} hides class translation.")
|
|
print(f"{where}: Entity name {entity.name} hides class translation.")
|
|
|
- detected +=1
|
|
|
|
|
|
|
+ detected += 1
|
|
|
continue
|
|
continue
|
|
|
|
|
|
|
|
- if entity.entity not in english["entity"]:
|
|
|
|
|
|
|
+ if entity.entity not in english:
|
|
|
continue
|
|
continue
|
|
|
|
|
|
|
|
if entity.translation_key:
|
|
if entity.translation_key:
|
|
|
if slug == entity.translation_key:
|
|
if slug == entity.translation_key:
|
|
|
print(f"{where}: Entity name {entity.name} hides translation.")
|
|
print(f"{where}: Entity name {entity.name} hides translation.")
|
|
|
- detected +=1
|
|
|
|
|
|
|
+ detected += 1
|
|
|
continue
|
|
continue
|
|
|
- translations = english["entity"][entity.entity]
|
|
|
|
|
|
|
+ translations = english[entity.entity]
|
|
|
if slug in translations:
|
|
if slug in translations:
|
|
|
- print(
|
|
|
|
|
- f"{where}: Entity can use translation_key: {slug}"
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ print(f"{where}: Entity can use translation_key: {slug}")
|
|
|
detected += 1
|
|
detected += 1
|
|
|
return detected
|
|
return detected
|
|
|
|
|
|