mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Hide mac address from HomeWizard Energy config entry/discovery titles (#102931)
This commit is contained in:
parent
4fa551612e
commit
100c3079ae
@ -62,7 +62,7 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
self._abort_if_unique_id_configured(updates=user_input)
|
||||
return self.async_create_entry(
|
||||
title=f"{device_info.product_name} ({device_info.serial})",
|
||||
title=f"{device_info.product_name}",
|
||||
data=user_input,
|
||||
)
|
||||
|
||||
@ -121,14 +121,18 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
errors = {"base": ex.error_code}
|
||||
else:
|
||||
return self.async_create_entry(
|
||||
title=f"{self.discovery.product_name} ({self.discovery.serial})",
|
||||
title=self.discovery.product_name,
|
||||
data={CONF_IP_ADDRESS: self.discovery.ip},
|
||||
)
|
||||
|
||||
self._set_confirm_only()
|
||||
self.context["title_placeholders"] = {
|
||||
"name": f"{self.discovery.product_name} ({self.discovery.serial})"
|
||||
}
|
||||
|
||||
# We won't be adding mac/serial to the title for devices
|
||||
# that users generally don't have multiple of.
|
||||
name = self.discovery.product_name
|
||||
if self.discovery.product_type not in ["HWE-P1", "HWE-WTR"]:
|
||||
name = f"{name} ({self.discovery.serial})"
|
||||
self.context["title_placeholders"] = {"name": name}
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="discovery_confirm",
|
||||
|
@ -43,7 +43,7 @@ async def test_manual_flow_works(
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["title"] == "P1 meter (aabbccddeeff)"
|
||||
assert result["title"] == "P1 meter"
|
||||
assert result["data"][CONF_IP_ADDRESS] == "2.2.2.2"
|
||||
|
||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
||||
@ -68,8 +68,8 @@ async def test_discovery_flow_works(
|
||||
properties={
|
||||
"api_enabled": "1",
|
||||
"path": "/api/v1",
|
||||
"product_name": "P1 meter",
|
||||
"product_type": "HWE-P1",
|
||||
"product_name": "Energy Socket",
|
||||
"product_type": "HWE-SKT",
|
||||
"serial": "aabbccddeeff",
|
||||
},
|
||||
)
|
||||
@ -109,11 +109,11 @@ async def test_discovery_flow_works(
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "P1 meter (aabbccddeeff)"
|
||||
assert result["title"] == "Energy Socket"
|
||||
assert result["data"][CONF_IP_ADDRESS] == "192.168.43.183"
|
||||
|
||||
assert result["result"]
|
||||
assert result["result"].unique_id == "HWE-P1_aabbccddeeff"
|
||||
assert result["result"].unique_id == "HWE-SKT_aabbccddeeff"
|
||||
|
||||
|
||||
async def test_discovery_flow_during_onboarding(
|
||||
@ -149,7 +149,7 @@ async def test_discovery_flow_during_onboarding(
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "P1 meter (aabbccddeeff)"
|
||||
assert result["title"] == "P1 meter"
|
||||
assert result["data"][CONF_IP_ADDRESS] == "192.168.43.183"
|
||||
|
||||
assert result["result"]
|
||||
@ -214,7 +214,7 @@ async def test_discovery_flow_during_onboarding_disabled_api(
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "P1 meter (aabbccddeeff)"
|
||||
assert result["title"] == "P1 meter"
|
||||
assert result["data"][CONF_IP_ADDRESS] == "192.168.43.183"
|
||||
|
||||
assert result["result"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user