From 87b5d24f1f119c1d2c07081f823d5989af38df88 Mon Sep 17 00:00:00 2001 From: Tuen Lee Date: Tue, 9 Jan 2024 20:33:32 +0000 Subject: [PATCH] fix #70 translation_key bug that not translate the values --- custom_components/polestar_api/sensor.py | 4 +-- custom_components/polestar_api/strings.json | 5 ++- .../polestar_api/translations/en.json | 34 +++++++------------ .../polestar_api/translations/nl.json | 28 ++++++--------- 4 files changed, 27 insertions(+), 44 deletions(-) diff --git a/custom_components/polestar_api/sensor.py b/custom_components/polestar_api/sensor.py index 59d67b0..80d2ab6 100644 --- a/custom_components/polestar_api/sensor.py +++ b/custom_components/polestar_api/sensor.py @@ -416,7 +416,7 @@ class PolestarSensor(PolestarEntity, SensorEntity): """Representation of a Polestar Sensor.""" entity_description: PolestarSensorDescription - attr_has_entity_name = True + _attr_has_entity_name = True def __init__(self, device: Polestar, @@ -430,7 +430,7 @@ def __init__(self, #self._attr_name = f"{description.name}" self._attr_unique_id = f"polestar_{unique_id}-{description.key}" self.entity_description = description - self.attr_translation_key = f"polestar_{description.key}" + self._attr_translation_key = f"polestar_{description.key}" self._attr_native_unit_of_measurement = description.native_unit_of_measurement self._sensor_data = None self._attr_unit_of_measurement = description.native_unit_of_measurement diff --git a/custom_components/polestar_api/strings.json b/custom_components/polestar_api/strings.json index 1a2104f..28dcfcf 100644 --- a/custom_components/polestar_api/strings.json +++ b/custom_components/polestar_api/strings.json @@ -6,9 +6,8 @@ "description": "Enter Authentication of Polestar EV", "data": { "name": "Friendly name", - "username": "Username", - "password": "Password", - "vin": "VIN" + "username": "Username OG", + "password": "Password OG" } } }, diff --git a/custom_components/polestar_api/translations/en.json b/custom_components/polestar_api/translations/en.json index a689961..3bbae8b 100644 --- a/custom_components/polestar_api/translations/en.json +++ b/custom_components/polestar_api/translations/en.json @@ -5,10 +5,8 @@ "title": "Configure Polestar EV", "description": "Enter Authentication of Polestar EV", "data": { - "name": "Friendly name", "username": "Username", - "password": "Password", - "vin": "VIN" + "password": "Password" } } }, @@ -21,16 +19,13 @@ }, "entity": { "sensor": { - "polestar_estimate_distance_to_empty_miles": { - "name": "Distance Miles Remaining" + "polestar_estimate_range": { + "name": "Range" }, - "polestar_estimate_distance_to_empty_km": { - "name": "Distance km Remaining" - }, - "polestar_current_odometer_meters": { + "polestar_current_odometer": { "name": "Odometer" }, - "polestar_average_speed_km_per_hour": { + "polestar_average_speed": { "name": "Average Speed" }, "polestar_current_trip_meter_automatic": { @@ -42,23 +37,23 @@ "polestar_battery_charge_level": { "name": "Battery Charge Level" }, - "polestar_estimated_charging_time_to_full_minutes": { - "name": "Estimated Charging Time to Full Minutes" + "polestar_estimated_charging_time_to_full": { + "name": "Charging Time" }, "polestar_charging_status": { "name": "Charging Status" }, - "polestar_charging_power_watts": { - "name": "Charging Power Watts" + "polestar_charging_power": { + "name": "Charging Power" }, - "polestar_charging_current_amps": { - "name": "Charging Current Amps" + "polestar_charging_current": { + "name": "Charging Current" }, "polestar_charger_connection_status": { "name": "Charger Connection Status" }, - "polestar_average_energy_consumption_kwh_per_100_km": { - "name": "Average Energy Consumption kWh/100km" + "polestar_average_energy_consumption_kwh_per_100": { + "name": "Avg. Energy Consumption" }, "polestar_estimated_charging_time_minutes_to_target_distance": { "name": "Estimated Charging Time Minutes to Target Distance" @@ -84,9 +79,6 @@ "polestar_last_updated_battery_data": { "name": "Last Updated Battery Data" }, - "polestar_estimate_full_charge_range_miles": { - "name": "Estimate Full Charge Range Miles" - }, "polestar_estimate_full_charge_range": { "name": "Estimate Full Charge Range" }, diff --git a/custom_components/polestar_api/translations/nl.json b/custom_components/polestar_api/translations/nl.json index d3c0678..9946a85 100644 --- a/custom_components/polestar_api/translations/nl.json +++ b/custom_components/polestar_api/translations/nl.json @@ -2,13 +2,11 @@ "config": { "step": { "user": { - "title": "Configure Polestar EV", - "description": "Enter Authentication of Polestar EV", + "title": "Configureer Polestar API", + "description": "Vul authenticatie voor Polestar EV", "data": { - "name": "Friendly name", - "username": "Username", - "password": "Password", - "vin": "VIN" + "username": "Gebruikersnaam", + "password": "Wachtwoord" } } }, @@ -24,12 +22,6 @@ "polestar_estimate_range": { "name": "Resterende afstand" }, - "polestar_distance_to_empty_miles": { - "name": "Resterende afstand (mijl)" - }, - "polestar_estimate_distance_to_empty_km": { - "name": "Resterende afstand (km)" - }, "polestar_current_odometer": { "name": "Huidige kilometerstand" }, @@ -52,10 +44,10 @@ "name": "Laadstatus" }, "polestar_charging_power": { - "name": "Laadvermogen (W)" + "name": "Laadvermogen" }, "polestar_charging_current": { - "name": "Laadstroom (A)" + "name": "Laadstroom" }, "polestar_charger_connection_status": { "name": "Laadkabel status" @@ -72,6 +64,9 @@ "polestar_registration_number": { "name": "Registratienummer" }, + "polestar_software_version": { + "name": "Software Versie" + }, "polestar_estimated_fully_charged_time": { "name": "Geschatte volledig opgeladen tijd" }, @@ -84,11 +79,8 @@ "polestar_last_updated_battery_data": { "name": "Laatst geüpdatete batterijgegevens" }, - "polestar_estimate_full_charge_range_miles": { - "name": "Geschatte volledige laadafstand (mijl)" - }, "polestar_estimate_full_charge_range": { - "name": "Geschatte volledige laadafstand (km)" + "name": "Geschatte volledige laadafstand" }, "polestar_api_status_code": { "name": "API Status Code"