Skip to content

Commit

Permalink
Added Dutch, Norwegian and Swedish translations.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbkarlsson authored Aug 5, 2024
1 parent 840176c commit aed6104
Show file tree
Hide file tree
Showing 19 changed files with 490 additions and 250 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.11", "3.12"]
include:
- python-version: "3.9"
pytest_all_ha_versions: "pytest_all_ha_versions_python39"
- python-version: "3.10"
pytest_all_ha_versions: "pytest_all_ha_versions_python310"
- python-version: "3.11"
pytest_all_ha_versions: "pytest_all_ha_versions_python311"
- python-version: "3.12"
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.11", "3.12"]
include:
- python-version: "3.9"
requirements: "requirements_test39.txt"
- python-version: "3.10"
requirements: "requirements_test310.txt"
- python-version: "3.11"
requirements: "requirements_test311.txt"
- python-version: "3.12"
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.11", "3.12"]
include:
- python-version: "3.9"
requirements: "requirements_test39.txt"
- python-version: "3.10"
requirements: "requirements_test310.txt"
- python-version: "3.11"
requirements: "requirements_test311.txt"
- python-version: "3.12"
Expand Down
10 changes: 5 additions & 5 deletions custom_components/ev_smart_charging/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from .const import (
BUTTON,
DOMAIN,
ENTITY_NAME_START_BUTTON,
ENTITY_NAME_STOP_BUTTON,
ENTITY_KEY_START_BUTTON,
ENTITY_KEY_STOP_BUTTON,
ICON_START,
ICON_STOP,
)
Expand All @@ -35,15 +35,15 @@ def __init__(self, entry, coordinator: EVSmartChargingCoordinator):
_LOGGER.debug("EVSmartChargingButton.__init__()")
super().__init__(entry)
self.coordinator = coordinator
id_name = self._attr_name.replace(" ", "").lower()
id_name = self._entity_key.replace("_", "").lower()
self._attr_unique_id = ".".join([entry.entry_id, BUTTON, id_name])
_LOGGER.debug("self._attr_unique_id = %s", self._attr_unique_id)


class EVSmartChargingButtonStart(EVSmartChargingButton):
"""EV Smart Charging start button class."""

_attr_name = ENTITY_NAME_START_BUTTON
_entity_key = ENTITY_KEY_START_BUTTON
_attr_icon = ICON_START

async def async_press(self) -> None:
Expand All @@ -54,7 +54,7 @@ async def async_press(self) -> None:
class EVSmartChargingButtonStop(EVSmartChargingButton):
"""EV Smart Charging start button class."""

_attr_name = ENTITY_NAME_STOP_BUTTON
_entity_key = ENTITY_KEY_STOP_BUTTON
_attr_icon = ICON_STOP

async def async_press(self) -> None:
Expand Down
60 changes: 30 additions & 30 deletions custom_components/ev_smart_charging/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,27 @@
PLATFORM_OCPP = "ocpp"
PLATFORM_GENERIC = "generic"

