Introduced abort in config flow if all entities are deselected when editing a device

This commit is contained in:
rospogrigio
2023-01-10 12:54:39 +01:00
committed by rospogrigio
parent 0f3160f178
commit c379645ea1
2 changed files with 7 additions and 1 deletions

View File

@@ -570,6 +570,11 @@ class LocalTuyaOptionsFlowHandler(config_entries.OptionsFlow):
CONF_ENTITIES: [], CONF_ENTITIES: [],
} }
) )
if len(user_input[CONF_ENTITIES]) == 0:
return self.async_abort(
reason="no_entities",
description_placeholders={},
)
if user_input[CONF_ENTITIES]: if user_input[CONF_ENTITIES]:
entity_ids = [ entity_ids = [
int(entity.split(":")[0]) int(entity.split(":")[0])

View File

@@ -33,7 +33,8 @@
"options": { "options": {
"abort": { "abort": {
"already_configured": "Device has already been configured.", "already_configured": "Device has already been configured.",
"device_success": "Device {dev_name} successfully {action}." "device_success": "Device {dev_name} successfully {action}.",
"no_entities": "Cannot remove all entities from a device.\nIf you want to delete a device, enter it in the Devices menu, click the 3 dots in the 'Device info' frame, and press the Delete button."
}, },
"error": { "error": {
"authentication_failed": "Failed to authenticate.\n{msg}", "authentication_failed": "Failed to authenticate.\n{msg}",