Skip to content

Commit

Permalink
feat: Update translation keys in nissan_carwings components
Browse files Browse the repository at this point in the history
  • Loading branch information
remuslazar committed Jun 30, 2024
1 parent 1b3fb0d commit ee88189
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 16 deletions.
6 changes: 5 additions & 1 deletion custom_components/nissan_carwings/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ async def async_setup_entry(
class LeafPluggedInSensor(NissanCarwingsEntity, BinarySensorEntity):
"""Plugged In Sensor class."""

_attr_translation_key = "plug_status"

def __init__(self, coordinator: CarwingsDataUpdateCoordinator) -> None:
"""Initialize the sensor class."""
super().__init__(coordinator)
Expand All @@ -63,12 +65,14 @@ def is_on(self) -> bool:
class LeafChargingSensor(NissanCarwingsEntity, BinarySensorEntity):
"""Charging Sensor class."""

_attr_translation_key = "charging_status"

def __init__(self, coordinator: CarwingsDataUpdateCoordinator) -> None:
"""Initialize the sensor class."""
super().__init__(coordinator)
self.entity_description = BinarySensorEntityDescription(
key="charging_status",
name="Charging",
name="Charging Status",
device_class=BinarySensorDeviceClass.BATTERY_CHARGING,
)
self._attr_unique_id = f"{self.unique_id_prefix}_{self.entity_description.key}"
Expand Down
2 changes: 2 additions & 0 deletions custom_components/nissan_carwings/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ async def async_setup_entry(
class UpdateButton(NissanCarwingsEntity, ButtonEntity):
"""nissan_carwings switch class."""

_attr_translation_key = "request_update"

def __init__(
self,
coordinator: CarwingsDataUpdateCoordinator,
Expand Down
9 changes: 7 additions & 2 deletions custom_components/nissan_carwings/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def __init__(self, coordinator: CarwingsDataUpdateCoordinator, *, is_ac_on: bool
device_class=SensorDeviceClass.DISTANCE,
native_unit_of_measurement=PERCENTAGE,
)
self._attr_translation_key = "range_ac_on" if is_ac_on else "range_ac_off"
self._attr_unique_id = f"{self.unique_id_prefix}_{self.entity_description.key}"
self._attr_icon = "mdi:speedometer"

Expand Down Expand Up @@ -124,6 +125,8 @@ def native_unit_of_measurement(self) -> str:
class BatteryCapacitySensor(NissanCarwingsEntity, SensorEntity):
"""Current Battery Capacity Sensor."""

_attr_translation_key = "battery_capacity"

def __init__(self, coordinator: CarwingsDataUpdateCoordinator) -> None:
"""Initialize the sensor class."""
super().__init__(coordinator)
Expand All @@ -150,15 +153,17 @@ def native_value(self) -> float | None:
class DrivingAnalysisSensor(NissanCarwingsEntity, SensorEntity):
"""Driving Analysis Sensor."""

_attr_translation_key = "electric_mileage"

def __init__(self, coordinator: CarwingsDrivingAnalysisDataUpdateCoordinator) -> None:
"""Initialize the sensor class."""
super().__init__(coordinator)
self.entity_description = SensorEntityDescription(
key="driving_analysis",
name="Driving Mileage",
name="Electric Mileage",
device_class=SensorDeviceClass.ENERGY_STORAGE,
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
icon="mdi:car",
icon="mdi:ev-station",
suggested_display_precision=1,
)
self._attr_unique_id = f"{self.unique_id_prefix}_{self.entity_description.key}"
Expand Down
2 changes: 2 additions & 0 deletions custom_components/nissan_carwings/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ async def async_setup_entry(
class ClimateControlSwitch(NissanCarwingsEntity, SwitchEntity):
"""nissan_carwings switch class."""

_attr_translation_key = "ac_control"

def __init__(
self,
coordinator: CarwingsClimateDataUpdateCoordinator,
Expand Down
49 changes: 42 additions & 7 deletions custom_components/nissan_carwings/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,50 @@
"init": {
"description": "Einstellungen",
"data": {
"update_interval": "Aktualisierungsintervall (in Sekunden)"
"update_interval": "Aktualisierungsintervall (in Sekunden)",
"poll_interval": "Standard-Poll-Intervall (in Sekunden)",
"poll_interval_charging": "Poll-Intervall während des Ladens (in Sekunden)"
},
"data_description": {
"update_interval": "Wie oft die Integration die neuesten Daten über die API synchronisieren soll.",
"poll_interval": "Wie oft die Integration die Nissan Connect API nach neuen Daten abfragen soll.",
"poll_interval_charging": "Wie oft die Integration die Nissan Connect API nach neuen Daten abfragen soll, während das Fahrzeug lädt."
}
}
}
},
"entity": {
"sensor": {
"battery_soc": {
"name": "Batterie"
},
"entity": {
"sensor": {
"battery_soc": {
"name": "Batterie"
},
"range_ac_off": {
"name": "Reichweite"
},
"range_ac_on": {
"name": "Reichweite (mit Klima)"
},
"battery_capacity": {
"name": "Batteriekapazität"
},
"electric_mileage": {
"name": "Tagesverbrauch"
}
},
"switch": {
"ac_control": {
"name": "Klima"
}
},
"binary_sensor": {
"plug_status": {
"name": "Kabel"
},
"charging_status": {
"name": "Status"
}
},
"button": {
"update": "Aktualisierung anfordern"
}
}
}
Expand Down
47 changes: 41 additions & 6 deletions custom_components/nissan_carwings/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,49 @@
"update_interval": "Update (fetch) Interval (in seconds)",
"poll_interval": "Default Poll Interval (in seconds)",
"poll_interval_charging": "Poll Interval while charging (in seconds)"
},
"data_description": {
"update_interval": "How often the integration should synchronize latest data from via API.",
"poll_interval": "How often the integration should poll the Nissan Connect API for new data.",
"poll_interval_charging": "How often the integration should poll the Nissan Connect API for new data while charging."
}
}
}
},
"entity": {
"sensor": {
"battery_soc": {
"name": "Battery"
},
"entity": {
"sensor": {
"battery_soc": {
"name": "Battery"
},
"range_ac_off": {
"name": "Estimated Range"
},
"range_ac_on": {
"name": "Estimated Range (AC)"
},
"battery_capacity": {
"name": "Battery Capacity"
},
"electric_mileage": {
"name": "Daily Efficiency"
}
},
"switch": {
"ac_control": {
"name": "Climate Control"
}
},
"binary_sensor": {
"plug_status": {
"name": "Plug Status"
},
"charging_status": {
"name": "Charging"
}
},
"button": {
"request_update": {
"name": "Request Update"
}
}
}
}
Expand Down

0 comments on commit ee88189

Please sign in to comment.