Skip to content

Commit

Permalink
Fix Home Connect service validation error placeholders (#131294)
Browse files Browse the repository at this point in the history
  • Loading branch information
Diegorro98 authored Nov 22, 2024
1 parent c61e94d commit 53b87f4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions homeassistant/components/home_connect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,10 @@ def update_unique_id(

def get_dict_from_home_connect_error(err: api.HomeConnectError) -> dict[str, Any]:
"""Return a dict from a Home Connect error."""
return (
err.args[0]
return {
"description": cast(dict[str, Any], err.args[0]).get("description", "?")
if len(err.args) > 0 and isinstance(err.args[0], dict)
else {"description": err.args[0]}
else err.args[0]
if len(err.args) > 0 and isinstance(err.args[0], str)
else {}
)
else "?",
}
6 changes: 3 additions & 3 deletions homeassistant/components/home_connect/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
"message": "Error while trying to set color of {entity_id}: {description}"
},
"set_setting": {
"message": "Error while trying to assign the value \"{value}\" to the setting \"{key}\" for {entity_id}: {description}"
"message": "Error while trying to assign the value \"{value}\" to the setting \"{setting_key}\" for {entity_id}: {description}"
},
"turn_on": {
"message": "Error while trying to turn on {entity_id} ({key}): {description}"
"message": "Error while trying to turn on {entity_id} ({setting_key}): {description}"
},
"turn_off": {
"message": "Error while trying to turn off {entity_id} ({key}): {description}"
"message": "Error while trying to turn off {entity_id} ({setting_key}): {description}"
},
"start_program": {
"message": "Error while trying to start program {program}: {description}"
Expand Down
12 changes: 6 additions & 6 deletions tests/components/home_connect/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,31 +162,31 @@ async def test_switch_functionality(
SERVICE_TURN_OFF,
"set_setting",
"Dishwasher",
r"Error.*turn.*off.*appliance.*value",
r"Error.*turn.*off.*",
),
(
"switch.dishwasher_power",
{BSH_POWER_STATE: {"value": ""}},
SERVICE_TURN_ON,
"set_setting",
"Dishwasher",
r"Error.*turn.*on.*appliance.*",
r"Error.*turn.*on.*",
),
(
"switch.dishwasher_child_lock",
{BSH_CHILD_LOCK_STATE: {"value": ""}},
SERVICE_TURN_ON,
"set_setting",
"Dishwasher",
r"Error.*turn.*on.*key.*",
r"Error.*turn.*on.*",
),
(
"switch.dishwasher_child_lock",
{BSH_CHILD_LOCK_STATE: {"value": ""}},
SERVICE_TURN_OFF,
"set_setting",
"Dishwasher",
r"Error.*turn.*off.*key.*",
r"Error.*turn.*off.*",
),
],
indirect=["problematic_appliance"],
Expand Down Expand Up @@ -297,15 +297,15 @@ async def test_ent_desc_switch_functionality(
SERVICE_TURN_ON,
"set_setting",
"FridgeFreezer",
r"Error.*turn.*on.*key.*",
r"Error.*turn.*on.*",
),
(
"switch.fridgefreezer_freezer_super_mode",
{REFRIGERATION_SUPERMODEFREEZER: {"value": ""}},
SERVICE_TURN_OFF,
"set_setting",
"FridgeFreezer",
r"Error.*turn.*off.*key.*",
r"Error.*turn.*off.*",
),
],
indirect=["problematic_appliance"],
Expand Down

0 comments on commit 53b87f4

Please sign in to comment.