From d0993ff32cb690f55269aa61defc026c5558dca5 Mon Sep 17 00:00:00 2001 From: Christoph Dahlen Date: Wed, 20 Dec 2023 18:49:49 +0100 Subject: [PATCH 1/9] Update __init__.py * add CONFIG_SCHEMA as required by hassfest --- custom_components/polestar_api/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/custom_components/polestar_api/__init__.py b/custom_components/polestar_api/__init__.py index 09cca9c..c888d73 100644 --- a/custom_components/polestar_api/__init__.py +++ b/custom_components/polestar_api/__init__.py @@ -28,6 +28,8 @@ Platform.SENSOR, ] +CONFIG_SCHEMA = cv.removed(DOMAIN, raise_if_present=False) + _LOGGER = logging.getLogger(__name__) From 90087a798d75f01640fb7919b9225d3f8809433f Mon Sep 17 00:00:00 2001 From: Christoph Dahlen Date: Wed, 20 Dec 2023 18:51:57 +0100 Subject: [PATCH 2/9] Update manifest.json * change order of entries * remove version entry * turn "name" into a friendly name --- custom_components/polestar_api/manifest.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_components/polestar_api/manifest.json b/custom_components/polestar_api/manifest.json index 6100b11..d4c518c 100644 --- a/custom_components/polestar_api/manifest.json +++ b/custom_components/polestar_api/manifest.json @@ -1,9 +1,9 @@ { "domain": "polestar_api", - "name": "polestar_api", - "version": "0.0.1", + "name": "Polestar API", + "codeowners": ["@leeyuentuen"], "config_flow": true, - "documentation": "https://github.com/leeyuentuen/polestar_api", "dependencies": [], - "codeowners": ["leeyuentuen"] + "documentation": "https://github.com/leeyuentuen/polestar_api", + "iot_class": "cloud_polling" } From 2d6569a1e958889e0275a26bc06d2bc3014601c9 Mon Sep 17 00:00:00 2001 From: Christoph Dahlen Date: Wed, 20 Dec 2023 18:52:39 +0100 Subject: [PATCH 3/9] Create hassfest.yml --- .github/workflows/hassfest.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/hassfest.yml diff --git a/.github/workflows/hassfest.yml b/.github/workflows/hassfest.yml new file mode 100644 index 0000000..82aefa7 --- /dev/null +++ b/.github/workflows/hassfest.yml @@ -0,0 +1,15 @@ +name: Validate with hassfest + +on: + push: + pull_request: + schedule: + - cron: "0 0 * * *" + +jobs: + validate: + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v3" + - uses: home-assistant/actions/hassfest@master + From a3ac846b900d42d612a651d95fc794a100aeee24 Mon Sep 17 00:00:00 2001 From: Christoph Dahlen Date: Wed, 20 Dec 2023 18:55:20 +0100 Subject: [PATCH 4/9] Update manifest.json * return of the "version" attribute --- custom_components/polestar_api/manifest.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_components/polestar_api/manifest.json b/custom_components/polestar_api/manifest.json index d4c518c..a1c8da3 100644 --- a/custom_components/polestar_api/manifest.json +++ b/custom_components/polestar_api/manifest.json @@ -5,5 +5,6 @@ "config_flow": true, "dependencies": [], "documentation": "https://github.com/leeyuentuen/polestar_api", - "iot_class": "cloud_polling" + "iot_class": "cloud_polling", + "version": "1.0.4" } From 367fc0834e8232ce6ead1ff3846927c0ea8f685a Mon Sep 17 00:00:00 2001 From: Christoph Dahlen Date: Wed, 20 Dec 2023 19:05:34 +0100 Subject: [PATCH 5/9] Prepare translation * added first translation key * reference translation key in en and de translation --- custom_components/polestar_api/sensor.py | 1 + .../polestar_api/translations/de.json | 7 +++ .../polestar_api/translations/en.json | 43 +++++++++++-------- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/custom_components/polestar_api/sensor.py b/custom_components/polestar_api/sensor.py index ed862a4..4ea5707 100644 --- a/custom_components/polestar_api/sensor.py +++ b/custom_components/polestar_api/sensor.py @@ -93,6 +93,7 @@ class PolestarSensorDescription( PolestarSensorDescription( key="estimate_distance_to_empty_km", name="Distance km Remaining", + translation_key="polestar_api_estimate_distance_to_empty_km", icon="mdi:map-marker-distance", query="getBatteryData", field_name="estimatedDistanceToEmptyKm", diff --git a/custom_components/polestar_api/translations/de.json b/custom_components/polestar_api/translations/de.json index d990d4c..9b0d1b9 100644 --- a/custom_components/polestar_api/translations/de.json +++ b/custom_components/polestar_api/translations/de.json @@ -18,5 +18,12 @@ "already_configured": "Die Polestar API ist bereits konfiguriert", "no_token": "Kein Token in der Antwort gefunden. Bitte überprüfe Deine Anmeldeinformationen." } + }, + "entity": { + "sensor": { + "polestar_api_estimate_distance_to_empty_km": { + "name": "Reichweite" + } + } } } \ No newline at end of file diff --git a/custom_components/polestar_api/translations/en.json b/custom_components/polestar_api/translations/en.json index 1a2104f..8ec0462 100644 --- a/custom_components/polestar_api/translations/en.json +++ b/custom_components/polestar_api/translations/en.json @@ -1,22 +1,29 @@ { - "config": { - "step": { - "user": { - "title": "Configure Polestar EV", - "description": "Enter Authentication of Polestar EV", - "data": { - "name": "Friendly name", - "username": "Username", - "password": "Password", - "vin": "VIN" + "config": { + "step": { + "user": { + "title": "Configure Polestar EV", + "description": "Enter Authentication of Polestar EV", + "data": { + "name": "Friendly name", + "username": "Username", + "password": "Password", + "vin": "VIN" + } + } + }, + "abort": { + "api_timeout": "Timeout connecting to the api.", + "api_failed": "Unexpected error creating api.", + "already_configured": "Polestar API is already configured", + "no_token": "No token found in response. Please check your credentials." } - } }, - "abort": { - "api_timeout": "Timeout connecting to the api.", - "api_failed": "Unexpected error creating api.", - "already_configured": "Polestar API is already configured", - "no_token": "No token found in response. Please check your credentials." + "entity": { + "sensor": { + "polestar_api_estimate_distance_to_empty_km": { + "name": "Distance km Remaining" + } + } } - } -} +} \ No newline at end of file From 83e49a9779e3857fbc86c42cc1f184c957ac8789 Mon Sep 17 00:00:00 2001 From: Christoph Dahlen Date: Wed, 20 Dec 2023 19:18:48 +0100 Subject: [PATCH 6/9] Update __init__.py * import config valdiation from HA helpers. --- custom_components/polestar_api/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/polestar_api/__init__.py b/custom_components/polestar_api/__init__.py index c888d73..a93dfc2 100644 --- a/custom_components/polestar_api/__init__.py +++ b/custom_components/polestar_api/__init__.py @@ -17,7 +17,7 @@ ) from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady - +from homeassistant.helpers import config_validation as cv from .const import ( DOMAIN, From 75154b9e00c1e466c3a92e20b470c241e6b10c5a Mon Sep 17 00:00:00 2001 From: Christoph Dahlen Date: Fri, 22 Dec 2023 13:22:08 +0100 Subject: [PATCH 7/9] Update sensor.py * remove translation_key --- custom_components/polestar_api/sensor.py | 1 - 1 file changed, 1 deletion(-) diff --git a/custom_components/polestar_api/sensor.py b/custom_components/polestar_api/sensor.py index 4ea5707..ed862a4 100644 --- a/custom_components/polestar_api/sensor.py +++ b/custom_components/polestar_api/sensor.py @@ -93,7 +93,6 @@ class PolestarSensorDescription( PolestarSensorDescription( key="estimate_distance_to_empty_km", name="Distance km Remaining", - translation_key="polestar_api_estimate_distance_to_empty_km", icon="mdi:map-marker-distance", query="getBatteryData", field_name="estimatedDistanceToEmptyKm", From 6dca3ced53a963ca97451e5a1ec27afb83d56c41 Mon Sep 17 00:00:00 2001 From: Christoph Dahlen Date: Fri, 22 Dec 2023 13:22:33 +0100 Subject: [PATCH 8/9] Update de.json * remove translation entry for entity name. --- custom_components/polestar_api/translations/de.json | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/custom_components/polestar_api/translations/de.json b/custom_components/polestar_api/translations/de.json index 9b0d1b9..37b4aaf 100644 --- a/custom_components/polestar_api/translations/de.json +++ b/custom_components/polestar_api/translations/de.json @@ -18,12 +18,5 @@ "already_configured": "Die Polestar API ist bereits konfiguriert", "no_token": "Kein Token in der Antwort gefunden. Bitte überprüfe Deine Anmeldeinformationen." } - }, - "entity": { - "sensor": { - "polestar_api_estimate_distance_to_empty_km": { - "name": "Reichweite" - } - } } -} \ No newline at end of file +} From 9f17f1f21713d11cf36e6e8627dab5038898292b Mon Sep 17 00:00:00 2001 From: Christoph Dahlen Date: Fri, 22 Dec 2023 13:23:49 +0100 Subject: [PATCH 9/9] Update manifest.json * bump version number --- custom_components/polestar_api/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/polestar_api/manifest.json b/custom_components/polestar_api/manifest.json index a1c8da3..66d8c97 100644 --- a/custom_components/polestar_api/manifest.json +++ b/custom_components/polestar_api/manifest.json @@ -6,5 +6,5 @@ "dependencies": [], "documentation": "https://github.com/leeyuentuen/polestar_api", "iot_class": "cloud_polling", - "version": "1.0.4" + "version": "1.0.5" }