From b41a1e175166599e96500b0f2fb510093aecb196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85ke=20Strandberg?= Date: Sun, 18 Oct 2020 19:38:11 +0200 Subject: [PATCH] Localize status sensor (#67) * Localize status sensor * Status Error and nb language added * Removed commented code --- custom_components/easee/const.py | 2 +- custom_components/easee/entity.py | 2 ++ custom_components/easee/translations/sensor.en.json | 12 ++++++++++++ custom_components/easee/translations/sensor.nb.json | 12 ++++++++++++ custom_components/easee/translations/sensor.sv.json | 12 ++++++++++++ 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 custom_components/easee/translations/sensor.en.json create mode 100644 custom_components/easee/translations/sensor.nb.json create mode 100644 custom_components/easee/translations/sensor.sv.json diff --git a/custom_components/easee/const.py b/custom_components/easee/const.py index daf0777d..fd8ff196 100644 --- a/custom_components/easee/const.py +++ b/custom_components/easee/const.py @@ -99,7 +99,7 @@ ], "units": None, "convert_units_func": None, - "device_class": None, + "device_class": "easee_status", "icon": "mdi:ev-station", }, "total_power": { diff --git a/custom_components/easee/entity.py b/custom_components/easee/entity.py index bce6186f..47304c26 100644 --- a/custom_components/easee/entity.py +++ b/custom_components/easee/entity.py @@ -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 @@ -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: diff --git a/custom_components/easee/translations/sensor.en.json b/custom_components/easee/translations/sensor.en.json new file mode 100644 index 00000000..a9dd6fb6 --- /dev/null +++ b/custom_components/easee/translations/sensor.en.json @@ -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" + } + } +} \ No newline at end of file diff --git a/custom_components/easee/translations/sensor.nb.json b/custom_components/easee/translations/sensor.nb.json new file mode 100644 index 00000000..f43fc94e --- /dev/null +++ b/custom_components/easee/translations/sensor.nb.json @@ -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" + } + } +} diff --git a/custom_components/easee/translations/sensor.sv.json b/custom_components/easee/translations/sensor.sv.json new file mode 100644 index 00000000..91cd1ddc --- /dev/null +++ b/custom_components/easee/translations/sensor.sv.json @@ -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" + } + } +}