diff --git a/homeassistant/components/wallbox/__init__.py b/homeassistant/components/wallbox/__init__.py index af1c59e42c1..f9510421ba0 100644 --- a/homeassistant/components/wallbox/__init__.py +++ b/homeassistant/components/wallbox/__init__.py @@ -29,6 +29,8 @@ from .const import ( CONF_SERIAL_NUMBER_KEY, CONF_SOFTWARE_KEY, CONF_STATION, + CONF_STATUS_DESCRIPTION_KEY, + CONF_STATUS_ID_KEY, DOMAIN, ) @@ -37,6 +39,39 @@ _LOGGER = logging.getLogger(__name__) PLATFORMS = [Platform.SENSOR, Platform.NUMBER, Platform.LOCK] UPDATE_INTERVAL = 30 +# Translation of StatusId based on Wallbox portal code: +# https://my.wallbox.com/src/utilities/charger/chargerStatuses.js +CHARGER_STATUS: dict[int, str] = { + 0: "Disconnected", + 14: "Error", + 15: "Error", + 161: "Ready", + 162: "Ready", + 163: "Disconnected", + 164: "Waiting", + 165: "Locked", + 166: "Updating", + 177: "Scheduled", + 178: "Paused", + 179: "Scheduled", + 180: "Waiting for car demand", + 181: "Waiting for car demand", + 182: "Paused", + 183: "Waiting in queue by Power Sharing", + 184: "Waiting in queue by Power Sharing", + 185: "Waiting in queue by Power Boost", + 186: "Waiting in queue by Power Boost", + 187: "Waiting MID failed", + 188: "Waiting MID safety margin exceeded", + 189: "Waiting in queue by Eco-Smart", + 193: "Charging", + 194: "Charging", + 195: "Charging", + 196: "Discharging", + 209: "Locked", + 210: "Locked", +} + class WallboxCoordinator(DataUpdateCoordinator[dict[str, Any]]): """Wallbox Coordinator class.""" @@ -86,6 +121,9 @@ class WallboxCoordinator(DataUpdateCoordinator[dict[str, Any]]): data[CONF_LOCKED_UNLOCKED_KEY] = data[CONF_DATA_KEY][ CONF_LOCKED_UNLOCKED_KEY ] + data[CONF_STATUS_DESCRIPTION_KEY] = CHARGER_STATUS.get( + data[CONF_STATUS_ID_KEY], "Unknown" + ) return data diff --git a/homeassistant/components/wallbox/const.py b/homeassistant/components/wallbox/const.py index c5be4d1606d..e4b33f6bc6b 100644 --- a/homeassistant/components/wallbox/const.py +++ b/homeassistant/components/wallbox/const.py @@ -21,5 +21,6 @@ CONF_MAX_CHARGING_CURRENT_KEY = "max_charging_current" CONF_LOCKED_UNLOCKED_KEY = "locked" CONF_NAME_KEY = "name" CONF_STATE_OF_CHARGE_KEY = "state_of_charge" +CONF_STATUS_ID_KEY = "status_id" CONF_STATUS_DESCRIPTION_KEY = "status_description" CONF_CONNECTIONS = "connections" diff --git a/tests/components/wallbox/__init__.py b/tests/components/wallbox/__init__.py index 8a31d2ebcd5..c778f02b454 100644 --- a/tests/components/wallbox/__init__.py +++ b/tests/components/wallbox/__init__.py @@ -20,6 +20,7 @@ from homeassistant.components.wallbox.const import ( CONF_SERIAL_NUMBER_KEY, CONF_SOFTWARE_KEY, CONF_STATION, + CONF_STATUS_ID_KEY, DOMAIN, ) from homeassistant.const import CONF_PASSWORD, CONF_USERNAME @@ -33,6 +34,7 @@ test_response = json.loads( json.dumps( { CONF_CHARGING_POWER_KEY: 0, + CONF_STATUS_ID_KEY: 161, CONF_MAX_AVAILABLE_POWER_KEY: 25.2, CONF_CHARGING_SPEED_KEY: 0, CONF_ADDED_RANGE_KEY: 150,