From 3c747f9602688fe68814b22098b66c50aa2bc78d Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Sat, 1 Jul 2023 01:44:23 +0200 Subject: [PATCH] Add script to check missing translations --- scripts/check.py | 46 ++++++++++++++++++++++++++++++++++++++++++ scripts/sensor_docs.py | 25 ++++------------------- 2 files changed, 50 insertions(+), 21 deletions(-) create mode 100755 scripts/check.py diff --git a/scripts/check.py b/scripts/check.py new file mode 100755 index 0000000..150259f --- /dev/null +++ b/scripts/check.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +import sys +from pathlib import Path + +if __name__ == "__main__": + sys.path.insert(0, str(Path(__file__).parent.parent)) + +from custom_components.hon.binary_sensor import BINARY_SENSORS +from custom_components.hon.button import BUTTONS +from custom_components.hon.climate import CLIMATES +from custom_components.hon.fan import FANS +from custom_components.hon.light import LIGHTS +from custom_components.hon.number import NUMBERS +from custom_components.hon.select import SELECTS +from custom_components.hon.sensor import SENSORS +from custom_components.hon.switch import SWITCHES + +entities = { + "binary_sensor": BINARY_SENSORS, + "button": BUTTONS, + "light": LIGHTS, + "climate": CLIMATES, + "number": NUMBERS, + "select": SELECTS, + "sensor": SENSORS, + "fan": FANS, + "switch": SWITCHES, +} + + +def get_missing_translation_keys(): + result = {} + for entity_type, appliances in entities.items(): + for appliance, data in appliances.items(): + for entity in data: + if entity.translation_key: + continue + key = f"{entity_type}.{entity.key}" + result.setdefault(appliance, []).append(key) + return result + + +if __name__ == "__main__": + for appliance, data in sorted(get_missing_translation_keys().items()): + for key in data: + print(f"WARNING - {appliance} - Missing translation key for {key}") diff --git a/scripts/sensor_docs.py b/scripts/sensor_docs.py index 10c914f..cc144d4 100755 --- a/scripts/sensor_docs.py +++ b/scripts/sensor_docs.py @@ -8,6 +8,7 @@ from pathlib import Path if __name__ == "__main__": sys.path.insert(0, str(Path(__file__).parent.parent)) +from custom_components.hon.const import APPLIANCES from custom_components.hon.binary_sensor import BINARY_SENSORS from custom_components.hon.button import BUTTONS from custom_components.hon.light import LIGHTS @@ -22,36 +23,18 @@ from custom_components.hon.switch import ( HonSwitchEntityDescription, ) -APPLIANCES = { - "AC": "Air Conditioner", - "AP": "Air Purifier", - "AS": "Air Scanner", - "DW": "Dish Washer", - "HO": "Hood", - "IH": "Induction Hob", - "MW": "Microwave", - "OV": "Oven", - "REF": "Fridge", - "RVC": "Robot Vacuum Cleaner", - "TD": "Tumble Dryer", - "WC": "Wine Cellar", - "WD": "Washer Dryer", - "WH": "Water Heater", - "WM": "Washing Machine", -} - ENTITY_CATEGORY_SORT = ["control", "config", "sensor"] entities = { "binary_sensor": BINARY_SENSORS, "button": BUTTONS, + "light": LIGHTS, + "climate": CLIMATES, "number": NUMBERS, "select": SELECTS, "sensor": SENSORS, - "switch": SWITCHES, - "climate": CLIMATES, "fan": FANS, - "light": LIGHTS, + "switch": SWITCHES, } result = {}