updated version number, added logging
This commit is contained in:
1 parent
4710a8183f
commit
14f2219b94
3 files changed
+14
-6
No files matched your search
@@ -155,6 +155,7 @@ class PollingCoordinator(DataUpdateCoordinator):
|
|||||||
self.bluetti_device = DummyDevice(bluetti_device)
|
self.bluetti_device = DummyDevice(bluetti_device)
|
||||||
|
|
||||||
# Create client
|
# Create client
|
||||||
|
self.logger.debug("Creating client")
|
||||||
device = bluetooth.async_ble_device_from_address(hass, address)
|
device = bluetooth.async_ble_device_from_address(hass, address)
|
||||||
if device is None:
|
if device is None:
|
||||||
self.logger.error("Device %s not available", mac_loggable(address))
|
self.logger.error("Device %s not available", mac_loggable(address))
|
||||||
@@ -195,7 +196,7 @@ class PollingCoordinator(DataUpdateCoordinator):
|
|||||||
if attempt == max_retries:
|
if attempt == max_retries:
|
||||||
raise # pass exception on max_retries attempt
|
raise # pass exception on max_retries attempt
|
||||||
else:
|
else:
|
||||||
self.logger.debug(f"Connect unsucessful (attempt {attempt}): {e}. Retrying...")
|
self.logger.warning(f"Connect unsucessful (attempt {attempt}): {e}. Retrying...")
|
||||||
await asyncio.sleep(2)
|
await asyncio.sleep(2)
|
||||||
|
|
||||||
# Attach notifier if needed
|
# Attach notifier if needed
|
||||||
@@ -220,7 +221,7 @@ class PollingCoordinator(DataUpdateCoordinator):
|
|||||||
self.logger.warning("Got a parse exception...")
|
self.logger.warning("Got a parse exception...")
|
||||||
|
|
||||||
if len(self.bluetti_device.pack_polling_commands) > 0:
|
if len(self.bluetti_device.pack_polling_commands) > 0:
|
||||||
_LOGGER.debug("Polling battery packs")
|
self.logger.debug("Polling battery packs")
|
||||||
# pack polling
|
# pack polling
|
||||||
for pack in range (1, self.bluetti_device.pack_num_max + 1):
|
for pack in range (1, self.bluetti_device.pack_num_max + 1):
|
||||||
# Set current pack number
|
# Set current pack number
|
||||||
@@ -251,7 +252,7 @@ class PollingCoordinator(DataUpdateCoordinator):
|
|||||||
self.logger.warning("Got a parse exception...")
|
self.logger.warning("Got a parse exception...")
|
||||||
|
|
||||||
except TimeoutError:
|
except TimeoutError:
|
||||||
self.logger.debug("Polling timed out for device %s", mac_loggable(self._address))
|
self.logger.warning("Polling timed out for device %s", mac_loggable(self._address))
|
||||||
return None
|
return None
|
||||||
except BleakError as err:
|
except BleakError as err:
|
||||||
self.logger.warning("Bleak error: %s", err)
|
self.logger.warning("Bleak error: %s", err)
|
||||||
|
|||||||
@@ -18,5 +18,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.11"
|
"version": "2023.12.1"
|
||||||
}
|
}
|
||||||
@@ -143,9 +143,16 @@ class BluettiSensor(CoordinatorEntity, SensorEntity):
|
|||||||
if self.coordinator.persistent_conn and not self.coordinator.client.is_connected:
|
if self.coordinator.persistent_conn and not self.coordinator.client.is_connected:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self.coordinator.data is None:
|
||||||
|
_LOGGER.warning(
|
||||||
|
"Data from coordinator is None. Skipping update for %s",
|
||||||
|
unique_id_loggable(self._attr_unique_id)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
_LOGGER.debug("Updating state of %s", unique_id_loggable(self._attr_unique_id))
|
_LOGGER.debug("Updating state of %s", unique_id_loggable(self._attr_unique_id))
|
||||||
if not isinstance(self.coordinator.data, dict):
|
if not isinstance(self.coordinator.data, dict):
|
||||||
_LOGGER.debug(
|
_LOGGER.warning(
|
||||||
"Invalid data from coordinator (sensor.%s)", unique_id_loggable(self._attr_unique_id)
|
"Invalid data from coordinator (sensor.%s)", unique_id_loggable(self._attr_unique_id)
|
||||||
)
|
)
|
||||||
self._attr_available = False
|
self._attr_available = False
|
||||||
@@ -153,7 +160,7 @@ class BluettiSensor(CoordinatorEntity, SensorEntity):
|
|||||||
|
|
||||||
response_data = self.coordinator.data.get(self._response_key)
|
response_data = self.coordinator.data.get(self._response_key)
|
||||||
if response_data is None:
|
if response_data is None:
|
||||||
_LOGGER.debug("No data for available for (%s)", self._response_key)
|
_LOGGER.warning("No data for available for (%s)", self._response_key)
|
||||||
self._attr_available = False
|
self._attr_available = False
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user