Compare commits

..
5 Commits
Author SHA1 Message Date
Patrick762 0943ecf187 fix manifest version number 2024-02-10 14:20:37 +01:00
Patrick762 58f2ec50c4 added sleep() between pack pollings 2024-02-10 14:15:52 +01:00
Patrick762 ad536235bb removed device name from entity name 2024-02-10 13:59:01 +01:00
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
9 changed files with 55 additions and 7 deletions

No files matched your search

@@ -95,7 +95,7 @@ class BluettiBinarySensor(CoordinatorEntity, BinarySensorEntity):
self._response_key = response_key self._response_key = response_key
self._attr_device_info = device_info self._attr_device_info = device_info
self._attr_name = e_name self._attr_name = name
self._attr_available = False self._attr_available = False
self._attr_unique_id = get_unique_id(e_name) self._attr_unique_id = get_unique_id(e_name)
self._attr_entity_category = category self._attr_entity_category = category
+15 -2
View File
@@ -24,6 +24,7 @@ from .const import (
CONF_POLLING_TIMEOUT, CONF_POLLING_TIMEOUT,
CONF_USE_CONTROLS, CONF_USE_CONTROLS,
DOMAIN, DOMAIN,
SUPPORTED_MODELS,
) )
_LOGGER = logging.getLogger(__name__) _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) await self.async_set_unique_id(address, raise_on_progress=False)
self._abort_if_unique_id_configured() self._abort_if_unique_id_configured()
dev_type = get_type_by_bt_name(discovery_info.name) 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( return self.async_create_entry(
title=discovery_info.name, title=name,
data={ data={
CONF_ADDRESS: discovery_info.address, CONF_ADDRESS: discovery_info.address,
CONF_TYPE: dev_type, 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() 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( return self.async_show_form(
+11
View File
@@ -17,6 +17,17 @@ CONF_MAX_RETRIES = "max_retries"
DATA_COORDINATOR = "coordinator" DATA_COORDINATOR = "coordinator"
DATA_POLLING_RUNNING = "polling_running" 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+)$') DEVICE_NAME_RE = re.compile(r'^(AC200M|AC300|AC500|AC60|EP500P|EP500|EP600|EP760|EB3A)(\d+)$')
CONTROL_FIELDS = [ CONTROL_FIELDS = [
@@ -136,6 +136,9 @@ class PollingCoordinator(DataUpdateCoordinator):
self.bluetti_device.build_setter_command('pack_num', pack) self.bluetti_device.build_setter_command('pack_num', pack)
) )
# We need to wait after switching packs for the data to be available
await asyncio.sleep(5)
for command in self.bluetti_device.pack_polling_commands: for command in self.bluetti_device.pack_polling_commands:
# Request & parse result for each pack # Request & parse result for each pack
try: try:
+3 -2
View File
@@ -9,7 +9,8 @@
{ "local_name": "EB3A*" }, { "local_name": "EB3A*" },
{ "local_name": "EP500*" }, { "local_name": "EP500*" },
{ "local_name": "EP600*" }, { "local_name": "EP600*" },
{ "local_name": "EP760*" } { "local_name": "EP760*" },
{ "local_name": "PBOX*" }
], ],
"codeowners": ["@Patrick762"], "codeowners": ["@Patrick762"],
"config_flow": true, "config_flow": true,
@@ -19,5 +20,5 @@
"iot_class": "local_polling", "iot_class": "local_polling",
"issue_tracker": "https://github.com/Patrick762/hassio-bluetti-bt/issues", "issue_tracker": "https://github.com/Patrick762/hassio-bluetti-bt/issues",
"requirements": ["bluetti_mqtt==0.15.0"], "requirements": ["bluetti_mqtt==0.15.0"],
"version": "0.0.14" "version": "0.0.16"
} }
+1 -1
View File
@@ -126,7 +126,7 @@ class BluettiSensor(CoordinatorEntity, SensorEntity):
self._response_key = response_key self._response_key = response_key
self._attr_device_info = device_info self._attr_device_info = device_info
self._attr_name = e_name self._attr_name = name
self._attr_available = False self._attr_available = False
self._attr_unique_id = get_unique_id(e_name) self._attr_unique_id = get_unique_id(e_name)
self._attr_native_unit_of_measurement = unit_of_measurement self._attr_native_unit_of_measurement = unit_of_measurement
+1 -1
View File
@@ -107,7 +107,7 @@ class BluettiSwitch(CoordinatorEntity, SwitchEntity):
self._attr_device_info = device_info self._attr_device_info = device_info
self._attr_has_entity_name = True self._attr_has_entity_name = True
self._attr_name = e_name self._attr_name = name
self._attr_available = False self._attr_available = False
self._attr_unique_id = get_unique_id(e_name) self._attr_unique_id = get_unique_id(e_name)
self._attr_entity_category = category self._attr_entity_category = category
@@ -1,4 +1,14 @@
{ {
"config": {
"step": {
"user": {
"data": {
"address": "Gerät",
"type": "Modell (erforderlich bei PBOX Geräten)"
}
}
}
},
"options": { "options": {
"step": { "step": {
"init": { "init": {
@@ -1,4 +1,14 @@
{ {
"config": {
"step": {
"user": {
"data": {
"address": "Device",
"type": "Model (required for PBOX devices)"
}
}
}
},
"options": { "options": {
"step": { "step": {
"init": { "init": {