Skip to content

Commit

Permalink
Fix vacuum entity name and add integration (config) error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
elad-bar committed Jul 13, 2023
1 parent 44efb02 commit 8b3205f
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 58 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions custom_components/aqua_temp/common/entity_descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
]
3 changes: 3 additions & 0 deletions custom_components/aqua_temp/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,16 @@ 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)

_LOGGER.debug("User inputs are valid")

return self.async_create_entry(title=DEFAULT_NAME, data=user_input)

except LoginError:
errors = {"base": "invalid_credentials"}

Expand Down
52 changes: 0 additions & 52 deletions custom_components/aqua_temp/managers/aqua_temp_config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import json
import logging
import os
import sys

from homeassistant.config_entries import STORAGE_VERSION, ConfigEntry
from homeassistant.const import (
Expand All @@ -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

Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion custom_components/aqua_temp/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion custom_components/aqua_temp/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"climate": {
"mode": {
"name": "HVAC Mode"
"name": ""
}
},
"select": {
Expand Down
2 changes: 1 addition & 1 deletion custom_components/aqua_temp/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"climate": {
"mode": {
"name": "HVAC Mode"
"name": ""
}
},
"select": {
Expand Down

0 comments on commit 8b3205f

Please sign in to comment.