# Entity names
ENTITY_NAME_CHARGING_SENSOR = "Charging"
ENTITY_NAME_STATUS_SENSOR = "Status"
ENTITY_NAME_ACTIVE_SWITCH = "Smart charging activated"
ENTITY_NAME_APPLY_LIMIT_SWITCH = "Apply price limit"
ENTITY_NAME_CONTINUOUS_SWITCH = "Continuous charging preferred"
ENTITY_NAME_EV_CONNECTED_SWITCH = "EV connected"
ENTITY_NAME_KEEP_ON_SWITCH = "Keep charger on"
ENTITY_NAME_OPPORTUNISTIC_SWITCH = "Opportunistic charging"
ENTITY_NAME_LOW_PRICE_CHARGING_SWITCH = "Low price charging"
ENTITY_NAME_LOW_SOC_CHARGING_SWITCH = "Low SOC charging"
ENTITY_NAME_START_BUTTON = "Manually start charging"
ENTITY_NAME_STOP_BUTTON = "Manually stop charging"
ENTITY_NAME_CONF_PCT_PER_HOUR_NUMBER = "Charging speed"
ENTITY_NAME_CONF_MAX_PRICE_NUMBER = "Electricity price limit"
ENTITY_NAME_CONF_OPPORTUNISTIC_LEVEL_NUMBER = "Opportunistic level"
ENTITY_NAME_CONF_LOW_PRICE_CHARGING_NUMBER = "Low price charging level"
ENTITY_NAME_CONF_LOW_SOC_CHARGING_NUMBER = "Low SOC charging level"
ENTITY_NAME_CONF_MIN_SOC_NUMBER = "Minimum EV SOC"
ENTITY_NAME_CONF_START_HOUR = "Charge start time"
ENTITY_NAME_CONF_READY_HOUR = "Charge completion time"
# Entity keys
ENTITY_KEY_CHARGING_SENSOR = "charging"
ENTITY_KEY_STATUS_SENSOR = "status"
ENTITY_KEY_ACTIVE_SWITCH = "smart_charging_activated"
ENTITY_KEY_APPLY_LIMIT_SWITCH = "apply_price_limit"
ENTITY_KEY_CONTINUOUS_SWITCH = "continuous_charging_preferred"
ENTITY_KEY_EV_CONNECTED_SWITCH = "ev_connected"
ENTITY_KEY_KEEP_ON_SWITCH = "keep_charger_on"
ENTITY_KEY_OPPORTUNISTIC_SWITCH = "opportunistic_charging"
ENTITY_KEY_LOW_PRICE_CHARGING_SWITCH = "low_price_charging"
ENTITY_KEY_LOW_SOC_CHARGING_SWITCH = "low_soc_charging"
ENTITY_KEY_START_BUTTON = "manually_start_charging"
ENTITY_KEY_STOP_BUTTON = "manually_stop_charging"
ENTITY_KEY_CONF_PCT_PER_HOUR_NUMBER = "charging_speed"
ENTITY_KEY_CONF_MAX_PRICE_NUMBER = "electricity_price_limit"
ENTITY_KEY_CONF_OPPORTUNISTIC_LEVEL_NUMBER = "opportunistic_level"
ENTITY_KEY_CONF_LOW_PRICE_CHARGING_NUMBER = "low_price_charging_level"
ENTITY_KEY_CONF_LOW_SOC_CHARGING_NUMBER = "low_soc_charging_level"
ENTITY_KEY_CONF_MIN_SOC_NUMBER = "minimum_ev_soc"
ENTITY_KEY_CONF_START_HOUR = "charge_start_time"
ENTITY_KEY_CONF_READY_HOUR = "charge_completion_time"

# Configuration and options
CONF_DEVICE_NAME = "device_name"
Expand Down Expand Up @@ -101,15 +101,15 @@
START_HOUR_NONE = -48
READY_HOUR_NONE = 72

CHARGING_STATUS_WAITING_NEW_PRICE = "Waiting for new prices"
CHARGING_STATUS_NO_PLAN = "No charging planned"
CHARGING_STATUS_WAITING_CHARGING = "Waiting for charging to begin"
CHARGING_STATUS_CHARGING = "Charging"
CHARGING_STATUS_KEEP_ON = "Keeping charger on"
CHARGING_STATUS_DISCONNECTED = "Disconnected"
CHARGING_STATUS_NOT_ACTIVE = "Smart charging not active"
CHARGING_STATUS_LOW_PRICE_CHARGING = "Low price charging"
CHARGING_STATUS_LOW_SOC_CHARGING = "Low SOC charging"
CHARGING_STATUS_WAITING_NEW_PRICE = "waiting_for_new_prices"
CHARGING_STATUS_NO_PLAN = "no_charging_planned"
CHARGING_STATUS_WAITING_CHARGING = "waiting_for_charging_to_begin"
CHARGING_STATUS_CHARGING = "charging"
CHARGING_STATUS_KEEP_ON = "keeping_charger_on"
CHARGING_STATUS_DISCONNECTED = "disconnected"
CHARGING_STATUS_NOT_ACTIVE = "smart_charging_not_active"
CHARGING_STATUS_LOW_PRICE_CHARGING = "low_price_charging"
CHARGING_STATUS_LOW_SOC_CHARGING = "low_soc_charging"

# Defaults
DEFAULT_NAME = DOMAIN
Expand Down
4 changes: 4 additions & 0 deletions custom_components/ev_smart_charging/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ class EVSmartChargingEntity(Entity):
_attr_icon = ICON
_attr_has_entity_name = True

_entity_key: str

def __init__(self, config_entry):
self.config_entry = config_entry
self._attr_translation_key = self._entity_key


