2023-04-23 03:06:31 +05:30
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2023-04-22 06:17:55 +05:30
|
|
|
import asyncio
|
|
|
|
import json
|
2023-04-23 01:12:16 +05:30
|
|
|
import re
|
2023-05-07 18:29:04 +05:30
|
|
|
import sys
|
2023-04-22 06:17:55 +05:30
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
from pyhon import HonAPI
|
|
|
|
|
2023-05-07 18:29:04 +05:30
|
|
|
if __name__ == "__main__":
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
|
2023-05-07 17:17:19 +05:30
|
|
|
from custom_components.hon import const
|
2023-04-27 03:27:44 +05:30
|
|
|
|
2023-04-22 06:17:55 +05:30
|
|
|
SENSOR = {
|
2023-05-07 17:17:19 +05:30
|
|
|
"washing_modes": const.MACH_MODE,
|
|
|
|
"mach_modes_ac": const.AC_MACH_MODE,
|
|
|
|
"program_phases_wm": const.WASHING_PR_PHASE,
|
|
|
|
"program_phases_td": const.TUMBLE_DRYER_PR_PHASE,
|
|
|
|
"program_phases_dw": const.DISHWASHER_PR_PHASE,
|
|
|
|
"dry_levels": const.TUMBLE_DRYER_DRY_LEVEL,
|
2023-04-22 06:17:55 +05:30
|
|
|
}
|
|
|
|
|
2023-04-27 03:27:44 +05:30
|
|
|
SELECT = {
|
2023-05-07 17:17:19 +05:30
|
|
|
"dry_levels": const.TUMBLE_DRYER_DRY_LEVEL,
|
|
|
|
"eco_pilot": const.AC_HUMAN_SENSE,
|
|
|
|
"fan_mode": const.AC_FAN_MODE,
|
2023-05-22 00:21:20 +05:30
|
|
|
"ref_zones": const.REF_ZONES,
|
2023-04-27 03:27:44 +05:30
|
|
|
}
|
2023-04-23 02:39:57 +05:30
|
|
|
|
2023-04-23 00:49:32 +05:30
|
|
|
PROGRAMS = {
|
2023-05-07 17:17:19 +05:30
|
|
|
"select": {
|
|
|
|
"programs_ac": "PROGRAMS.AC",
|
|
|
|
"programs_dw": "PROGRAMS.DW",
|
|
|
|
"programs_ih": "PROGRAMS.IH",
|
|
|
|
"programs_ov": "PROGRAMS.OV",
|
|
|
|
"programs_td": "PROGRAMS.TD",
|
|
|
|
"programs_wm": "PROGRAMS.WM_WD",
|
2023-05-10 21:43:05 +05:30
|
|
|
"programs_ref": "PROGRAMS.REF",
|
2023-05-07 17:17:19 +05:30
|
|
|
},
|
|
|
|
"sensor": {
|
2023-05-29 22:37:52 +05:30
|
|
|
"programs_ac": "PROGRAMS.AC",
|
|
|
|
"programs_dw": "PROGRAMS.DW",
|
|
|
|
"programs_ih": "PROGRAMS.IH",
|
|
|
|
"programs_ov": "PROGRAMS.OV",
|
2023-05-07 17:17:19 +05:30
|
|
|
"programs_td": "PROGRAMS.TD",
|
2023-05-29 22:37:52 +05:30
|
|
|
"programs_wm": "PROGRAMS.WM_WD",
|
|
|
|
"programs_ref": "PROGRAMS.REF",
|
2023-05-07 17:17:19 +05:30
|
|
|
},
|
2023-04-23 00:49:32 +05:30
|
|
|
}
|
|
|
|
|
2023-05-28 11:20:59 +05:30
|
|
|
CLIMATE = {
|
|
|
|
"fridge": {
|
|
|
|
"preset_mode": {
|
|
|
|
"name": "REF_CMD&CTRL.MODE_SELECTION_DRAWER_FRIDGE.FRIDGE_MODE_TITLE",
|
|
|
|
"state": {
|
|
|
|
"auto_set": "REF_CMD&CTRL.MODALITIES.ECO",
|
|
|
|
"super_cool": "REF_CMD&CTRL.MODALITIES.SUPER_COOL",
|
|
|
|
"holiday": "REF_CMD&CTRL.MODALITIES.BACK_FROM_HOLIDAY",
|
|
|
|
"no_mode": "REF_CMD&CTRL.MODALITIES.NO_MODE_SELECTED",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"freezer": {
|
|
|
|
"preset_mode": {
|
|
|
|
"name": "REF_CMD&CTRL.MODE_SELECTION_DRAWER_FREEZER.FREEZER_MODE_TITLE",
|
|
|
|
"state": {
|
|
|
|
"auto_set": "REF_CMD&CTRL.MODALITIES.ECO",
|
|
|
|
"super_freeze": "REF_CMD&CTRL.MODALITIES.SHOCK_FREEZE",
|
|
|
|
"no_mode": "REF_CMD&CTRL.MODALITIES.NO_MODE_SELECTED",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
2023-05-28 21:08:56 +05:30
|
|
|
"oven": {
|
|
|
|
"preset_mode": {
|
|
|
|
"name": "OV.TABS.PROGRAMS_TITLE",
|
|
|
|
"state": "PROGRAMS.OV",
|
|
|
|
}
|
|
|
|
},
|
2023-05-28 11:20:59 +05:30
|
|
|
}
|
|
|
|
|
2023-04-23 05:31:14 +05:30
|
|
|
NAMES = {
|
|
|
|
"switch": {
|
|
|
|
"anti_crease": "HDRY_CMD&CTRL.PROGRAM_CYCLE_DETAIL.ANTICREASE_TITLE",
|
2023-05-07 17:17:19 +05:30
|
|
|
"add_dish": "DW.ADD_DISH",
|
2023-04-23 05:31:14 +05:30
|
|
|
"eco_express": "DW_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.ECO",
|
|
|
|
"extra_dry": "DW_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.EXTRA_DRY",
|
|
|
|
"half_load": "DW_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.HALF_LOAD",
|
|
|
|
"open_door": "DW_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.OPEN_DOOR",
|
|
|
|
"three_in_one": "DW_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.THREE_IN_ONE",
|
|
|
|
"preheat": "OV.PROGRAM_DETAIL.PREHEAT",
|
|
|
|
"dish_washer": "GLOBALS.APPLIANCES_NAME.DW",
|
|
|
|
"tumble_dryer": "GLOBALS.APPLIANCES_NAME.TD",
|
|
|
|
"washing_machine": "GLOBALS.APPLIANCES_NAME.WM",
|
|
|
|
"washer_dryer": "GLOBALS.APPLIANCES_NAME.WD",
|
|
|
|
"oven": "GLOBALS.APPLIANCES_NAME.OV",
|
|
|
|
"prewash": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.PREWASH",
|
|
|
|
"pause": "GENERAL.PAUSE_PROGRAM",
|
2023-04-23 19:54:30 +05:30
|
|
|
"keep_fresh": "GLOBALS.APPLIANCE_STATUS.TUMBLING",
|
2023-04-25 01:08:05 +05:30
|
|
|
"delay_time": "HINTS.TIPS_TIME_ENERGY_SAVING.TIPS_USE_AT_NIGHT_TITLE",
|
2023-04-27 03:27:44 +05:30
|
|
|
"rapid_mode": "AC.PROGRAM_CARD.RAPID",
|
|
|
|
"eco_mode": "AC.PROGRAM_CARD.ECO_MODE",
|
|
|
|
"10_degree_heating": "PROGRAMS.AC.IOT_10_HEATING",
|
|
|
|
"self_clean": "PROGRAMS.AC.IOT_SELF_CLEAN",
|
|
|
|
"self_clean_56": "PROGRAMS.AC.IOT_SELF_CLEAN_56",
|
|
|
|
"silent_mode": "AC.PROGRAM_DETAIL.SILENT_MODE",
|
|
|
|
"mute_mode": "AC.PROGRAM_DETAIL.MUTE_MODE",
|
2023-05-07 05:40:30 +05:30
|
|
|
"extra_rinse_1": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.EXTRARINSE1",
|
|
|
|
"extra_rinse_2": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.EXTRARINSE2",
|
|
|
|
"extra_rinse_3": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.EXTRARINSE3",
|
|
|
|
"acqua_plus": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.ACQUAPLUS",
|
2023-05-13 04:50:02 +05:30
|
|
|
"auto_dose_softener": [
|
|
|
|
"WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.AUTODOSE",
|
|
|
|
"WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.SOFTENER",
|
|
|
|
],
|
|
|
|
"auto_dose_detergent": [
|
|
|
|
"WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.AUTODOSE",
|
|
|
|
"WASHING_CMD&CTRL.DASHBOARD_MENU_MORE_SETTINGS_WATER.DETERGENT",
|
|
|
|
],
|
2023-05-07 05:40:30 +05:30
|
|
|
"good_night": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.GOODNIGHT",
|
2023-05-15 22:53:53 +05:30
|
|
|
"auto_set": "REF_CMD&CTRL.MODALITIES.ECO",
|
|
|
|
"super_cool": "REF_CMD&CTRL.MODALITIES.SUPER_COOL",
|
|
|
|
"super_freeze": "REF_CMD&CTRL.MODALITIES.SUPER_FREEZE",
|
2023-05-22 00:21:20 +05:30
|
|
|
"refrigerator": "REF.NAME",
|
2023-04-23 05:31:14 +05:30
|
|
|
},
|
|
|
|
"binary_sensor": {
|
|
|
|
"door_lock": "WASHING_CMD&CTRL.CHECK_UP_RESULTS.DOOR_LOCK",
|
|
|
|
"extra_rinse_1": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.EXTRARINSE1",
|
|
|
|
"extra_rinse_2": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.EXTRARINSE2",
|
|
|
|
"extra_rinse_3": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.EXTRARINSE3",
|
|
|
|
"good_night": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.GOODNIGHT",
|
|
|
|
"anti_crease": "HDRY_CMD&CTRL.PROGRAM_CYCLE_DETAIL.ANTICREASE_TITLE",
|
2023-05-07 05:40:30 +05:30
|
|
|
"acqua_plus": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.ACQUAPLUS",
|
2023-04-23 05:31:14 +05:30
|
|
|
"spin_speed": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_MAIN_OPTIONS.SPINSPEED",
|
|
|
|
"still_hot": "IH.COILS_STATUS.STILL_HOT",
|
|
|
|
"pan_status": "IH.COILS_STATUS.PAN",
|
|
|
|
"remote_control": "OV.SUPPORT.REMOTE_CONTROL",
|
|
|
|
"rinse_aid": "DW_CMD&CTRL.MAINTENANCE.CONSUMABLE_LEVELS_ICON_RINSE_AID",
|
|
|
|
"salt_level": "DW_CMD&CTRL.MAINTENANCE.CONSUMABLE_LEVELS_ICON_SALT",
|
|
|
|
"door_open": "GLOBALS.APPLIANCE_STATUS.DOOR_OPEN",
|
2023-04-23 19:54:30 +05:30
|
|
|
"connection": "ENROLLMENT_COMMON.HEADER_NAME.STEP_APPLIANCE_CONNECTION",
|
2023-04-25 01:08:05 +05:30
|
|
|
"child_lock": "AP.FOOTER_MENU_MORE.SECURITY_LOCK_TITLE",
|
|
|
|
"on": "GLOBALS.GENERAL.ON",
|
|
|
|
"prewash": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.PREWASH",
|
2023-05-14 06:47:58 +05:30
|
|
|
"buzzer": "DW_CMD&CTRL.SETTINGS.END_CYCLE_BUZZER",
|
2023-05-15 04:08:41 +05:30
|
|
|
"holiday_mode": "REF.DASHBOARD_MENU_MORE_NOTIFICATIONS.HOLIDAY_MODE",
|
|
|
|
"auto_set": "REF_CMD&CTRL.MODALITIES.ECO",
|
|
|
|
"super_cool": "REF_CMD&CTRL.MODALITIES.SUPER_COOL",
|
|
|
|
"super_freeze": "REF_CMD&CTRL.MODALITIES.SUPER_FREEZE",
|
|
|
|
"freezer_door": ["GLOBALS.APPLIANCE_STATUS.DOOR_OPEN", "REF.ZONES.FREEZER"],
|
|
|
|
"fridge_door": ["GLOBALS.APPLIANCE_STATUS.DOOR_OPEN", "REF.ZONES.FRIDGE"],
|
2023-05-17 03:31:33 +05:30
|
|
|
"filter_replacement": "AP.MAINTENANCE.FILTER_REPLACEMENT",
|
2023-04-23 05:31:14 +05:30
|
|
|
},
|
|
|
|
"button": {
|
|
|
|
"induction_hob": "GLOBALS.APPLIANCES_NAME.IH",
|
2023-05-22 00:21:20 +05:30
|
|
|
"start_program": ["WC.SET_PROGRAM.PROGRAM", "GLOBALS.GENERAL.START_ON"],
|
|
|
|
"stop_program": ["WC.SET_PROGRAM.PROGRAM", "GLOBALS.GENERAL.STOP"],
|
2023-04-23 05:31:14 +05:30
|
|
|
},
|
|
|
|
"select": {
|
2023-04-23 19:54:30 +05:30
|
|
|
"dry_levels": "WASHING_CMD&CTRL.DRAWER_CYCLE_DRYING.TAB_LEVEL",
|
|
|
|
"dry_time": "WASHING_CMD&CTRL.DRAWER_CYCLE_DRYING.TAB_TIME",
|
2023-04-23 05:31:14 +05:30
|
|
|
"spin_speed": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_MAIN_OPTIONS.SPINSPEED",
|
|
|
|
"temperature": "IH.COMMON.TEMPERATURE",
|
|
|
|
"programs_dw": "WC.SET_PROGRAM.PROGRAM",
|
|
|
|
"programs_ih": "WC.SET_PROGRAM.PROGRAM",
|
|
|
|
"programs_ov": "WC.SET_PROGRAM.PROGRAM",
|
|
|
|
"programs_td": "WC.SET_PROGRAM.PROGRAM",
|
|
|
|
"programs_wm": "WC.SET_PROGRAM.PROGRAM",
|
2023-05-29 22:37:52 +05:30
|
|
|
"programs_ac": "WC.SET_PROGRAM.PROGRAM",
|
|
|
|
"programs_ref": "WC.SET_PROGRAM.PROGRAM",
|
2023-04-27 03:27:44 +05:30
|
|
|
"eco_pilot": "AC.PROGRAM_DETAIL.ECO_PILOT",
|
2023-05-14 06:47:58 +05:30
|
|
|
"remaining_time": "ENROLLMENT_COMMON.GENERAL.REMAINING_TIME",
|
2023-05-22 00:21:20 +05:30
|
|
|
"ref_zones": "IH.COMMON.COIL",
|
2023-04-23 05:31:14 +05:30
|
|
|
},
|
|
|
|
"sensor": {
|
2023-04-23 19:54:30 +05:30
|
|
|
"dry_levels": "WASHING_CMD&CTRL.DRAWER_CYCLE_DRYING.TAB_LEVEL",
|
|
|
|
"dry_time": "WASHING_CMD&CTRL.DRAWER_CYCLE_DRYING.TAB_TIME",
|
2023-04-23 05:31:14 +05:30
|
|
|
"power": "OV.RECIPE_DETAIL.POWER_LEVEL",
|
|
|
|
"remaining_time": "ENROLLMENT_COMMON.GENERAL.REMAINING_TIME",
|
|
|
|
"temperature": "IH.COMMON.TEMPERATURE",
|
|
|
|
"water_efficiency": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_RESULT.WATER_EFFICIENCY",
|
|
|
|
"water_saving": "STATISTICS.SMART_AI_CYCLE.WATER_SAVING",
|
|
|
|
"duration": "WASHING_CMD&CTRL.DRAWER_PROGRAM_FILTERS.DURATION",
|
|
|
|
"target_temperature": "IH.COOKING_DETAIL.TEMPERATURE_TARGETING",
|
|
|
|
"spin_speed": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_MAIN_OPTIONS.SPINSPEED",
|
|
|
|
"steam_leve": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_MAIN_OPTIONS.STEAM_LEVEL",
|
|
|
|
"dirt_level": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_MAIN_OPTIONS.DIRTY_LEVEL",
|
|
|
|
"program_phases_wm": "WASHING_CMD&CTRL.STATISTICS_GRAPHIC_INSTANT_CONSUMPTION.PHASE",
|
|
|
|
"program_phases_td": "WASHING_CMD&CTRL.STATISTICS_GRAPHIC_INSTANT_CONSUMPTION.PHASE",
|
|
|
|
"program_phases_dw": "WASHING_CMD&CTRL.STATISTICS_GRAPHIC_INSTANT_CONSUMPTION.PHASE",
|
2023-04-23 19:54:30 +05:30
|
|
|
"delay_time": "HINTS.TIPS_TIME_ENERGY_SAVING.TIPS_USE_AT_NIGHT_TITLE",
|
|
|
|
"suggested_load": "WASHING_CMD&CTRL.DRAWER_PROGRAM_FILTERS.LOAD_CAPACITY",
|
|
|
|
"energy_label": "WASHING_CMD&CTRL.DRAWER_PROGRAM_FILTERS.ENERGY_EFFICIENCY",
|
|
|
|
"det_dust": "HUBS.WIDGET.STAINS_WIDGET.STAINS.SUGGESTED_DET_DUST",
|
|
|
|
"det_liquid": "HUBS.WIDGET.STAINS_WIDGET.STAINS.SUGGESTED_DET_LIQUID",
|
2023-04-25 01:08:05 +05:30
|
|
|
"errors": "ROBOT_CMD&CTRL.PHASE_ERROR.TITLE",
|
|
|
|
"programs": "OV.TABS.CURRENT_PROGRAM",
|
2023-05-10 21:43:05 +05:30
|
|
|
"room_temperature": "REF.SMART_DRINK_ASSISTANT.AMBIENT",
|
|
|
|
"humidity": "AP.TITLES.HUMIDITY",
|
2023-04-25 01:08:05 +05:30
|
|
|
"cycles_total": [
|
|
|
|
"WASHING_CMD&CTRL.GENERAL.CYCLES",
|
|
|
|
"WC.VIRTUAL_WINE_STATS_COUNTRY.TOTAL",
|
|
|
|
],
|
|
|
|
"energy_total": [
|
|
|
|
"MISE.ENERGY_CONSUMPTION.TITLE",
|
|
|
|
"WC.VIRTUAL_WINE_STATS_COUNTRY.TOTAL",
|
|
|
|
],
|
|
|
|
"water_total": [
|
|
|
|
"WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_RESULT.WATER_EFFICIENCY",
|
|
|
|
"WC.VIRTUAL_WINE_STATS_COUNTRY.TOTAL",
|
|
|
|
],
|
|
|
|
"energy_current": [
|
|
|
|
"MISE.ENERGY_CONSUMPTION.TITLE",
|
|
|
|
"CUBE90_GLOBAL.GENERAL.CURRENT",
|
|
|
|
],
|
|
|
|
"water_current": [
|
|
|
|
"WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_RESULT.WATER_EFFICIENCY",
|
|
|
|
"CUBE90_GLOBAL.GENERAL.CURRENT",
|
|
|
|
],
|
2023-05-15 22:53:53 +05:30
|
|
|
"freezer_temp": "REF_CMD&CTRL.TEMPERATURE_DRAWER_FREEZER.FREEZER_TEMPERATURE_TITLE",
|
|
|
|
"fridge_temp": "REF_CMD&CTRL.TEMPERATURE_DRAWER_FRIDGE.FRIDGE_TEMPERATURE_TITLE",
|
2023-05-29 22:37:52 +05:30
|
|
|
"programs_dw": "WC.SET_PROGRAM.PROGRAM",
|
|
|
|
"programs_ih": "WC.SET_PROGRAM.PROGRAM",
|
|
|
|
"programs_ov": "WC.SET_PROGRAM.PROGRAM",
|
|
|
|
"programs_td": "WC.SET_PROGRAM.PROGRAM",
|
|
|
|
"programs_wm": "WC.SET_PROGRAM.PROGRAM",
|
|
|
|
"programs_ac": "WC.SET_PROGRAM.PROGRAM",
|
|
|
|
"programs_ref": "WC.SET_PROGRAM.PROGRAM",
|
2023-04-23 05:31:14 +05:30
|
|
|
},
|
|
|
|
"number": {
|
|
|
|
"power_management": "HINTS.COOKING_WITH_INDUCTION.POWER_MANAGEMENT",
|
|
|
|
"temperature": "IH.COMMON.TEMPERATURE",
|
2023-04-23 19:54:30 +05:30
|
|
|
"delay_time": "HINTS.TIPS_TIME_ENERGY_SAVING.TIPS_USE_AT_NIGHT_TITLE",
|
2023-04-23 05:31:14 +05:30
|
|
|
"water_hard": "WASHING_CMD&CTRL.DASHBOARD_MENU_MORE_SETTINGS_WATER.TITLE",
|
|
|
|
"program_duration": "OV.PROGRAM_DETAIL.PROGRAM_DURATION",
|
|
|
|
"target_temperature": "IH.COOKING_DETAIL.TEMPERATURE_TARGETING",
|
|
|
|
"rinse_iterations": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL.DRAWER_HEADER_RINSE",
|
|
|
|
"wash_time": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL.WASHING_TIME",
|
2023-04-23 19:54:30 +05:30
|
|
|
"dry_time": "WASHING_CMD&CTRL.DRAWER_CYCLE_DRYING.TAB_TIME",
|
2023-05-07 05:40:30 +05:30
|
|
|
"steam_level": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_MAIN_OPTIONS.STEAM_LEVEL",
|
2023-05-15 04:08:41 +05:30
|
|
|
"freezer_temp_sel": ["OV.COMMON.GOAL_TEMPERATURE", "REF.ZONES.FREEZER"],
|
|
|
|
"fridge_temp_sel": ["OV.COMMON.GOAL_TEMPERATURE", "REF.ZONES.FRIDGE"],
|
2023-04-23 05:31:14 +05:30
|
|
|
},
|
2023-05-28 11:20:59 +05:30
|
|
|
"climate": {
|
|
|
|
"air_conditioner": "GLOBALS.APPLIANCES_NAME.AC",
|
|
|
|
"fridge": "REF.ZONES.FRIDGE",
|
|
|
|
"freezer": "REF.ZONES.FREEZER",
|
2023-05-28 21:08:56 +05:30
|
|
|
"oven": "GLOBALS.APPLIANCES_NAME.OV",
|
2023-05-28 11:20:59 +05:30
|
|
|
},
|
2023-06-09 09:26:52 +05:30
|
|
|
"fan": {"air_extraction": "HO.DASHBOARD.AIR_EXTRACTION_TITLE"},
|
2023-04-23 05:31:14 +05:30
|
|
|
}
|
|
|
|
|
2023-04-22 06:17:55 +05:30
|
|
|
|
|
|
|
async def check_translation_files(translations):
|
2023-05-07 17:17:19 +05:30
|
|
|
for language in const.LANGUAGES:
|
2023-04-22 06:17:55 +05:30
|
|
|
path = translations / f"{language}.json"
|
|
|
|
if not path.is_file():
|
|
|
|
async with HonAPI(anonymous=True) as hon:
|
|
|
|
keys = await hon.translation_keys(language)
|
|
|
|
save_json(path, keys)
|
|
|
|
|
|
|
|
|
|
|
|
def load_hon_translations():
|
|
|
|
translations = Path(__file__).parent / "translations"
|
|
|
|
translations.mkdir(exist_ok=True)
|
|
|
|
asyncio.run(check_translation_files(translations))
|
|
|
|
return {f.stem: f for f in translations.glob("*.json")}
|
|
|
|
|
|
|
|
|
|
|
|
def load_hass_translations():
|
|
|
|
translations = (
|
|
|
|
Path(__file__).parent.parent / "custom_components" / "hon" / "translations"
|
|
|
|
)
|
|
|
|
return {f.stem: f for f in translations.glob("*.json")}
|
|
|
|
|
|
|
|
|
|
|
|
def load_json(path):
|
|
|
|
if path:
|
|
|
|
with open(path, "r") as file:
|
|
|
|
return json.loads(file.read())
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
|
|
def save_json(path, keys):
|
|
|
|
with open(path, "w") as json_file:
|
2023-04-25 01:37:58 +05:30
|
|
|
json_file.write(json.dumps(keys, indent=4, ensure_ascii=False))
|
2023-04-22 06:17:55 +05:30
|
|
|
|
|
|
|
|
|
|
|
def load_key(full_key, json_data, fallback=None):
|
2023-04-25 01:08:05 +05:30
|
|
|
if isinstance(full_key, list):
|
|
|
|
return " ".join(
|
|
|
|
[load_key(item, json_data, fallback).strip() for item in full_key]
|
|
|
|
)
|
2023-04-22 06:17:55 +05:30
|
|
|
result = json_data.copy()
|
|
|
|
for key in full_key.split("."):
|
|
|
|
result = result.get(key, {})
|
|
|
|
if not result and fallback:
|
|
|
|
return load_key(full_key, fallback)
|
2023-05-07 17:17:19 +05:30
|
|
|
return result or full_key
|
2023-04-22 06:17:55 +05:30
|
|
|
|
|
|
|
|
2023-04-23 00:49:32 +05:30
|
|
|
def load_keys(full_key, json_data):
|
2023-04-25 01:37:58 +05:30
|
|
|
blacklist = ["description", "desctiption", "_recipe_", "_guided_"]
|
2023-04-23 00:49:32 +05:30
|
|
|
first, last = full_key.split(".")
|
|
|
|
data = json_data.get(first, {}).get(last, {})
|
|
|
|
return {
|
|
|
|
key.lower(): value
|
|
|
|
for key, value in data.items()
|
|
|
|
if not any(b in key.lower() for b in blacklist)
|
2023-04-23 01:12:16 +05:30
|
|
|
and re.findall("^[a-z0-9-_]+$", key.lower())
|
2023-04-23 00:49:32 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-04-23 02:39:57 +05:30
|
|
|
def add_data(old, original, fallback, data, name, entity="sensor"):
|
|
|
|
sensor = old.setdefault("entity", {}).setdefault(entity, {})
|
|
|
|
for number, phase in data.items():
|
|
|
|
state = sensor.setdefault(name, {}).setdefault("state", {})
|
|
|
|
if key := load_key(phase, original, fallback):
|
|
|
|
state[str(number)] = key
|
|
|
|
|
|
|
|
|
2023-04-25 02:10:20 +05:30
|
|
|
def translate_login(old, *args):
|
|
|
|
login = old.setdefault("config", {}).setdefault("step", {}).setdefault("user", {})
|
|
|
|
login["description"] = load_key("CUBE90_ALEXA.HAIER_SMART_SKILLS.STEP_2", *args)
|
|
|
|
login.setdefault("data", {})["email"] = load_key(
|
|
|
|
"PET.EDIT_PET_PROFESSIONALS.EMAIL", *args
|
|
|
|
)
|
|
|
|
login["data"]["password"] = load_key("CUBE90_GLOBAL.GENERAL.PASSWORD", *args)
|
|
|
|
|
|
|
|
|
2023-04-22 06:17:55 +05:30
|
|
|
def main():
|
|
|
|
hass = load_hass_translations()
|
|
|
|
hon = load_hon_translations()
|
|
|
|
base_path = Path(__file__).parent.parent / "custom_components/hon/translations"
|
|
|
|
fallback = load_json(hon.get("en", ""))
|
2023-05-07 17:17:19 +05:30
|
|
|
for language in const.LANGUAGES:
|
2023-04-22 06:17:55 +05:30
|
|
|
original = load_json(hon.get(language, ""))
|
|
|
|
old = load_json(hass.get(language, ""))
|
|
|
|
for name, data in SENSOR.items():
|
2023-04-23 02:39:57 +05:30
|
|
|
add_data(old, original, fallback, data, name)
|
|
|
|
for name, data in SELECT.items():
|
|
|
|
add_data(old, original, fallback, data, name, "select")
|
2023-05-07 17:17:19 +05:30
|
|
|
for entity, data in PROGRAMS.items():
|
|
|
|
for name, program in data.items():
|
|
|
|
select = old.setdefault("entity", {}).setdefault(entity, {})
|
|
|
|
select.setdefault(name, {})["state"] = load_keys(program, original)
|
2023-04-23 05:31:14 +05:30
|
|
|
for entity, data in NAMES.items():
|
|
|
|
for name, key in data.items():
|
|
|
|
select = old.setdefault("entity", {}).setdefault(entity, {})
|
|
|
|
select.setdefault(name, {})["name"] = load_key(key, original, fallback)
|
2023-05-28 11:20:59 +05:30
|
|
|
for name, modes in CLIMATE.items():
|
|
|
|
climate = old.setdefault("entity", {}).setdefault("climate", {})
|
|
|
|
attr = climate.setdefault(name, {}).setdefault("state_attributes", {})
|
|
|
|
for mode, data in modes.items():
|
|
|
|
mode_name = load_key(data["name"], original, fallback)
|
|
|
|
attr.setdefault(mode, {})["name"] = mode_name
|
2023-05-28 21:08:56 +05:30
|
|
|
if isinstance(data["state"], dict):
|
|
|
|
for state, key in data["state"].items():
|
|
|
|
mode_state = load_key(key, original, fallback)
|
|
|
|
attr[mode].setdefault("state", {})[state] = mode_state
|
|
|
|
else:
|
|
|
|
attr[mode]["state"] = load_keys(data["state"], original)
|
|
|
|
|
2023-04-25 02:10:20 +05:30
|
|
|
translate_login(old, original, fallback)
|
2023-04-22 06:17:55 +05:30
|
|
|
save_json(base_path / f"{language}.json", old)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|