From aed6104aff852e1b938b5d523a564aae98f80d3a Mon Sep 17 00:00:00 2001 From: Jonas Karlsson Date: Mon, 5 Aug 2024 22:14:25 +0200 Subject: [PATCH] Added Dutch, Norwegian and Swedish translations. --- .github/workflows/pre-release.yml | 6 +- .github/workflows/pull.yml | 6 +- .github/workflows/push.yml | 6 +- custom_components/ev_smart_charging/button.py | 10 +- custom_components/ev_smart_charging/const.py | 60 +++++----- custom_components/ev_smart_charging/entity.py | 4 + custom_components/ev_smart_charging/number.py | 26 ++-- custom_components/ev_smart_charging/select.py | 10 +- custom_components/ev_smart_charging/sensor.py | 26 ++-- custom_components/ev_smart_charging/switch.py | 34 +++--- .../ev_smart_charging/translations/en.json | 60 +++++++++- .../ev_smart_charging/translations/nb.json | 111 ++++++++++++++++++ .../ev_smart_charging/translations/nl.json | 111 ++++++++++++++++++ .../ev_smart_charging/translations/sv.json | 111 ++++++++++++++++++ hacs.json | 2 +- scripts/pytest_all_ha_versions_python310 | 80 ------------- scripts/pytest_all_ha_versions_python311 | 5 +- scripts/pytest_all_ha_versions_python39 | 60 ---------- tests/test_sensor.py | 12 +- 19 files changed, 490 insertions(+), 250 deletions(-) create mode 100644 custom_components/ev_smart_charging/translations/nb.json create mode 100644 custom_components/ev_smart_charging/translations/nl.json create mode 100644 custom_components/ev_smart_charging/translations/sv.json delete mode 100644 scripts/pytest_all_ha_versions_python310 delete mode 100644 scripts/pytest_all_ha_versions_python39 diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 2a21bfb..0eacdd4 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -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" diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index 75c684b..4a6d29a 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -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" diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index a94d68b..c3aeb8f 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -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" diff --git a/custom_components/ev_smart_charging/button.py b/custom_components/ev_smart_charging/button.py index c187b97..2c96b62 100644 --- a/custom_components/ev_smart_charging/button.py +++ b/custom_components/ev_smart_charging/button.py @@ -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, ) @@ -35,7 +35,7 @@ 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) @@ -43,7 +43,7 @@ def __init__(self, entry, coordinator: EVSmartChargingCoordinator): 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: @@ -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: diff --git a/custom_components/ev_smart_charging/const.py b/custom_components/ev_smart_charging/const.py index fcf8f0c..3b21ffc 100644 --- a/custom_components/ev_smart_charging/const.py +++ b/custom_components/ev_smart_charging/const.py @@ -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" @@ -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 diff --git a/custom_components/ev_smart_charging/entity.py b/custom_components/ev_smart_charging/entity.py index e581db8..a80dafa 100644 --- a/custom_components/ev_smart_charging/entity.py +++ b/custom_components/ev_smart_charging/entity.py @@ -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""" diff --git a/custom_components/ev_smart_charging/number.py b/custom_components/ev_smart_charging/number.py index a523cd9..d5096a2 100644 --- a/custom_components/ev_smart_charging/number.py +++ b/custom_components/ev_smart_charging/number.py @@ -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, @@ -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: @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/custom_components/ev_smart_charging/select.py b/custom_components/ev_smart_charging/select.py index 592ddca..dda5879 100644 --- a/custom_components/ev_smart_charging/select.py +++ b/custom_components/ev_smart_charging/select.py @@ -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, @@ -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: @@ -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 @@ -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 diff --git a/custom_components/ev_smart_charging/sensor.py b/custom_components/ev_smart_charging/sensor.py index 507c1c8..82c1a3f 100644 --- a/custom_components/ev_smart_charging/sensor.py +++ b/custom_components/ev_smart_charging/sensor.py @@ -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 @@ -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__()") @@ -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, } @@ -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 diff --git a/custom_components/ev_smart_charging/switch.py b/custom_components/ev_smart_charging/switch.py index 9c51c0b..77eed00 100644 --- a/custom_components/ev_smart_charging/switch.py +++ b/custom_components/ev_smart_charging/switch.py @@ -9,14 +9,14 @@ from .const import ( DOMAIN, - ENTITY_NAME_ACTIVE_SWITCH, - ENTITY_NAME_APPLY_LIMIT_SWITCH, - ENTITY_NAME_CONTINUOUS_SWITCH, - ENTITY_NAME_EV_CONNECTED_SWITCH, - ENTITY_NAME_LOW_PRICE_CHARGING_SWITCH, - ENTITY_NAME_KEEP_ON_SWITCH, - ENTITY_NAME_LOW_SOC_CHARGING_SWITCH, - ENTITY_NAME_OPPORTUNISTIC_SWITCH, + ENTITY_KEY_ACTIVE_SWITCH, + ENTITY_KEY_APPLY_LIMIT_SWITCH, + ENTITY_KEY_CONTINUOUS_SWITCH, + ENTITY_KEY_EV_CONNECTED_SWITCH, + ENTITY_KEY_LOW_PRICE_CHARGING_SWITCH, + ENTITY_KEY_KEEP_ON_SWITCH, + ENTITY_KEY_LOW_SOC_CHARGING_SWITCH, + ENTITY_KEY_OPPORTUNISTIC_SWITCH, ICON_CONNECTION, SWITCH, ) @@ -51,7 +51,7 @@ def __init__(self, entry, coordinator: EVSmartChargingCoordinator): _LOGGER.debug("EVSmartChargingSwitch.__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, SWITCH, id_name]) async def async_turn_on(self, **kwargs: Any) -> None: @@ -75,7 +75,7 @@ async def async_added_to_hass(self) -> None: class EVSmartChargingSwitchActive(EVSmartChargingSwitch): """EV Smart Charging active switch class.""" - _attr_name = ENTITY_NAME_ACTIVE_SWITCH + _entity_key = ENTITY_KEY_ACTIVE_SWITCH def __init__(self, entry, coordinator: EVSmartChargingCoordinator): _LOGGER.debug("EVSmartChargingSwitchActive.__init__()") @@ -99,7 +99,7 @@ async def async_turn_off(self, **kwargs: Any) -> None: class EVSmartChargingSwitchApplyLimit(EVSmartChargingSwitch): """EV Smart Charging apply limit switch class.""" - _attr_name = ENTITY_NAME_APPLY_LIMIT_SWITCH + _entity_key = ENTITY_KEY_APPLY_LIMIT_SWITCH def __init__(self, entry, coordinator: EVSmartChargingCoordinator): _LOGGER.debug("EVSmartChargingSwitchApplyLimit.__init__()") @@ -124,7 +124,7 @@ async def async_turn_off(self, **kwargs: Any) -> None: class EVSmartChargingSwitchContinuous(EVSmartChargingSwitch): """EV Smart Charging continuous switch class.""" - _attr_name = ENTITY_NAME_CONTINUOUS_SWITCH + _entity_key = ENTITY_KEY_CONTINUOUS_SWITCH def __init__(self, entry, coordinator: EVSmartChargingCoordinator): _LOGGER.debug("EVSmartChargingSwitchContinuous.__init__()") @@ -148,7 +148,7 @@ async def async_turn_off(self, **kwargs: Any) -> None: class EVSmartChargingSwitchEVConnected(EVSmartChargingSwitch): """EV Smart Charging continuous switch class.""" - _attr_name = ENTITY_NAME_EV_CONNECTED_SWITCH + _entity_key = ENTITY_KEY_EV_CONNECTED_SWITCH _attr_icon = ICON_CONNECTION def __init__(self, entry, coordinator: EVSmartChargingCoordinator): @@ -173,7 +173,7 @@ async def async_turn_off(self, **kwargs: Any) -> None: class EVSmartChargingSwitchKeepOn(EVSmartChargingSwitch): """EV Smart Charging keep charger on switch class.""" - _attr_name = ENTITY_NAME_KEEP_ON_SWITCH + _entity_key = ENTITY_KEY_KEEP_ON_SWITCH def __init__(self, entry, coordinator: EVSmartChargingCoordinator): _LOGGER.debug("EVSmartChargingSwitchKeepOn.__init__()") @@ -198,7 +198,7 @@ async def async_turn_off(self, **kwargs: Any) -> None: class EVSmartChargingSwitchOpportunistic(EVSmartChargingSwitch): """EV Smart Charging opportunistic switch class.""" - _attr_name = ENTITY_NAME_OPPORTUNISTIC_SWITCH + _entity_key = ENTITY_KEY_OPPORTUNISTIC_SWITCH def __init__(self, entry, coordinator: EVSmartChargingCoordinator): _LOGGER.debug("EVSmartChargingSwitchOpportunistic.__init__()") @@ -223,7 +223,7 @@ async def async_turn_off(self, **kwargs: Any) -> None: class EVSmartChargingSwitchLowPriceCharging(EVSmartChargingSwitch): """EV Smart Charging low price charging switch class.""" - _attr_name = ENTITY_NAME_LOW_PRICE_CHARGING_SWITCH + _entity_key = ENTITY_KEY_LOW_PRICE_CHARGING_SWITCH def __init__(self, entry, coordinator: EVSmartChargingCoordinator): _LOGGER.debug("EVSmartChargingSwitchLowPriceCharging.__init__()") @@ -247,7 +247,7 @@ async def async_turn_off(self, **kwargs: Any) -> None: class EVSmartChargingSwitchLowSocCharging(EVSmartChargingSwitch): """EV Smart Charging low SOC charging switch class.""" - _attr_name = ENTITY_NAME_LOW_SOC_CHARGING_SWITCH + _entity_key = ENTITY_KEY_LOW_SOC_CHARGING_SWITCH def __init__(self, entry, coordinator: EVSmartChargingCoordinator): _LOGGER.debug("EVSmartChargingSwitchLowSocCharging.__init__()") diff --git a/custom_components/ev_smart_charging/translations/en.json b/custom_components/ev_smart_charging/translations/en.json index d6481cc..a167a34 100644 --- a/custom_components/ev_smart_charging/translations/en.json +++ b/custom_components/ev_smart_charging/translations/en.json @@ -28,7 +28,7 @@ "options": { "step": { "init": { - "description": "Configuration of name and external entities.", + "description": "Configuration of external entities.", "data": { "price_sensor": "Electricity price sensor", "ev_soc_sensor": "EV SOC entity", @@ -49,5 +49,63 @@ "charger_control_switch_not_found": "Charger control switch entity not found.", "charger_control_switch_not_switch": "Charger control switch entity is not a switch." } + }, + "entity": { + "button": { + "manually_start_charging": { "name": "Manually start charging" }, + "manually_stop_charging": { "name": "Manually stop charging" } + }, + "number": { + "charging_speed": { "name": "Charging speed" }, + "electricity_price_limit": { "name": "Electricity price limit" }, + "opportunistic_level": { "name": "Opportunistic level" }, + "low_price_charging_level": { "name": "Low price charging level" }, + "low_soc_charging_level": { "name": "Low SOC charging level" }, + "minimum_ev_soc": { "name": "Minimum EV SOC" } + }, + "select": { + "charge_start_time": { "name": "Charge start time" }, + "charge_completion_time": { "name": "Charge completion time" } + }, + "sensor": { + "charging": { + "name": "Charging", + "state_attributes": { + "current_price": { "name": "Current price"}, + "ev_soc": {"name": "EV SOC"}, + "ev_target_soc": {"name": "EV target SOC"}, + "charging_is_planned": {"name": "Charging is planned"}, + "charging_start_time": {"name": "Charging start time"}, + "charging_stop_time": {"name": "Charging stop time"}, + "charging_number_of_hours": {"name": "Charging number of hours"}, + "raw_two_days": {"name": "Raw two days"}, + "charging_schedule": {"name": "Charging schedule"} + } + }, + "status": { + "name": "Status", + "state": { + "waiting_for_new_prices": "Waiting for new prices", + "no_charging_planned": "No charging planned", + "waiting_for_charging_to_begin": "Waiting for charging to begin", + "charging": "Charging", + "keeping_charger_on": "Keeping charger on", + "disconnected": "Disconnected", + "smart_charging_not_active": "Smart charging not active", + "low_price_charging": "Low price charging", + "low_soc_charging": "Low SOC charging" + } + } + }, + "switch": { + "smart_charging_activated": { "name": "Smart charging activated" }, + "apply_price_limit": { "name": "Apply price limit" }, + "continuous_charging_preferred": { "name": "Continuous charging preferred" }, + "ev_connected": { "name": "EV connected" }, + "keep_charger_on": { "name": "Keep charger on" }, + "opportunistic_charging": { "name": "Opportunistic charging" }, + "low_price_charging": { "name": "Low price charging" }, + "low_soc_charging": { "name": "Low SOC charging" } + } } } \ No newline at end of file diff --git a/custom_components/ev_smart_charging/translations/nb.json b/custom_components/ev_smart_charging/translations/nb.json new file mode 100644 index 0000000..0612d1a --- /dev/null +++ b/custom_components/ev_smart_charging/translations/nb.json @@ -0,0 +1,111 @@ +{ + "config": { + "step": { + "user": { + "description": "Konfigurasjon av navn og eksterne enheter.", + "data": { + "device_name": "Navn", + "price_sensor": "Sensor for strømpris", + "ev_soc_sensor": "Elbil SOC-enhet (ladenivå)", + "ev_target_soc_sensor": "Enhet for ønsket SOC/ladenivå (mellomrom for å ta bort)", + "charger_entity": "Ladekontrollbryter (mellomrom for å ta bort)", + "ev_controlled": "Elbilintegrasjon, brukes for å styre start og stopp av lading." + } + } + }, + "error": { + "price_not_found": "Sensor for strømpris ikke funnet.", + "price_not_sensor": "Strømpris-enheten er ikke en sensor.", + "sensor_is_not_price": "Sensoren for strømpris har ikke de nødvendige attributtene.", + "ev_soc_not_found": "Elbil SOC-enhet ikke funnet.", + "ev_soc_invalid_data": "SOC-enheten gir ugyldige data.", + "ev_target_soc_not_found": "Elbil mål-SOC-enhet ikke funnet.", + "ev_target_soc_invalid_data": "Mål-SOC-enheten gir ugyldige data.", + "charger_control_switch_not_found": "Ladekontrollbryter ikke funnet.", + "charger_control_switch_not_switch": "Ladekontrollbryteren er ikke en bryter." + } + }, + "options": { + "step": { + "init": { + "description": "Konfigurasjon av eksterne enheter.", + "data": { + "price_sensor": "Sensor for strømpris", + "ev_soc_sensor": "Elbil SOC-enhet", + "ev_target_soc_sensor": "Elbil mål-SOC-enhet (mellomrom for å ta bort)", + "charger_entity": "Ladekontrollbryter (mellomrom for å ta bort)", + "ev_controlled": "Elbil-integrasjon for å kontrollere start/stopp av lading" + } + } + }, + "error": { + "price_not_found": "Sensor for strømpris ikke funnet.", + "price_not_sensor": "Strømpris-enheten er ikke en sensor.", + "sensor_is_not_price": "Sensoren for strømpris har ikke de nødvendige attributtene.", + "ev_soc_not_found": "Elbil SOC-enhet ikke funnet.", + "ev_soc_invalid_data": "SOC-enheten gir ugyldige data.", + "ev_target_soc_not_found": "Elbil mål-SOC-enhet ikke funnet.", + "ev_target_soc_invalid_data": "Mål-SOC-enheten gir ugyldige data.", + "charger_control_switch_not_found": "Ladekontrollbryter ikke funnet.", + "charger_control_switch_not_switch": "Ladekontrollbryteren er ikke en bryter." + } + }, + "entity": { + "button": { + "manually_start_charging": { "name": "Start lading manuelt" }, + "manually_stop_charging": { "name": "Stopp lading manuelt" } + }, + "number": { + "charging_speed": { "name": "Ladehastighet" }, + "electricity_price_limit": { "name": "Maksimum strømpris" }, + "opportunistic_level": { "name": "Opportunistisk nivå" }, + "low_price_charging_level": { "name": "Lad ved lavt prisnivå" }, + "low_soc_charging_level": { "name": "Lad ved lavt ladenivå (SOC)" }, + "minimum_ev_soc": { "name": "Minimum ladenivå (SOC)" } + }, + "select": { + "charge_start_time": { "name": "Starttidspunkt for lading" }, + "charge_completion_time": { "name": "Sluttidspunkt for lading" } + }, + "sensor": { + "charging": { + "name": "Lading", + "state_attributes": { + "current_price": { "name": "Gjeldende pris"}, + "ev_soc": {"name": "Ladenivå (SOC)"}, + "ev_target_soc": {"name": "Ønsket ladenivå (SOC)"}, + "charging_is_planned": {"name": "Lading er planlagt"}, + "charging_start_time": {"name": "Starttidspunkt for lading"}, + "charging_stop_time": {"name": "Stopptidspunkt for lading"}, + "charging_number_of_hours": {"name": "Antall ladetimer"}, + "raw_two_days": {"name": "Strømpriser to dager"}, + "charging_schedule": {"name": "Ladeskjema"} + } + }, + "status": { + "name": "Status", + "state": { + "waiting_for_new_prices": "Venter på nye priser", + "no_charging_planned": "Ingen lading planlagt", + "waiting_for_charging_to_begin": "Venter på at lading skal begynne", + "charging": "Lader", + "keeping_charger_on": "Holder laderen på", + "disconnected": "Frakoblet", + "smart_charging_not_active": "Smart lading ikke aktiv", + "low_price_charging": "Lad ved lav pris", + "low_soc_charging": "Lad ved lavt ladenivå (SOC)" + } + } + }, + "switch": { + "smart_charging_activated": { "name": "Smart lading aktivert" }, + "apply_price_limit": { "name": "Bruk prisgrense" }, + "continuous_charging_preferred": { "name": "Kontinuerlig lading foretrukket" }, + "ev_connected": { "name": "Elbil tilkoblet" }, + "keep_charger_on": { "name": "Hold laderen på" }, + "opportunistic_charging": { "name": "Opportunistisk lading" }, + "low_price_charging": { "name": "Lad ved lav pris" }, + "low_soc_charging": { "name": "Lad ved lavt ladenivå (SOC)" } + } + } +} \ No newline at end of file diff --git a/custom_components/ev_smart_charging/translations/nl.json b/custom_components/ev_smart_charging/translations/nl.json new file mode 100644 index 0000000..89b6351 --- /dev/null +++ b/custom_components/ev_smart_charging/translations/nl.json @@ -0,0 +1,111 @@ +{ + "config": { + "step": { + "user": { + "description": "Configuratie van de naam en gekoppelde entities.", + "data": { + "device_name": "Naam", + "price_sensor": "Electriciteit prijs template entity", + "ev_soc_sensor": "EV SOC sensor", + "ev_target_soc_sensor": "EV doel SOC input (enkele spatie om niet te gebruiken)", + "charger_entity": "Oplader bedienings switch (enkele spatie om niet te gebruiken)", + "ev_controlled": "Een EV integratie bediend het starten/stoppen van het opladen" + } + } + }, + "error": { + "price_not_found": "Electriciteit prijs sensor niet gevonden.", + "price_not_sensor": "De electriciteit prijs entity is geen sensor.", + "sensor_is_not_price": "De Electriciteit prijs sensor heeft niet de benodigde attributen.", + "ev_soc_not_found": "EV SOC sensor is niet gevonden.", + "ev_soc_invalid_data": "De SOC sensor heeft ongeldige data.", + "ev_target_soc_not_found": "EV doel SOC input niet gevonden.", + "ev_target_soc_invalid_data": "De EV doel SOC input heeft ongeldige data.", + "charger_control_switch_not_found": "Oplader bedienings switch niet gevonden.", + "charger_control_switch_not_switch": "Oplader bedienings switch entity is geen switch." + } + }, + "options": { + "step": { + "init": { + "description": "Configuratie van de gekoppelde entities.", + "data": { + "price_sensor": "Electriciteit prijs template entity", + "ev_soc_sensor": "EV SOC sensor", + "ev_target_soc_sensor": "EV doel SOC input (enkele spatie om niet te gebruiken)", + "charger_entity": "Oplader bedienings switch (enkele spatie om niet te gebruiken)", + "ev_controlled": "Een EV integratie bediend het starten/stoppen van het opladen" + } + } + }, + "error": { + "price_not_found": "Electriciteit prijs sensor niet gevonden.", + "price_not_sensor": "De electriciteit prijs entity is geen sensor.", + "sensor_is_not_price": "De Electriciteit prijs sensor heeft niet de benodigde attributen.", + "ev_soc_not_found": "EV SOC sensor is niet gevonden.", + "ev_soc_invalid_data": "De SOC sensor heeft ongeldige data.", + "ev_target_soc_not_found": "EV doel SOC input niet gevonden.", + "ev_target_soc_invalid_data": "De EV doel SOC input heeft ongeldige data.", + "charger_control_switch_not_found": "Oplader bedienings switch niet gevonden.", + "charger_control_switch_not_switch": "Oplader bedienings switch entity is geen switch." + } + }, + "entity": { + "button": { + "manually_start_charging": { "name": "Handmatige start opladen" }, + "manually_stop_charging": { "name": "Handmatige stop opladen" } + }, + "number": { + "charging_speed": { "name": "Oplaadsnelheid" }, + "electricity_price_limit": { "name": "Limiet elektriciteitsprijs" }, + "opportunistic_level": { "name": "Opportunistisch niveau" }, + "low_price_charging_level": { "name": "Lage prijs oplaadniveau" }, + "low_soc_charging_level": { "name": "Lage SOC oplaadniveau" }, + "minimum_ev_soc": { "name": "Minimum EV SOC" } + }, + "select": { + "charge_start_time": { "name": "Oplaad starttijd" }, + "charge_completion_time": { "name": "Oplaad voltooiingstijd" } + }, + "sensor": { + "charging": { + "name": "Opladen", + "state_attributes": { + "current_price": { "name": "Actuele prijs"}, + "ev_soc": {"name": "EV SOC"}, + "ev_target_soc": {"name": "EV instelwaarde SOC"}, + "charging_is_planned": {"name": "Opladen staat gepland"}, + "charging_start_time": {"name": "Start tijd opladen"}, + "charging_stop_time": {"name": "Gereed tijd opladen"}, + "charging_number_of_hours": {"name": "Aantal uren opladen"}, + "raw_two_days": {"name": "Ruwe date van 2 dagen"}, + "charging_schedule": {"name": "Oplaad schema"} + } + }, + "status": { + "name": "Status", + "state": { + "waiting_for_new_prices": "Wachten op nieuwe prijzen", + "no_charging_planned": "Geen opladen gepland", + "waiting_for_charging_to_begin": "Wachten tot het opladen begint", + "charging": "Aan het opladen", + "keeping_charger_on": "Oplader ingeschakeld houden", + "disconnected": "Losgekoppeld", + "smart_charging_not_active": "Slim opladen niet actief", + "low_price_charging": "Lage prijs opladen", + "low_soc_charging": "Lage SOC opladen" + } + } + }, + "switch": { + "smart_charging_activated": { "name": "Activeer slim opladen" }, + "apply_price_limit": { "name": "Prijslimiet toepassen" }, + "continuous_charging_preferred": { "name": "Bij voorkeur continu opladen" }, + "ev_connected": { "name": "EV aangesloten" }, + "keep_charger_on": { "name": "Oplader ingeschakeld houden" }, + "opportunistic_charging": { "name": "Opportunistisch opladen" }, + "low_price_charging": { "name": "Lage prijs opladen" }, + "low_soc_charging": { "name": "Lage SOC opladen" } + } + } +} diff --git a/custom_components/ev_smart_charging/translations/sv.json b/custom_components/ev_smart_charging/translations/sv.json new file mode 100644 index 0000000..3213728 --- /dev/null +++ b/custom_components/ev_smart_charging/translations/sv.json @@ -0,0 +1,111 @@ +{ + "config": { + "step": { + "user": { + "description": "Konfigurering av namn och externa entiteter.", + "data": { + "device_name": "Namn", + "price_sensor": "Elpris sensor", + "ev_soc_sensor": "Entitet för laddnivå (SOC)", + "ev_target_soc_sensor": "Entitet för önskad laddnivå (ett mellanslags för att ta bort)", + "charger_entity": "Brytare för laddningsstyrning (ett mellanslags för att ta bort)", + "ev_controlled": "Elbilsintegration kommer att styra start och stopp av laddning." + } + } + }, + "error": { + "price_not_found": "Elprissensorn hittas inte.", + "price_not_sensor": "Entiteten för elpris är inte en sensor.", + "sensor_is_not_price": "Entiteten för elpris har inte rätt attribut.", + "ev_soc_not_found": "Entiteten för laddnivå (SOC) hittas inte.", + "ev_soc_invalid_data": "Entiteten för laddnivå ger inkorrekt data.", + "ev_target_soc_not_found": "Entiteten för önskad laddnivå (SOC) hittas inte.", + "ev_target_soc_invalid_data": "Entiteten för önskad laddnivå ger inkorrekt data.", + "charger_control_switch_not_found": "Brytare för laddningsstyrning hittas inte.", + "charger_control_switch_not_switch": "Entiteten för laddningsstyrning är inte en brytare." + } + }, + "options": { + "step": { + "init": { + "description": "Konfigurering av externa entiteter.", + "data": { + "price_sensor": "Elpris sensor", + "ev_soc_sensor": "Entitet för laddnivå (SOC)", + "ev_target_soc_sensor": "Entitet för önskad laddnivå (ett mellanslags för att ta bort)", + "charger_entity": "Brytare för laddningsstyrning (ett mellanslags för att ta bort)", + "ev_controlled": "Elbilsintegration kommer att styra start och stopp av laddning." + } + } + }, + "error": { + "price_not_found": "Elprissensorn hittas inte.", + "price_not_sensor": "Entiteten för elpris är inte en sensor.", + "sensor_is_not_price": "Entiteten för elpris har inte rätt attribut.", + "ev_soc_not_found": "Entiteten för laddnivå (SOC) hittas inte.", + "ev_soc_invalid_data": "Entiteten för laddnivå ger inkorrekt data.", + "ev_target_soc_not_found": "Entiteten för önskad laddnivå hittas inte.", + "ev_target_soc_invalid_data": "Entiteten för önskad laddnivå ger inkorrekt data.", + "charger_control_switch_not_found": "Brytare för laddningsstyrning hittas inte.", + "charger_control_switch_not_switch": "Entiteten för laddningsstyrning är inte en brytare." + } + }, + "entity": { + "button": { + "manually_start_charging": { "name": "Starta laddning manuellt" }, + "manually_stop_charging": { "name": "Stoppa laddning manuellt" } + }, + "number": { + "charging_speed": { "name": "Laddningshastighet" }, + "electricity_price_limit": { "name": "Elprisgräns" }, + "opportunistic_level": { "name": "Opportunistisk nivå" }, + "low_price_charging_level": { "name": "Prisnivå för lågprisladdning" }, + "low_soc_charging_level": { "name": "Laddnivå för lågladdnivåladdning" }, + "minimum_ev_soc": { "name": "Lägsta laddnivå (SOC)" } + }, + "select": { + "charge_start_time": { "name": "Starttid för laddning" }, + "charge_completion_time": { "name": "Sluttid för laddning" } + }, + "sensor": { + "charging": { + "name": "Laddning", + "state_attributes": { + "current_price": { "name": "Nuvarande pris"}, + "ev_soc": {"name": "Laddnivå (SOC)"}, + "ev_target_soc": {"name": "Önskad laddnivå (SOC)"}, + "charging_is_planned": {"name": "Laddning är planerad"}, + "charging_start_time": {"name": "Laddning starttid"}, + "charging_stop_time": {"name": "Laddning sluttid"}, + "charging_number_of_hours": {"name": "Antal timmar laddning"}, + "raw_two_days": {"name": "Priser två dagar"}, + "charging_schedule": {"name": "Laddningsschema"} + } + }, + "status": { + "name": "Status", + "state": { + "waiting_for_new_prices": "Väntar på ny prisinformation", + "no_charging_planned": "Ingen laddning planerad", + "waiting_for_charging_to_begin": "Väntar på att laddning ska börja", + "charging": "Laddar", + "keeping_charger_on": "Laddaren hålls aktiv", + "disconnected": "Frånkopplad", + "smart_charging_not_active": "Smart laddning inte aktiverad", + "low_price_charging": "Laddar, lågt pris", + "low_soc_charging": "Laddar, låg laddnivå (SOC)" + } + } + }, + "switch": { + "smart_charging_activated": { "name": "Smart laddning aktiverad" }, + "apply_price_limit": { "name": "Tillämpa elprisgräns" }, + "continuous_charging_preferred": { "name": "Föredra kontinuerlig laddning" }, + "ev_connected": { "name": "Elbil ansluten" }, + "keep_charger_on": { "name": "Håll laddaren aktiv" }, + "opportunistic_charging": { "name": "Opportunistisk laddning" }, + "low_price_charging": { "name": "Laddning vid lågt pris" }, + "low_soc_charging": { "name": "Laddning vid låg laddnivå (SOC)" } + } + } +} \ No newline at end of file diff --git a/hacs.json b/hacs.json index 3e1852c..14f89c1 100644 --- a/hacs.json +++ b/hacs.json @@ -1,6 +1,6 @@ { "name": "EV Smart Charging", - "homeassistant": "2022.7.0", + "homeassistant": "2023.4.0", "zip_release": true, "filename": "ev_smart_charging.zip", "render_readme": true diff --git a/scripts/pytest_all_ha_versions_python310 b/scripts/pytest_all_ha_versions_python310 deleted file mode 100644 index a4e1377..0000000 --- a/scripts/pytest_all_ha_versions_python310 +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env bash - -# https://github.com/home-assistant/core -# https://github.com/MatthewFlamm/pytest-homeassistant-custom-component - -run_first_test() { - local asynciomode="$1" # First parameter, "strict" or "auto" - echo - pip3 list 2>/dev/null | grep homeassistant | grep -v "\-home" - pip3 list 2>/dev/null | grep pytest-homeassistant-custom-component - output=$(pytest -q --no-summary --asyncio-mode=$asynciomode tests 2>&1 | grep passed) - echo "$output" - number1=$(echo "$output" | awk '{print $1}') - if [ -z "$number1" ]; then - echo "No passed test cases!" - exit 1 - fi -} - -run_next_test() { - local asynciomode="$1" # First parameter, "strict" or "auto" - echo - pip3 list 2>/dev/null | grep homeassistant | grep -v "\-home" - pip3 list 2>/dev/null | grep pytest-homeassistant-custom-component - output=$(pytest -q --no-summary --asyncio-mode=$asynciomode tests 2>&1 | grep passed) - echo "$output" - number2=$(echo "$output" | awk '{print $1}') - if [ "$number1" != "$number2" ]; then - echo "Results are different!" - exit 1 - fi -} - -pip3 install -qq pytest-asyncio==0.20.2 - -pip3 install -qq homeassistant==2022.7.0 pytest-homeassistant-custom-component==0.10.2 -run_first_test "strict" - -pip3 install -qq homeassistant==2022.7.7 pytest-homeassistant-custom-component==0.10.8 -run_next_test "strict" - -pip3 install -qq homeassistant==2022.8.7 pytest-homeassistant-custom-component==0.11.12 -run_next_test "strict" - -pip3 install -qq homeassistant==2022.9.7 pytest-homeassistant-custom-component==0.11.26 -run_next_test "strict" - -pip3 install -qq homeassistant==2022.10.5 pytest-homeassistant-custom-component==0.12.10 -run_next_test "strict" - -pip3 install -qq homeassistant==2022.11.4 pytest-homeassistant-custom-component==0.12.21 -run_next_test "strict" - -pip3 install -qq homeassistant==2022.12.8 pytest-homeassistant-custom-component==0.12.36 -run_next_test "auto" - -pip3 install -qq homeassistant==2023.1.7 pytest-homeassistant-custom-component==0.12.49 -run_next_test "auto" - -# As of HA 2023.2, Python 3.9 is not supported. -pip3 install -qq homeassistant==2023.2.5 pytest-homeassistant-custom-component==0.12.57 -run_next_test "auto" - -# As of HA 2023.3, Python 3.11 is supported. -pip3 install -qq homeassistant==2023.3.6 pytest-homeassistant-custom-component==0.13.10 -run_next_test "auto" - -pip3 install -qq homeassistant==2023.4.6 pytest-homeassistant-custom-component==0.13.23 -run_next_test "auto" - -pip3 install -qq homeassistant==2023.5.4 pytest-homeassistant-custom-component==0.13.32 -run_next_test "auto" - -pip3 install -qq homeassistant==2023.6.3 pytest-homeassistant-custom-component==0.13.39 -run_next_test "auto" - -pip3 install -qq homeassistant==2023.7.3 pytest-homeassistant-custom-component==0.13.45 -run_next_test "auto" - -# As of HA 2023.8, Python 3.10 is not supported. diff --git a/scripts/pytest_all_ha_versions_python311 b/scripts/pytest_all_ha_versions_python311 index 99cabfa..8cfe730 100644 --- a/scripts/pytest_all_ha_versions_python311 +++ b/scripts/pytest_all_ha_versions_python311 @@ -32,8 +32,9 @@ run_next_test() { } # As of HA 2023.3, Python 3.11 is supported. -pip3 install -qq homeassistant==2023.3.6 pytest-homeassistant-custom-component==0.13.10 -run_first_test "auto" +# HA 2023.3 does not support entity translation. +#pip3 install -qq homeassistant==2023.3.6 pytest-homeassistant-custom-component==0.13.10 +#run_first_test "auto" pip3 install -qq homeassistant==2023.4.6 pytest-homeassistant-custom-component==0.13.23 run_next_test "auto" diff --git a/scripts/pytest_all_ha_versions_python39 b/scripts/pytest_all_ha_versions_python39 deleted file mode 100644 index 98abbe1..0000000 --- a/scripts/pytest_all_ha_versions_python39 +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env bash - -# https://github.com/home-assistant/core -# https://github.com/MatthewFlamm/pytest-homeassistant-custom-component - -run_first_test() { - local asynciomode="$1" # First parameter, "strict" or "auto" - echo - pip3 list 2>/dev/null | grep homeassistant | grep -v "\-home" - pip3 list 2>/dev/null | grep pytest-homeassistant-custom-component - output=$(pytest -q --no-summary --asyncio-mode=$asynciomode tests 2>&1 | grep passed) - echo "$output" - number1=$(echo "$output" | awk '{print $1}') - if [ -z "$number1" ]; then - echo "No passed test cases!" - exit 1 - fi -} - -run_next_test() { - local asynciomode="$1" # First parameter, "strict" or "auto" - echo - pip3 list 2>/dev/null | grep homeassistant | grep -v "\-home" - pip3 list 2>/dev/null | grep pytest-homeassistant-custom-component - output=$(pytest -q --no-summary --asyncio-mode=$asynciomode tests 2>&1 | grep passed) - echo "$output" - number2=$(echo "$output" | awk '{print $1}') - if [ "$number1" != "$number2" ]; then - echo "Results are different!" - exit 1 - fi -} - -pip3 install -qq pytest-asyncio==0.20.2 - -pip3 install -qq homeassistant==2022.7.0 pytest-homeassistant-custom-component==0.10.2 -run_first_test "strict" - -pip3 install -qq homeassistant==2022.7.7 pytest-homeassistant-custom-component==0.10.8 -run_next_test "strict" - -pip3 install -qq homeassistant==2022.8.7 pytest-homeassistant-custom-component==0.11.12 -run_next_test "strict" - -pip3 install -qq homeassistant==2022.9.7 pytest-homeassistant-custom-component==0.11.26 -run_next_test "strict" - -pip3 install -qq homeassistant==2022.10.5 pytest-homeassistant-custom-component==0.12.10 -run_next_test "strict" - -pip3 install -qq homeassistant==2022.11.4 pytest-homeassistant-custom-component==0.12.21 -run_next_test "strict" - -pip3 install -qq homeassistant==2022.12.8 pytest-homeassistant-custom-component==0.12.36 -run_next_test "auto" - -pip3 install -qq homeassistant==2023.1.7 pytest-homeassistant-custom-component==0.12.49 -run_next_test "auto" - -# As of HA 2023.2, Python 3.9 is not supported. diff --git a/tests/test_sensor.py b/tests/test_sensor.py index 04538a6..0dfc642 100644 --- a/tests/test_sensor.py +++ b/tests/test_sensor.py @@ -107,16 +107,16 @@ async def test_sensor(hass, bypass_validate_input_sensors): extra = sensor.extra_state_attributes assert extra["current_price"] == 12.1 - assert extra["EV SOC"] == 56 - assert extra["EV target SOC"] == 80 - assert extra["Charging is planned"] is True - assert extra["Charging start time"] == datetime( + assert extra["ev_soc"] == 56 + assert extra["ev_target_soc"] == 80 + assert extra["charging_is_planned"] is True + assert extra["charging_start_time"] == datetime( 2022, 9, 30, 1, 0, tzinfo=ZoneInfo(key="Europe/Stockholm") ) - assert extra["Charging stop time"] == datetime( + assert extra["charging_stop_time"] == datetime( 2022, 9, 30, 5, 0, tzinfo=ZoneInfo(key="Europe/Stockholm") ) - assert extra["Charging number of hours"] == 4 + assert extra["charging_number_of_hours"] == 4 # Test sensor_status sensor_status.set_status(CHARGING_STATUS_WAITING_CHARGING)