mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Use smlight discovery hostname as device name (#125359)
* Use smlight discovery hostname as device name * Update reauth flow name * Drop host from description
This commit is contained in:
parent
ccbc300b68
commit
ff20131af1
@ -139,10 +139,6 @@ class SmlightConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self.context["entry_id"]
|
self.context["entry_id"]
|
||||||
)
|
)
|
||||||
host = entry_data[CONF_HOST]
|
host = entry_data[CONF_HOST]
|
||||||
self.context["title_placeholders"] = {
|
|
||||||
"host": host,
|
|
||||||
"name": entry_data.get(CONF_USERNAME, "unknown"),
|
|
||||||
}
|
|
||||||
self.client = Api2(host, session=async_get_clientsession(self.hass))
|
self.client = Api2(host, session=async_get_clientsession(self.hass))
|
||||||
self.host = host
|
self.host = host
|
||||||
|
|
||||||
@ -166,7 +162,8 @@ class SmlightConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
assert self._reauth_entry is not None
|
assert self._reauth_entry is not None
|
||||||
|
|
||||||
return self.async_update_reload_and_abort(
|
return self.async_update_reload_and_abort(
|
||||||
self._reauth_entry, data={**user_input, CONF_HOST: self.host}
|
self._reauth_entry,
|
||||||
|
data={**self._reauth_entry.data, **user_input},
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
@ -197,4 +194,5 @@ class SmlightConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
user_input[CONF_HOST] = self.host
|
user_input[CONF_HOST] = self.host
|
||||||
|
|
||||||
assert info.model is not None
|
assert info.model is not None
|
||||||
return self.async_create_entry(title=info.model, data=user_input)
|
title = self.context.get("title_placeholders", {}).get(CONF_NAME) or info.model
|
||||||
|
return self.async_create_entry(title=title, data=user_input)
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
},
|
},
|
||||||
"reauth_confirm": {
|
"reauth_confirm": {
|
||||||
"title": "[%key:common::config_flow::title::reauth%]",
|
"title": "[%key:common::config_flow::title::reauth%]",
|
||||||
"description": "Please enter the correct username and password for host: {host}",
|
"description": "Please enter the correct username and password",
|
||||||
"data": {
|
"data": {
|
||||||
"username": "[%key:common::config_flow::data::username%]",
|
"username": "[%key:common::config_flow::data::username%]",
|
||||||
"password": "[%key:common::config_flow::data::password%]"
|
"password": "[%key:common::config_flow::data::password%]"
|
||||||
|
@ -91,7 +91,7 @@ async def test_zeroconf_flow(
|
|||||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["context"]["source"] == "zeroconf"
|
assert result2["context"]["source"] == "zeroconf"
|
||||||
assert result2["context"]["unique_id"] == "aa:bb:cc:dd:ee:ff"
|
assert result2["context"]["unique_id"] == "aa:bb:cc:dd:ee:ff"
|
||||||
assert result2["title"] == "SLZB-06p7"
|
assert result2["title"] == "slzb-06"
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
CONF_HOST: MOCK_HOST,
|
CONF_HOST: MOCK_HOST,
|
||||||
}
|
}
|
||||||
@ -143,7 +143,7 @@ async def test_zeroconf_flow_auth(
|
|||||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result3["context"]["source"] == "zeroconf"
|
assert result3["context"]["source"] == "zeroconf"
|
||||||
assert result3["context"]["unique_id"] == "aa:bb:cc:dd:ee:ff"
|
assert result3["context"]["unique_id"] == "aa:bb:cc:dd:ee:ff"
|
||||||
assert result3["title"] == "SLZB-06p7"
|
assert result3["title"] == "slzb-06"
|
||||||
assert result3["data"] == {
|
assert result3["data"] == {
|
||||||
CONF_USERNAME: MOCK_USERNAME,
|
CONF_USERNAME: MOCK_USERNAME,
|
||||||
CONF_PASSWORD: MOCK_PASSWORD,
|
CONF_PASSWORD: MOCK_PASSWORD,
|
||||||
@ -356,7 +356,7 @@ async def test_zeroconf_legacy_mac(
|
|||||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["context"]["source"] == "zeroconf"
|
assert result2["context"]["source"] == "zeroconf"
|
||||||
assert result2["context"]["unique_id"] == "aa:bb:cc:dd:ee:ff"
|
assert result2["context"]["unique_id"] == "aa:bb:cc:dd:ee:ff"
|
||||||
assert result2["title"] == "SLZB-06p7"
|
assert result2["title"] == "slzb-06"
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
CONF_HOST: MOCK_HOST,
|
CONF_HOST: MOCK_HOST,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user