Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 homeassistant/components/matter/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def _update_from_device(self) -> None:
platform=Platform.BINARY_SENSOR,
entity_description=MatterBinarySensorEntityDescription(
key="EnergyEvseSupplyStateSensor",
translation_key="evse_supply_charging_state",
translation_key="evse_supply_state",
device_class=BinarySensorDeviceClass.RUNNING,
device_to_ha={
clusters.EnergyEvse.Enums.SupplyStateEnum.kDisabled: False,
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/matter/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
"evse_plug": {
"name": "Plug state"
},
"evse_supply_charging_state": {
"name": "Supply charging state"
"evse_supply_state": {
"name": "Charger supply state"
},
"boost_state": {
"name": "Boost state"
Expand Down
14 changes: 6 additions & 8 deletions homeassistant/components/wallbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed

from .const import DOMAIN, UPDATE_INTERVAL
from .const import UPDATE_INTERVAL
from .coordinator import InvalidAuth, WallboxCoordinator, async_validate_input

PLATFORMS = [
Expand All @@ -20,8 +20,10 @@
Platform.SWITCH,
]

type WallboxConfigEntry = ConfigEntry[WallboxCoordinator]

async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

async def async_setup_entry(hass: HomeAssistant, entry: WallboxConfigEntry) -> bool:
"""Set up Wallbox from a config entry."""
wallbox = Wallbox(
entry.data[CONF_USERNAME],
Expand All @@ -36,7 +38,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
wallbox_coordinator = WallboxCoordinator(hass, entry, wallbox)
await wallbox_coordinator.async_config_entry_first_refresh()

hass.data.setdefault(DOMAIN, {})[entry.entry_id] = wallbox_coordinator
entry.runtime_data = wallbox_coordinator

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

Expand All @@ -45,8 +47,4 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id)

return unload_ok
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
12 changes: 9 additions & 3 deletions homeassistant/components/wallbox/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ def _set_charging_current(
return data # noqa: TRY300
except requests.exceptions.HTTPError as wallbox_connection_error:
if wallbox_connection_error.response.status_code == 403:
raise InvalidAuth from wallbox_connection_error
raise InvalidAuth(
translation_domain=DOMAIN, translation_key="invalid_auth"
) from wallbox_connection_error
if wallbox_connection_error.response.status_code == 429:
raise HomeAssistantError(
translation_domain=DOMAIN, translation_key="too_many_requests"
Expand All @@ -248,7 +250,9 @@ def _set_icp_current(self, icp_current: float) -> dict[str, Any]:
return data # noqa: TRY300
except requests.exceptions.HTTPError as wallbox_connection_error:
if wallbox_connection_error.response.status_code == 403:
raise InvalidAuth from wallbox_connection_error
raise InvalidAuth(
translation_domain=DOMAIN, translation_key="invalid_auth"
) from wallbox_connection_error
if wallbox_connection_error.response.status_code == 429:
raise HomeAssistantError(
translation_domain=DOMAIN, translation_key="too_many_requests"
Expand Down Expand Up @@ -303,7 +307,9 @@ def _set_lock_unlock(self, lock: bool) -> dict[str, dict[str, dict[str, Any]]]:
return data # noqa: TRY300
except requests.exceptions.HTTPError as wallbox_connection_error:
if wallbox_connection_error.response.status_code == 403:
raise InvalidAuth from wallbox_connection_error
raise InvalidAuth(
translation_domain=DOMAIN, translation_key="invalid_auth"
) from wallbox_connection_error
if wallbox_connection_error.response.status_code == 429:
raise HomeAssistantError(
translation_domain=DOMAIN, translation_key="too_many_requests"
Expand Down
7 changes: 5 additions & 2 deletions homeassistant/components/wallbox/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
CHARGER_DATA_KEY,
CHARGER_LOCKED_UNLOCKED_KEY,
CHARGER_SERIAL_NUMBER_KEY,
DOMAIN,
)
from .coordinator import WallboxCoordinator
from .entity import WallboxEntity
Expand All @@ -32,14 +31,18 @@ async def async_setup_entry(
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
"""Create wallbox lock entities in HASS."""
coordinator: WallboxCoordinator = hass.data[DOMAIN][entry.entry_id]
coordinator: WallboxCoordinator = entry.runtime_data
async_add_entities(
WallboxLock(coordinator, description)
for ent in coordinator.data
if (description := LOCK_TYPES.get(ent))
)


# Coordinator is used to centralize the data updates
PARALLEL_UPDATES = 0


class WallboxLock(WallboxEntity, LockEntity):
"""Representation of a wallbox lock."""

Expand Down
7 changes: 5 additions & 2 deletions homeassistant/components/wallbox/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
CHARGER_MAX_ICP_CURRENT_KEY,
CHARGER_PART_NUMBER_KEY,
CHARGER_SERIAL_NUMBER_KEY,
DOMAIN,
)
from .coordinator import WallboxCoordinator
from .entity import WallboxEntity
Expand Down Expand Up @@ -84,14 +83,18 @@ async def async_setup_entry(
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
"""Create wallbox number entities in HASS."""
coordinator: WallboxCoordinator = hass.data[DOMAIN][entry.entry_id]
coordinator: WallboxCoordinator = entry.runtime_data
async_add_entities(
WallboxNumber(coordinator, entry, description)
for ent in coordinator.data
if (description := NUMBER_TYPES.get(ent))
)


# Coordinator is used to centralize the data updates
PARALLEL_UPDATES = 0


class WallboxNumber(WallboxEntity, NumberEntity):
"""Representation of the Wallbox portal."""

Expand Down
6 changes: 5 additions & 1 deletion homeassistant/components/wallbox/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async def async_setup_entry(
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
"""Create wallbox select entities in HASS."""
coordinator: WallboxCoordinator = hass.data[DOMAIN][entry.entry_id]
coordinator: WallboxCoordinator = entry.runtime_data
if coordinator.data[CHARGER_ECO_SMART_KEY] != EcoSmartMode.DISABLED:
async_add_entities(
WallboxSelect(coordinator, description)
Expand All @@ -74,6 +74,10 @@ async def async_setup_entry(
)


# Coordinator is used to centralize the data updates
PARALLEL_UPDATES = 0


class WallboxSelect(WallboxEntity, SelectEntity):
"""Representation of the Wallbox portal."""

Expand Down
7 changes: 5 additions & 2 deletions homeassistant/components/wallbox/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
CHARGER_SERIAL_NUMBER_KEY,
CHARGER_STATE_OF_CHARGE_KEY,
CHARGER_STATUS_DESCRIPTION_KEY,
DOMAIN,
)
from .coordinator import WallboxCoordinator
from .entity import WallboxEntity
Expand Down Expand Up @@ -174,7 +173,7 @@ async def async_setup_entry(
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
"""Create wallbox sensor entities in HASS."""
coordinator: WallboxCoordinator = hass.data[DOMAIN][entry.entry_id]
coordinator: WallboxCoordinator = entry.runtime_data

async_add_entities(
WallboxSensor(coordinator, description)
Expand All @@ -183,6 +182,10 @@ async def async_setup_entry(
)


# Coordinator is used to centralize the data updates
PARALLEL_UPDATES = 0


class WallboxSensor(WallboxEntity, SensorEntity):
"""Representation of the Wallbox portal."""

Expand Down
8 changes: 8 additions & 0 deletions homeassistant/components/wallbox/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
"station": "Station Serial Number",
"username": "[%key:common::config_flow::data::username%]",
"password": "[%key:common::config_flow::data::password%]"
},
"data_description": {
"station": "Serial number of the charger, this value can be found in the Wallbox App or in the Wallbox Portal.",
"username": "Username for your Wallbox Account.",
"password": "Password for your Wallbox Account."
}
},
"reauth_confirm": {
Expand Down Expand Up @@ -115,6 +120,9 @@
},
"too_many_requests": {
"message": "Error communicating with Wallbox API, too many requests"
},
"invalid_auth": {
"message": "Invalid authentication"
}
}
}
7 changes: 5 additions & 2 deletions homeassistant/components/wallbox/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
CHARGER_PAUSE_RESUME_KEY,
CHARGER_SERIAL_NUMBER_KEY,
CHARGER_STATUS_DESCRIPTION_KEY,
DOMAIN,
ChargerStatus,
)
from .coordinator import WallboxCoordinator
Expand All @@ -34,12 +33,16 @@ async def async_setup_entry(
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
"""Create wallbox sensor entities in HASS."""
coordinator: WallboxCoordinator = hass.data[DOMAIN][entry.entry_id]
coordinator: WallboxCoordinator = entry.runtime_data
async_add_entities(
[WallboxSwitch(coordinator, SWITCH_TYPES[CHARGER_PAUSE_RESUME_KEY])]
)


# Coordinator is used to centralize the data updates
PARALLEL_UPDATES = 0


class WallboxSwitch(WallboxEntity, SwitchEntity):
"""Representation of the Wallbox portal."""

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/wled/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"step": {
"init": {
"data": {
"keep_master_light": "Keep main light, even with 1 LED segment."
"keep_master_light": "Add 'Main' control even with single LED segment"
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions tests/components/matter/snapshots/test_binary_sensor.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@
'state': 'on',
})
# ---
# name: test_binary_sensors[silabs_evse_charging][binary_sensor.evse_supply_charging_state-entry]
# name: test_binary_sensors[silabs_evse_charging][binary_sensor.evse_charger_supply_state-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
Expand All @@ -698,7 +698,7 @@
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': None,
'entity_id': 'binary_sensor.evse_supply_charging_state',
'entity_id': 'binary_sensor.evse_charger_supply_state',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
Expand All @@ -710,24 +710,24 @@
}),
'original_device_class': <BinarySensorDeviceClass.RUNNING: 'running'>,
'original_icon': None,
'original_name': 'Supply charging state',
'original_name': 'Charger supply state',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'evse_supply_charging_state',
'translation_key': 'evse_supply_state',
'unique_id': '00000000000004D2-0000000000000017-MatterNodeDevice-1-EnergyEvseSupplyStateSensor-153-1',
'unit_of_measurement': None,
})
# ---
# name: test_binary_sensors[silabs_evse_charging][binary_sensor.evse_supply_charging_state-state]
# name: test_binary_sensors[silabs_evse_charging][binary_sensor.evse_charger_supply_state-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'running',
'friendly_name': 'evse Supply charging state',
'friendly_name': 'evse Charger supply state',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.evse_supply_charging_state',
'entity_id': 'binary_sensor.evse_charger_supply_state',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
Expand Down
4 changes: 2 additions & 2 deletions tests/components/matter/test_binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ async def test_evse_sensor(
assert state
assert state.state == "off"

# Test SupplyStateEnum value with binary_sensor.evse_supply_charging
entity_id = "binary_sensor.evse_supply_charging_state"
# Test SupplyStateEnum value with binary_sensor.evse_charger_supply_state
entity_id = "binary_sensor.evse_charger_supply_state"
state = hass.states.get(entity_id)
assert state
assert state.state == "on"
Expand Down
Loading
Loading