diff --git a/custom_components/drivvo/__init__.py b/custom_components/drivvo/__init__.py index aa09d7e..711a977 100644 --- a/custom_components/drivvo/__init__.py +++ b/custom_components/drivvo/__init__.py @@ -154,4 +154,4 @@ def sort_by_key(list): return data _LOGGER.debug("API Response Data Vehicle - %s: %s", info, response) - return False + return None diff --git a/custom_components/drivvo/config_flow.py b/custom_components/drivvo/config_flow.py index 44d0ed7..057df2b 100644 --- a/custom_components/drivvo/config_flow.py +++ b/custom_components/drivvo/config_flow.py @@ -9,7 +9,11 @@ from homeassistant.data_entry_flow import FlowResult import homeassistant.helpers.config_validation as cv from homeassistant.helpers import device_registry as dr -from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue +from homeassistant.helpers.issue_registry import ( + IssueSeverity, + async_create_issue, + async_delete_issue, +) from . import auth, get_vehicles from .const import ( @@ -63,6 +67,11 @@ async def async_step_init(self, user_input: dict[str, Any]) -> FlowResult: device_id=device.id, remove_config_entry_id=self.config_entry.entry_id, ) + async_delete_issue( + self.hass, + DOMAIN, + f"{vehicle}_vehicle_non_existent", + ) _LOGGER.debug("Device %s (%s) removed", device.name, device.id) self.hass.config_entries.async_update_entry( diff --git a/custom_components/drivvo/sensor.py b/custom_components/drivvo/sensor.py index 3fb92e0..52a31ab 100755 --- a/custom_components/drivvo/sensor.py +++ b/custom_components/drivvo/sensor.py @@ -75,6 +75,18 @@ async def async_setup_entry( ], update_before_add=True, ) + else: + async_create_issue( + hass, + DOMAIN, + f"{vehicle}_vehicle_non_existent", + is_fixable=False, + severity=IssueSeverity.WARNING, + translation_key="vehicle_non_existent", + translation_placeholders={ + "vehicle": vehicle, + }, + ) async def async_setup_platform( diff --git a/custom_components/drivvo/translations/en.json b/custom_components/drivvo/translations/en.json index d215d06..1d51003 100644 --- a/custom_components/drivvo/translations/en.json +++ b/custom_components/drivvo/translations/en.json @@ -37,6 +37,10 @@ "import_already_configured": { "title": "Account {email} already exists", "description": "Account {email} already exists and therefore was not imported.\n\nYou can remove the configuration from your `configuration.yaml` file." + }, + "vehicle_non_existent": { + "title": "The vehicle ID {vehicle} does not exist in the Drivvo app", + "description": "The vehicle ID {vehicle} does not exist, it may have been deleted.\n\nGo to the integration configuration options and remove the vehicle." } }, "options": { diff --git a/custom_components/drivvo/translations/pt-BR.json b/custom_components/drivvo/translations/pt-BR.json index dfa688b..5653d21 100644 --- a/custom_components/drivvo/translations/pt-BR.json +++ b/custom_components/drivvo/translations/pt-BR.json @@ -37,6 +37,10 @@ "import_already_configured": { "title": "A configuração da conta {email} já existe", "description": "A configuração da conta {email} já existe e por isso não foi importada.\n\nVocê pode remover a configuração do seu arquivo `configuration.yaml`." + }, + "vehicle_non_existent": { + "title": "O veículo ID {vehicle} não existe no aplicativo Drivvo", + "description": "O veículo {vehicle} não existe, ele pode ter sido excluído.\n\nAcesse as opções de configuração da integração e remova o veículo." } }, "options": {