Compare commits

...
2 Commits
Author SHA1 Message Date
Patrick762 ba6611b084 removed duplicate re.sub() 2024-02-10 13:21:49 +01:00
Patrick762 3e4b8601e8 added dropdown to select device model 2024-02-10 13:19:16 +01:00
5 changed files with 49 additions and 4 deletions

No files matched your search

+15 -2
View File
@@ -24,6 +24,7 @@ from .const import (
CONF_POLLING_TIMEOUT,
CONF_USE_CONTROLS,
DOMAIN,
SUPPORTED_MODELS,
)
_LOGGER = logging.getLogger(__name__)
@@ -58,12 +59,18 @@ class BluettiConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
await self.async_set_unique_id(address, raise_on_progress=False)
self._abort_if_unique_id_configured()
dev_type = get_type_by_bt_name(discovery_info.name)
name = re.sub("[^A-Z0-9]+", "", discovery_info.name)
if dev_type == "Unknown":
dev_type = user_input[CONF_TYPE]
name = name.replace("PBOX", dev_type)
return self.async_create_entry(
title=discovery_info.name,
title=name,
data={
CONF_ADDRESS: discovery_info.address,
CONF_TYPE: dev_type,
CONF_NAME: re.sub("[^A-Z0-9]+", "", discovery_info.name),
CONF_NAME: name,
},
)
@@ -88,6 +95,12 @@ class BluettiConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
for service_info in self._discovered_devices.values()
}
),
vol.Optional(CONF_TYPE): vol.In(
{
model: model
for model in SUPPORTED_MODELS
}
),
}
)
return self.async_show_form(
+11
View File
@@ -17,6 +17,17 @@ CONF_MAX_RETRIES = "max_retries"
DATA_COORDINATOR = "coordinator"
DATA_POLLING_RUNNING = "polling_running"
SUPPORTED_MODELS = [
"AC60",
"AC200M",
"AC300",
"AC500",
"EB3A",
"EP500",
"EP500P",
"EP600",
"EP760",
]
DEVICE_NAME_RE = re.compile(r'^(AC200M|AC300|AC500|AC60|EP500P|EP500|EP600|EP760|EB3A)(\d+)$')
CONTROL_FIELDS = [
+3 -2
View File
@@ -9,7 +9,8 @@
{ "local_name": "EB3A*" },
{ "local_name": "EP500*" },
{ "local_name": "EP600*" },
{ "local_name": "EP760*" }
{ "local_name": "EP760*" },
{ "local_name": "PBOX*" }
],
"codeowners": ["@Patrick762"],
"config_flow": true,
@@ -19,5 +20,5 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/Patrick762/hassio-bluetti-bt/issues",
"requirements": ["bluetti_mqtt==0.15.0"],
"version": "0.0.14"
"version": "0.0.15"
}
@@ -1,4 +1,14 @@
{
"config": {
"step": {
"user": {
"data": {
"address": "Gerät",
"type": "Modell (erforderlich bei PBOX Geräten)"
}
}
}
},
"options": {
"step": {
"init": {
@@ -1,4 +1,14 @@
{
"config": {
"step": {
"user": {
"data": {
"address": "Device",
"type": "Model (required for PBOX devices)"
}
}
}
},
"options": {
"step": {
"init": {