Skip to content

Fix Temperature Range Persistence (Sync with ESPHome Issue #65)#33

Open
eman wants to merge 2 commits into
mainfrom
bugfix/issue-65-temp-range-persistence
Open

Fix Temperature Range Persistence (Sync with ESPHome Issue #65)#33
eman wants to merge 2 commits into
mainfrom
bugfix/issue-65-temp-range-persistence

Conversation

@eman

@eman eman commented Jul 10, 2026

Copy link
Copy Markdown
Owner

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 0x01 rejection from the pump. This uses the exact 25-byte APDU structure verified in captures.

Copilot AI review requested due to automatic review settings July 10, 2026 19:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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([
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants