add polling for battery pack voltage & percent
This commit is contained in:
1 parent
296c9cbfd3
commit
b8a73e0ab9
2 files changed
+107
-3
No files matched your search
@@ -27,6 +27,7 @@ from bluetti_mqtt.mqtt_client import (
|
||||
NORMAL_DEVICE_FIELDS,
|
||||
DC_INPUT_FIELDS,
|
||||
MqttFieldType,
|
||||
battery_pack_fields,
|
||||
)
|
||||
|
||||
from . import device_info as dev_info, get_unique_id
|
||||
@@ -59,8 +60,14 @@ async def async_setup_entry(
|
||||
all_fields = NORMAL_DEVICE_FIELDS
|
||||
all_fields.update(DC_INPUT_FIELDS)
|
||||
all_fields.update(ADDITIONAL_DEVICE_FIELDS)
|
||||
# add pack fields for device
|
||||
_LOGGER.info("Device type(%s) pack_num_max(%s)", bluetti_device.type, bluetti_device.pack_num_max)
|
||||
for pack in range (1, bluetti_device.pack_num_max + 1):
|
||||
for name, field in battery_pack_fields(pack).items():
|
||||
all_fields.update({name+str(pack):field})
|
||||
|
||||
for field_key, field_config in all_fields.items():
|
||||
if bluetti_device.has_field(field_key):
|
||||
if bluetti_device.has_field(field_key) or field_config.id_override is not None:
|
||||
category = None
|
||||
if field_config.setter is True or field_key in DIAGNOSTIC_FIELDS:
|
||||
category = EntityCategory.DIAGNOSTIC
|
||||
@@ -144,6 +151,7 @@ class BluettiSensor(CoordinatorEntity, SensorEntity):
|
||||
|
||||
response_data = self.coordinator.data.get(self._response_key)
|
||||
if response_data is None:
|
||||
_LOGGER.debug("No data for available for (%s)",self._response_key)
|
||||
self._attr_available = False
|
||||
return
|
||||
|
||||
|
||||
Reference in new issue
Block a user