Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localize status sensor #67

Merged
merged 3 commits into from
Oct 18, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion custom_components/easee/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
],
"units": None,
"convert_units_func": None,
"device_class": None,
"device_class": "easee_status",
"icon": "mdi:ev-station",
},
"total_power": {
Expand Down
7 changes: 7 additions & 0 deletions custom_components/easee/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from homeassistant.helpers import entity_registry, device_registry
from homeassistant.helpers.entity_registry import async_entries_for_device
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.translation import async_get_translations
from homeassistant.util import dt
from homeassistant.const import DEVICE_CLASS_POWER

Expand Down Expand Up @@ -79,6 +80,7 @@ def __init__(

async def async_added_to_hass(self) -> None:
"""Entity created."""

self.hass.data[DOMAIN]["entities"].append({self._entity_name: self.entity_id})

async def async_will_remove_from_hass(self) -> None:
Expand Down Expand Up @@ -190,6 +192,11 @@ def get_value_from_key(self, key):

async def async_update(self):
"""Get the latest data and update the state."""
# self._translations = await async_get_translations(
astrandb marked this conversation as resolved.
Show resolved Hide resolved
# # data["language"], "area", DOMAIN
# "sv", "labels", DOMAIN
# )
# _LOGGER.debug("Translate status_charging: %s", self._translations[f"component.easee.labels.status_charging"])
_LOGGER.debug(
"ChargerEntity async_update : %s %s",
self.charger_data.charger.id,
Expand Down
12 changes: 12 additions & 0 deletions custom_components/easee/translations/sensor.en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"state": {
"easee_status": {
"STANDBY": "Standby",
"PAUSED": "Paused",
"READY_TO_CHARGE": "Ready to charge",
"CAR_CONNECTED": "Car connected",
"CHARGING": "Charging",
"ERROR": "Error"
}
}
}
12 changes: 12 additions & 0 deletions custom_components/easee/translations/sensor.nb.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"state": {
"easee_status": {
"STANDBY": "Ventemodus",
"PAUSED": "Pause",
"READY_TO_CHARGE": "Klar til lading",
"CAR_CONNECTED": "Bil tilkoblet",
"CHARGING": "Lader",
"ERROR": "Feil"
}
}
}
12 changes: 12 additions & 0 deletions custom_components/easee/translations/sensor.sv.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"state": {
"easee_status": {
"STANDBY": "Redo",
"PAUSED": "Paus",
"READY_TO_CHARGE": "Redo att ladda",
"CAR_CONNECTED": "Bil ansluten",
"CHARGING": "Laddar",
"ERROR": "Fel"
}
}
}