From 29e4efc284c9902d971c94d719cde8cdefced1f7 Mon Sep 17 00:00:00 2001 From: Harvey Lelliott <42912136+flip-dots@users.noreply.github.com> Date: Sun, 14 Dec 2025 14:51:02 +0000 Subject: [PATCH 1/2] Add generic device class to aid in adding support for unsupported devices --- README.md | 4 ++++ SolixBLE.py | 16 ++++++++++++++++ pyproject.toml | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f2a7d92..ab31717 100644 --- a/README.md +++ b/README.md @@ -74,3 +74,7 @@ the dependencies are installed as well. ``` pip install bleak bleak-retry-connector ``` + +## Adding support for new devices + +See the `Generic` class inside `SolixBLE.py` for guidance on how to add support for new devices. diff --git a/SolixBLE.py b/SolixBLE.py index c8eed15..de657cb 100644 --- a/SolixBLE.py +++ b/SolixBLE.py @@ -858,3 +858,19 @@ def battery_percentage(self) -> int: :returns: Percentage charge of battery or default int value. """ return self._data[169] if self._data is not None else DEFAULT_METADATA_INT + + +class Generic(SolixBLEDevice): + """ + Generic to be used for adding support for an unsupported device. + + Add support for a device like this: + + 1. Copy this subclass to a new class with a name of the device. + 2. Initialise the new class inside example.py and connect to it. + 3. Change values (e.g turn things on and off) to cause changes in the device state. + 4. Observe which values change in the log and add properties to your subclass that parse them (see C300, C1000, etc for examples). + 5. Profit??? + """ + + _EXPECTED_TELEMETRY_LENGTH: int = 0 diff --git a/pyproject.toml b/pyproject.toml index 1f50d30..19f9818 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "SolixBLE" -version = "2.0.0" +version = "2.1.0" dependencies = [ "bleak>=0.19.0", "bleak-retry-connector" From 00aba5dfe29154a7dff63f375ef0f4937c410793 Mon Sep 17 00:00:00 2001 From: Harvey Lelliott <42912136+flip-dots@users.noreply.github.com> Date: Sun, 14 Dec 2025 15:08:17 +0000 Subject: [PATCH 2/2] Add support for printing bytes diff when using Generic device --- SolixBLE.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/SolixBLE.py b/SolixBLE.py index de657cb..ab72476 100644 --- a/SolixBLE.py +++ b/SolixBLE.py @@ -330,13 +330,23 @@ def _parse_telemetry(self, data: bytearray) -> None: :param data: Bytes from status update message. """ - # If the size is wrong then it is not a telemetry message - if len(data) != self._EXPECTED_TELEMETRY_LENGTH: + # If we are expecting a particular size and the data is not that size then the + # data we received is not the telemetry data we want + if ( + self._EXPECTED_TELEMETRY_LENGTH != 0 + and len(data) != self._EXPECTED_TELEMETRY_LENGTH + ): _LOGGER.debug( f"Data is not telemetry data. The size is wrong ({len(data)} != {self._EXPECTED_TELEMETRY_LENGTH}). Data: '{data}'" ) return + if len(data) < 100: + _LOGGER.debug( + f"Data is not telemetry data. It is too small. We expect > 100 but got '{len(data)}'. Data: '{data}'" + ) + return + # If debugging and we have a previous status update to compare against if _LOGGER.isEnabledFor(logging.DEBUG) and self._data is not None: if data == self._data: