Use friendly_name instead of name in config entry
This commit is contained in:
committed by
rospogrigio
parent
9973c5fdcb
commit
e79b4cf619
@@ -11,7 +11,6 @@ from homeassistant.const import (
|
|||||||
CONF_ID,
|
CONF_ID,
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
CONF_DEVICE_ID,
|
CONF_DEVICE_ID,
|
||||||
CONF_NAME,
|
|
||||||
CONF_FRIENDLY_NAME,
|
CONF_FRIENDLY_NAME,
|
||||||
CONF_PLATFORM,
|
CONF_PLATFORM,
|
||||||
CONF_SWITCHES,
|
CONF_SWITCHES,
|
||||||
@@ -32,7 +31,7 @@ NO_ADDITIONAL_PLATFORMS = "no_additional_platforms"
|
|||||||
|
|
||||||
USER_SCHEMA = vol.Schema(
|
USER_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_NAME): str,
|
vol.Required(CONF_FRIENDLY_NAME): str,
|
||||||
vol.Required(CONF_HOST): str,
|
vol.Required(CONF_HOST): str,
|
||||||
vol.Required(CONF_DEVICE_ID): str,
|
vol.Required(CONF_DEVICE_ID): str,
|
||||||
vol.Required(CONF_LOCAL_KEY): str,
|
vol.Required(CONF_LOCAL_KEY): str,
|
||||||
@@ -133,7 +132,7 @@ class LocaltuyaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
if user_input.get(NO_ADDITIONAL_PLATFORMS):
|
if user_input.get(NO_ADDITIONAL_PLATFORMS):
|
||||||
config = {**self.basic_info, CONF_ENTITIES: self.entities}
|
config = {**self.basic_info, CONF_ENTITIES: self.entities}
|
||||||
return self.async_create_entry(title=config[CONF_NAME], data=config)
|
return self.async_create_entry(title=config[CONF_FRIENDLY_NAME], data=config)
|
||||||
|
|
||||||
self._set_platform(user_input[PLATFORM_TO_ADD])
|
self._set_platform(user_input[PLATFORM_TO_ADD])
|
||||||
return await self.async_step_add_entity()
|
return await self.async_step_add_entity()
|
||||||
@@ -193,7 +192,6 @@ class LocaltuyaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
#print('ENTITIES: [{}] '.format(self.entities))
|
#print('ENTITIES: [{}] '.format(self.entities))
|
||||||
config = {
|
config = {
|
||||||
CONF_NAME: f"{user_input[CONF_FRIENDLY_NAME]} (YAML)",
|
|
||||||
CONF_FRIENDLY_NAME: f"{user_input[CONF_FRIENDLY_NAME]}",
|
CONF_FRIENDLY_NAME: f"{user_input[CONF_FRIENDLY_NAME]}",
|
||||||
CONF_HOST: user_input[CONF_HOST],
|
CONF_HOST: user_input[CONF_HOST],
|
||||||
CONF_DEVICE_ID: user_input[CONF_DEVICE_ID],
|
CONF_DEVICE_ID: user_input[CONF_DEVICE_ID],
|
||||||
@@ -202,7 +200,7 @@ class LocaltuyaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
CONF_ENTITIES: self.entities,
|
CONF_ENTITIES: self.entities,
|
||||||
}
|
}
|
||||||
self._abort_if_unique_id_configured(updates=config)
|
self._abort_if_unique_id_configured(updates=config)
|
||||||
return self.async_create_entry(title=config[CONF_NAME], data=config)
|
return self.async_create_entry(title=config[CONF_FRIENDLY_NAME], data=config)
|
||||||
|
|
||||||
def _set_platform(self, platform):
|
def _set_platform(self, platform):
|
||||||
integration_module = ".".join(__name__.split(".")[:-1])
|
integration_module = ".".join(__name__.split(".")[:-1])
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
"title": "Add Tuya device",
|
"title": "Add Tuya device",
|
||||||
"description": "Fill in the basic details and pick device type. The name entered here will be used to identify the integration itself (as seen in the `Integrations` page). You will add entities and give them names in the following steps.",
|
"description": "Fill in the basic details and pick device type. The name entered here will be used to identify the integration itself (as seen in the `Integrations` page). You will add entities and give them names in the following steps.",
|
||||||
"data": {
|
"data": {
|
||||||
"name": "Name",
|
"friendly_name": "Name",
|
||||||
"host": "Host",
|
"host": "Host",
|
||||||
"device_id": "Device ID",
|
"device_id": "Device ID",
|
||||||
"local_key": "Local key",
|
"local_key": "Local key",
|
||||||
|
Reference in New Issue
Block a user