Fix Temperature Range Persistence (Sync with ESPHome Issue #65)#33
Open
eman wants to merge 2 commits into
Open
Fix Temperature Range Persistence (Sync with ESPHome Issue #65)#33eman wants to merge 2 commits into
eman wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the ControlService temperature range write path to use a captured, pump-accepted Class 10 APDU for Object 91 / Sub-ID 430 (Type 1012), addressing prior GENI Error 0x01 rejections caused by the generic DataObject encoding.
Changes:
- Adjusts
get_mode()to add retry intent for the initial Class 10 read after authentication and documents/handles connection-drop behavior. - Reworks
set_temperature_range_control()to manually construct the expected 25-byte APDU for Object 91 / Sub-ID 430 instead of using the prior generic payload format.
Comment on lines
403
to
+407
| # Read Class 10: Object 86, Sub-ID 6 (overall_operation_local_request_obj) | ||
| data = await self._read_class10_object(86, 6) | ||
| # Retry: this is often the first read issued right after the | ||
| # authentication handshake, and the pump can briefly be | ||
| # unresponsive while it finishes settling into the new session. | ||
| data = await self._read_class10_object(86, 6, retries=3) |
Comment on lines
+964
to
+974
|
|
||
| # Payload (14 bytes) | ||
| apdu.append(0x01 if autoadapt else 0x00) # DeltaTempEnabled | ||
| apdu.extend(encode_float_be(min_temp)) | ||
|
|
||
| # The remaining 9 bytes in the App capture | ||
| apdu.extend(bytes([ | ||
| 0x00, 0x00, 0x00, 0x16, | ||
| 0x00, 0x00, 0x00, 0x16, | ||
| 0x00 | ||
| ])) |
Comment on lines
+544
to
+547
| except ConnectionError: | ||
| # The pump dropped the BLE connection mid-read - propagate so | ||
| # the caller can report this distinctly from "no data read". | ||
| raise |
Comment on lines
951
to
+955
| # 2. Write temperature range to Object 91, Sub-ID 430 | ||
| # Payload format (Type 1012): | ||
| # [DeltaTempEnabled(1)][MinTemp(4)][MaxTemp(4)][TimeLimits(4)] | ||
| # Total size 13 bytes | ||
|
|
||
| # Build 13-byte structure data | ||
| struct_data = bytearray() | ||
| struct_data.append(0x01 if autoadapt else 0x00) # DeltaTempEnabled | ||
| struct_data.extend(encode_float_be(min_temp)) | ||
| struct_data.extend(encode_float_be(max_temp)) | ||
| struct_data.extend( | ||
| bytes([0x05, 0x3C, 0x01, 0x1E]) | ||
| ) # Default time limits | ||
|
|
||
| # Build APDU: [Class][OpSpec][ObjID][SubH][SubL][Reserved][Type(2)][Size(2)][Data...] | ||
| # Using Object 91, Sub 430 | ||
| apdu = bytearray( | ||
| [0x0A, 0xB3, 91, 0x01, 0xAE, 0x00, 0xF4, 0x03, 0x00, 0x00, 0x0D] | ||
| ) | ||
| apdu.extend(struct_data) | ||
| # Payload must match exactly what is read back (no Type ID bytes, 14 bytes data) | ||
| # Build APDU manually to match exactly what Grundfos GO app sends | ||
| # App sends: [Class 10] [OpSpec 0x97] [ObjID 91] [SubH 01] [SubL AE] [TypeH 03] [TypeL F4] [Reserved 02] [Size 00 00 0E] [Data...] | ||
| apdu = bytearray([ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates the Python reference implementation for setting the temperature range on Object 91 / Sub 430. The previous implementation used the generic DataObject format which resulted in a
GENI Error 0x01rejection from the pump. This uses the exact 25-byte APDU structure verified in captures.