diff --git a/custom_components/bluetti_bt/__init__.py b/custom_components/bluetti_bt/__init__.py index 4ac4aac..36b1f4b 100644 --- a/custom_components/bluetti_bt/__init__.py +++ b/custom_components/bluetti_bt/__init__.py @@ -37,6 +37,7 @@ def device_info(entry: ConfigEntry) -> DeviceInfo: identifiers={(DOMAIN, entry.data.get(CONF_ADDRESS))}, name=entry.title, manufacturer=MANUFACTURER, + model=get_type_by_bt_name(entry.title), ) @@ -46,3 +47,23 @@ def get_unique_id(name: str, sensor_type: str | None = None): if sensor_type is not None: return f"{sensor_type}.{res}" return res + + +def get_type_by_bt_name(bt_name: str): + """Get the device type.""" + dev_type = "Unknown" + if bt_name.startswith("AC200M"): + dev_type = "AC200M" + elif bt_name.startswith("AC300"): + dev_type = "AC300" + elif bt_name.startswith("AC500"): + dev_type = "AC500" + elif bt_name.startswith("AC60"): + dev_type = "AC60" + elif bt_name.startswith("EB3A"): + dev_type = "EB3A" + elif bt_name.startswith("EP500"): + dev_type = "EP500" + elif bt_name.startswith("EP600"): + dev_type = "EP600" + return dev_type diff --git a/custom_components/bluetti_bt/manifest.json b/custom_components/bluetti_bt/manifest.json index 0524a3e..0811f83 100644 --- a/custom_components/bluetti_bt/manifest.json +++ b/custom_components/bluetti_bt/manifest.json @@ -4,6 +4,8 @@ "bluetooth": [ { "local_name": "AC200M*" }, { "local_name": "AC300*" }, + { "local_name": "AC500*" }, + { "local_name": "AC60*" }, { "local_name": "EB3A*" }, { "local_name": "EP500*" }, { "local_name": "EP600*" } diff --git a/custom_components/bluetti_bt/sensor.py b/custom_components/bluetti_bt/sensor.py index ccd3052..ebcc67e 100644 --- a/custom_components/bluetti_bt/sensor.py +++ b/custom_components/bluetti_bt/sensor.py @@ -36,7 +36,7 @@ async def async_setup_entry( # Generate device info _LOGGER.error("Creating sensors for device %s", entry.data.get(CONF_ADDRESS)) device_info = dev_info(entry) - async_add_entities(Battery(coordinator, device_info)) + async_add_entities([Battery(coordinator, device_info)]) class PollingCoordinator(DataUpdateCoordinator):