From 8b3205f3d473ea055d18677e55afbb9efbc950b7 Mon Sep 17 00:00:00 2001 From: Elad Bar Date: Thu, 13 Jul 2023 22:30:54 +0300 Subject: [PATCH] Fix vacuum entity name and add integration (config) error handling --- CHANGELOG.md | 5 ++ .../aqua_temp/common/entity_descriptions.py | 4 +- custom_components/aqua_temp/config_flow.py | 3 ++ .../managers/aqua_temp_config_manager.py | 52 ------------------- custom_components/aqua_temp/manifest.json | 2 +- custom_components/aqua_temp/strings.json | 2 +- .../aqua_temp/translations/en.json | 2 +- 7 files changed, 12 insertions(+), 58 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58a6a93..d6f5531 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## v3.0.21 + +- Fix vacuum entity name +- Fix add integration (config) error handling + ## v3.0.20 - Fix error handling when performing an action diff --git a/custom_components/aqua_temp/common/entity_descriptions.py b/custom_components/aqua_temp/common/entity_descriptions.py index 9dd8674..72cbf96 100644 --- a/custom_components/aqua_temp/common/entity_descriptions.py +++ b/custom_components/aqua_temp/common/entity_descriptions.py @@ -85,7 +85,5 @@ class AquaTempSelectEntityDescription( device_class=BinarySensorDeviceClass.CONNECTIVITY, translation_key="device_status", ), - AquaTempClimateEntityDescription( - key="Mode", name="HVAC Mode", translation_key="mode" - ), + AquaTempClimateEntityDescription(key="Mode", translation_key="mode"), ] diff --git a/custom_components/aqua_temp/config_flow.py b/custom_components/aqua_temp/config_flow.py index b3e020e..0e27d6e 100644 --- a/custom_components/aqua_temp/config_flow.py +++ b/custom_components/aqua_temp/config_flow.py @@ -51,6 +51,8 @@ async def async_step_user(self, user_input=None): config_manager = AquaTempConfigManager(self.hass, None) config_manager.update_credentials(user_input) + await config_manager.initialize() + api = AquaTempAPI(self.hass, config_manager) await api.initialize(True) @@ -58,6 +60,7 @@ async def async_step_user(self, user_input=None): _LOGGER.debug("User inputs are valid") return self.async_create_entry(title=DEFAULT_NAME, data=user_input) + except LoginError: errors = {"base": "invalid_credentials"} diff --git a/custom_components/aqua_temp/managers/aqua_temp_config_manager.py b/custom_components/aqua_temp/managers/aqua_temp_config_manager.py index 12bd0c4..a3a84c9 100644 --- a/custom_components/aqua_temp/managers/aqua_temp_config_manager.py +++ b/custom_components/aqua_temp/managers/aqua_temp_config_manager.py @@ -2,7 +2,6 @@ import json import logging import os -import sys from homeassistant.config_entries import STORAGE_VERSION, ConfigEntry from homeassistant.const import ( @@ -16,7 +15,6 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers import translation from homeassistant.helpers.entity import DeviceInfo -from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.json import JSONEncoder from homeassistant.helpers.storage import Store @@ -115,8 +113,6 @@ async def initialize(self): self._hass, self._hass.config.language, "entity", {DOMAIN} ) - _LOGGER.debug(f"Translations loaded, Data: {json.dumps(self._translations)}") - for key in local_data: value = local_data[key] @@ -147,8 +143,6 @@ def get_entity_name( else f"{device_name} {translated_name}" ) - entity_name = f"{device_name} {translated_name}" - return entity_name def update_credentials(self, entry_data: dict): @@ -239,39 +233,6 @@ def get_hvac_reverse_mapping(self, device_code, hvac_mode) -> str: return result - def async_handle_discovered_device( - self, - device_code: str, - coordinator, - platform: Platform, - entity_initializer, - async_add_entities: AddEntitiesCallback, - ): - try: - entities = [] - - entity_descriptions = self.get_entity_descriptions(device_code) - - for entity_description in entity_descriptions: - if entity_description.platform == platform: - entity = entity_initializer( - device_code, entity_description.key, coordinator - ) - - entities.append(entity) - - _LOGGER.debug(f"Setting up {platform} entities: {entities}") - - async_add_entities(entities, True) - - except Exception as ex: - exc_type, exc_obj, tb = sys.exc_info() - line_number = tb.tb_lineno - - _LOGGER.error( - f"Failed to initialize {platform}, Error: {ex}, Line: {line_number}" - ) - def get_api_param(self, param: APIParam): result = self._api_config.get(str(param)) @@ -316,19 +277,6 @@ async def _save(self): await self._store.async_save(data) - def find_entity_description(self, device_code: str, key: str, platform: Platform): - entity_descriptions = self.get_entity_descriptions(device_code) - - entity_descriptions = [ - entity_description - for entity_description in entity_descriptions - if entity_description.platform == platform and entity_description.key == key - ] - - result = None if len(entity_descriptions) == 0 else entity_descriptions[0] - - return result - def _load_entity_descriptions(self, product_id: str): entities = copy(DEFAULT_ENTITY_DESCRIPTIONS) file_path = self._get_product_file( diff --git a/custom_components/aqua_temp/manifest.json b/custom_components/aqua_temp/manifest.json index 9cab19b..0849afc 100644 --- a/custom_components/aqua_temp/manifest.json +++ b/custom_components/aqua_temp/manifest.json @@ -8,5 +8,5 @@ "iot_class": "cloud_polling", "issue_tracker": "https://github.com/radical-squared/aquatemp/issues", "requirements": [], - "version": "3.0.20" + "version": "3.0.21" } diff --git a/custom_components/aqua_temp/strings.json b/custom_components/aqua_temp/strings.json index ba07fc2..eee5198 100644 --- a/custom_components/aqua_temp/strings.json +++ b/custom_components/aqua_temp/strings.json @@ -38,7 +38,7 @@ }, "climate": { "mode": { - "name": "HVAC Mode" + "name": "" } }, "select": { diff --git a/custom_components/aqua_temp/translations/en.json b/custom_components/aqua_temp/translations/en.json index ba07fc2..eee5198 100644 --- a/custom_components/aqua_temp/translations/en.json +++ b/custom_components/aqua_temp/translations/en.json @@ -38,7 +38,7 @@ }, "climate": { "mode": { - "name": "HVAC Mode" + "name": "" } }, "select": {