def update_ha_state(self):
"""Update the HA state"""
Expand Down
26 changes: 13 additions & 13 deletions custom_components/ev_smart_charging/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
CONF_OPPORTUNISTIC_LEVEL,
CONF_PCT_PER_HOUR,
DOMAIN,
ENTITY_NAME_CONF_LOW_PRICE_CHARGING_NUMBER,
ENTITY_NAME_CONF_LOW_SOC_CHARGING_NUMBER,
ENTITY_NAME_CONF_OPPORTUNISTIC_LEVEL_NUMBER,
ENTITY_NAME_CONF_PCT_PER_HOUR_NUMBER,
ENTITY_NAME_CONF_MAX_PRICE_NUMBER,
ENTITY_NAME_CONF_MIN_SOC_NUMBER,
ENTITY_KEY_CONF_LOW_PRICE_CHARGING_NUMBER,
ENTITY_KEY_CONF_LOW_SOC_CHARGING_NUMBER,
ENTITY_KEY_CONF_OPPORTUNISTIC_LEVEL_NUMBER,
ENTITY_KEY_CONF_PCT_PER_HOUR_NUMBER,
ENTITY_KEY_CONF_MAX_PRICE_NUMBER,
ENTITY_KEY_CONF_MIN_SOC_NUMBER,
ICON_BATTERY_50,
ICON_CASH,
NUMBER,
Expand Down Expand Up @@ -60,7 +60,7 @@ def __init__(self, entry, coordinator: EVSmartChargingCoordinator):
_LOGGER.debug("EVSmartChargingNumber.__init__()")
super().__init__(entry)
self.coordinator = coordinator
id_name = self._attr_name.replace(" ", "").lower()
id_name = self._entity_key.replace("_", "").lower()
self._attr_unique_id = ".".join([entry.entry_id, NUMBER, id_name])

async def async_set_native_value(self, value: float) -> None:
Expand All @@ -82,7 +82,7 @@ async def async_added_to_hass(self) -> None:
class EVSmartChargingNumberChargingSpeed(EVSmartChargingNumber):
"""EV Smart Charging active number class."""

_attr_name = ENTITY_NAME_CONF_PCT_PER_HOUR_NUMBER
_entity_key = ENTITY_KEY_CONF_PCT_PER_HOUR_NUMBER
_attr_entity_category = EntityCategory.CONFIG
_attr_native_min_value = 0.1
_attr_native_max_value = 100.0
Expand All @@ -106,7 +106,7 @@ async def async_set_native_value(self, value: float) -> None:
class EVSmartChargingNumberPriceLimit(EVSmartChargingNumber):
"""EV Smart Charging apply limit number class."""

_attr_name = ENTITY_NAME_CONF_MAX_PRICE_NUMBER
_entity_key = ENTITY_KEY_CONF_MAX_PRICE_NUMBER
_attr_icon = ICON_CASH
_attr_entity_category = EntityCategory.CONFIG
_attr_native_min_value = -10000.0
Expand All @@ -130,7 +130,7 @@ async def async_set_native_value(self, value: float) -> None:
class EVSmartChargingNumberMinSOC(EVSmartChargingNumber):
"""EV Smart Charging continuous number class."""

_attr_name = ENTITY_NAME_CONF_MIN_SOC_NUMBER
_entity_key = ENTITY_KEY_CONF_MIN_SOC_NUMBER
_attr_icon = ICON_BATTERY_50
_attr_entity_category = EntityCategory.CONFIG
_attr_native_min_value = 0.0
Expand All @@ -155,7 +155,7 @@ async def async_set_native_value(self, value: float) -> None:
class EVSmartChargingNumberOpportunistic(EVSmartChargingNumber):
"""EV Smart Charging opportunistic number class."""

_attr_name = ENTITY_NAME_CONF_OPPORTUNISTIC_LEVEL_NUMBER
_entity_key = ENTITY_KEY_CONF_OPPORTUNISTIC_LEVEL_NUMBER
_attr_entity_category = EntityCategory.CONFIG
_attr_native_min_value = 0.0
_attr_native_max_value = 100.0
Expand Down Expand Up @@ -185,7 +185,7 @@ async def async_set_native_value(self, value: float) -> None:
class EVSmartChargingNumberLowPriceCharging(EVSmartChargingNumber):
"""EV Smart Charging low price charging number class."""

_attr_name = ENTITY_NAME_CONF_LOW_PRICE_CHARGING_NUMBER
_entity_key = ENTITY_KEY_CONF_LOW_PRICE_CHARGING_NUMBER
_attr_icon = ICON_CASH
_attr_entity_category = EntityCategory.CONFIG
_attr_native_min_value = -10000.0
Expand All @@ -211,7 +211,7 @@ async def async_set_native_value(self, value: float) -> None:
class EVSmartChargingNumberLowSocCharging(EVSmartChargingNumber):
"""EV Smart Charging low SOC charging number class."""

