Fix Home Connect service validation error placeholders (#131294)

This commit is contained in:
J. Diego Rodríguez Royo 2024-11-22 19:28:08 +01:00 committed by GitHub
parent c61e94dac2
commit 53b87f47fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 14 deletions

View File

@ -329,10 +329,10 @@ async def async_migrate_entry(
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 "?",
}

View File

@ -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}"

View File

@ -162,7 +162,7 @@ async def test_switch_functionality(
SERVICE_TURN_OFF,
"set_setting",
"Dishwasher",
r"Error.*turn.*off.*appliance.*value",
r"Error.*turn.*off.*",
),
(
"switch.dishwasher_power",
@ -170,7 +170,7 @@ async def test_switch_functionality(
SERVICE_TURN_ON,
"set_setting",
"Dishwasher",
r"Error.*turn.*on.*appliance.*",
r"Error.*turn.*on.*",
),
(
"switch.dishwasher_child_lock",
@ -178,7 +178,7 @@ async def test_switch_functionality(
SERVICE_TURN_ON,
"set_setting",
"Dishwasher",
r"Error.*turn.*on.*key.*",
r"Error.*turn.*on.*",
),
(
"switch.dishwasher_child_lock",
@ -186,7 +186,7 @@ async def test_switch_functionality(
SERVICE_TURN_OFF,
"set_setting",
"Dishwasher",
r"Error.*turn.*off.*key.*",
r"Error.*turn.*off.*",
),
],
indirect=["problematic_appliance"],
@ -297,7 +297,7 @@ 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",
@ -305,7 +305,7 @@ async def test_ent_desc_switch_functionality(
SERVICE_TURN_OFF,
"set_setting",
"FridgeFreezer",
r"Error.*turn.*off.*key.*",
r"Error.*turn.*off.*",
),
],
indirect=["problematic_appliance"],