_attr_name = ENTITY_NAME_CONF_LOW_SOC_CHARGING_NUMBER
_entity_key = ENTITY_KEY_CONF_LOW_SOC_CHARGING_NUMBER
_attr_icon = ICON_BATTERY_50
_attr_entity_category = EntityCategory.CONFIG
_attr_native_min_value = 0.0
Expand Down
10 changes: 5 additions & 5 deletions custom_components/ev_smart_charging/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
CONF_READY_HOUR,
CONF_START_HOUR,
DOMAIN,
ENTITY_NAME_CONF_READY_HOUR,
ENTITY_NAME_CONF_START_HOUR,
ENTITY_KEY_CONF_READY_HOUR,
ENTITY_KEY_CONF_START_HOUR,
HOURS,
ICON_TIME,
SELECT,
Expand Down Expand Up @@ -46,7 +46,7 @@ def __init__(self, entry, coordinator: EVSmartChargingCoordinator):
_LOGGER.debug("EVSmartChargingSelect.__init__()")
super().__init__(entry)
self.coordinator = coordinator
id_name = self._attr_name.replace(" ", "").lower()
id_name = self._entity_key.replace("_", "").lower()
self._attr_unique_id = ".".join([entry.entry_id, SELECT, id_name])

async def async_select_option(self, option: str) -> None:
Expand All @@ -63,7 +63,7 @@ async def async_added_to_hass(self) -> None:
class EVSmartChargingSelectStartHour(EVSmartChargingSelect):
"""EV Smart Charging start_hour select class."""

_attr_name = ENTITY_NAME_CONF_START_HOUR
_entity_key = ENTITY_KEY_CONF_START_HOUR
_attr_icon = ICON_TIME
_attr_entity_category = EntityCategory.CONFIG
_attr_options = HOURS
Expand All @@ -90,7 +90,7 @@ async def async_select_option(self, option: str) -> None:
class EVSmartChargingSelectReadyHour(EVSmartChargingSelect):
"""EV Smart Charging ready_hour select class."""

_attr_name = ENTITY_NAME_CONF_READY_HOUR
_entity_key = ENTITY_KEY_CONF_READY_HOUR
_attr_icon = ICON_TIME
_attr_entity_category = EntityCategory.CONFIG
_attr_options = HOURS
Expand Down
26 changes: 11 additions & 15 deletions custom_components/ev_smart_charging/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@


from .const import (
CHARGING_STATUS_NOT_ACTIVE,
DOMAIN,
ENTITY_NAME_CHARGING_SENSOR,
ENTITY_NAME_STATUS_SENSOR,
ENTITY_KEY_CHARGING_SENSOR,
ENTITY_KEY_STATUS_SENSOR,
SENSOR,
)
from .entity import EVSmartChargingEntity
Expand All @@ -35,14 +34,13 @@ class EVSmartChargingSensor(EVSmartChargingEntity, SensorEntity):
def __init__(self, entry):
_LOGGER.debug("EVSmartChargingSensor.__init__()")
super().__init__(entry)
id_name = self._attr_name.replace(" ", "").lower()
id_name = self._entity_key.replace("_", "").lower()
self._attr_unique_id = ".".join([entry.entry_id, SENSOR, id_name])


class EVSmartChargingSensorCharging(EVSmartChargingSensor):
"""EV Smart Charging sensor class."""

_attr_name = ENTITY_NAME_CHARGING_SENSOR
_entity_key = ENTITY_KEY_CHARGING_SENSOR

def __init__(self, entry):
_LOGGER.debug("EVSmartChargingSensor.__init__()")
Expand Down Expand Up @@ -72,12 +70,12 @@ def set_state(self, new_state):
def extra_state_attributes(self) -> dict:
return {
"current_price": self._current_price,
"EV SOC": self._ev_soc,
"EV target SOC": self._ev_target_soc,
"Charging is planned": self._charging_is_planned,
"Charging start time": self._charging_start_time,
"Charging stop time": self._charging_stop_time,
"Charging number of hours": self._charging_number_of_hours,
"ev_soc": self._ev_soc,
"ev_target_soc": self._ev_target_soc,
"charging_is_planned": self._charging_is_planned,
"charging_start_time": self._charging_start_time,
"charging_stop_time": self._charging_stop_time,
"charging_number_of_hours": self._charging_number_of_hours,
"raw_two_days": self._raw_two_days,
"charging_schedule": self._charging_schedule,
}
Expand Down Expand Up @@ -176,14 +174,12 @@ def charging_number_of_hours(self, new_value):
class EVSmartChargingSensorStatus(EVSmartChargingSensor):
"""EV Smart Charging sensor class."""

_attr_name = ENTITY_NAME_STATUS_SENSOR
_entity_key = ENTITY_KEY_STATUS_SENSOR

def __init__(self, entry):
_LOGGER.debug("EVSmartChargingSensorStatus.__init__()")
super().__init__(entry)

self._attr_native_value = CHARGING_STATUS_NOT_ACTIVE

def set_status(self, new_status):
"""Set new status."""
self._attr_native_value = new_status
Expand Down
Loading

0 comments on commit aed6104

Please sign in to comment.