Skip to content

Data Models

The alpha_hwr.models module contains Pydantic models representing the pump's state and configuration. All models are fully typed and validated.

Telemetry Models

TelemetryData

Real-time telemetry data from the pump including flow, pressure, power, temperature, and electrical measurements.

Bases: BaseModel

Telemetry data from Grundfos Alpha HWR pump.

flow_gpm property

Convert flow to GPM.

formatted_string property

Get a human-readable string representation.

head_ft property

Convert head to feet.

head_psi property

Convert head to PSI.

media_temperature_f property

Convert media temperature to Fahrenheit.

Control Models

SetpointInfo

Current pump control configuration including mode, setpoint value, and operational limits.

Bases: BaseModel

Setpoint information for current control mode.

get_display_value()

Get setpoint value with appropriate unit based on control mode.

Returns:

Type Description
tuple[float, str]

Tuple of (value, unit_string)

Notes
  • CONSTANT_PRESSURE (0): Returns meters (m) - raw value is in Pascals, converted to m H2O
  • PROPORTIONAL_PRESSURE (1): Returns meters (m) - raw value is in Pascals
  • CONSTANT_FLOW (8): Returns m³/h - raw value is already in m³/h
  • CONSTANT_SPEED (2): Returns RPM - raw value is already in RPM
  • CONSTANT_TEMPERATURE (6): Returns °C - raw value is already in °C
  • Others: Returns raw value with "units"

get_limits_display()

Get min/max setpoint limits with appropriate unit conversion.

Returns:

Type Description
tuple[tuple[float, str], tuple[float, str]] | None

Tuple of ((min_value, unit), (max_value, unit)), or None if limits not available.

AlarmInfo

Current alarm and warning status with human-readable descriptions.

Bases: BaseModel

Alarm and warning information.

Device Models

DeviceInfo

Device identification information including serial number, firmware versions, and product details.

Bases: BaseModel

Device identification and version information.

Statistics

Cumulative pump statistics including operating hours and start count.

Bases: BaseModel

Cumulative operating statistics.

Schedule Models

ScheduleEntry

A single schedule time window for pump operation. Supports 5 independent schedule layers.

Bases: BaseModel

Schedule entry for pump operation timing.

Represents a single time window when the pump should operate. Includes validation for time ranges and overlap detection.

Notes

The enabled field indicates whether this specific day has an active schedule in the pump's internal storage. When reading schedules via get_schedule(), only enabled entries are returned. There is no way to "disable" an entry - you can only clear/remove it entirely. The enabled field is primarily used internally for the binary protocol format.

begin_time property

Get formatted begin time (HH:MM).

begin_time_obj property

Get begin time as datetime.time object.

day_index property

Get day index (0=Monday, 6=Sunday).

end_time property

Get formatted end time (HH:MM).

end_time_obj property

Get end time as datetime.time object.

crosses_midnight()

Check if this schedule entry crosses midnight.

Returns:

Type Description
bool

True if end time is before begin time (indicating midnight crossing)

from_bytes(data, day, layer=0) classmethod

Parse from 6-byte binary format.

Parameters:

Name Type Description Default
data bytes

6-byte binary data

required
day str

Day name for this entry

required
layer int

Schedule layer (0-4)

0

Returns:

Type Description
'ScheduleEntry'

ScheduleEntry instance

Raises:

Type Description
ValueError

If data is not 6 bytes

from_dict(data) classmethod

Create ScheduleEntry from dictionary (e.g., from get_schedule() output).

Parameters:

Name Type Description Default
data dict

Dictionary with schedule entry fields

required

Returns:

Type Description
'ScheduleEntry'

ScheduleEntry instance

get_duration_minutes()

Calculate entry duration in minutes.

Returns:

Type Description
int

Duration in minutes. If end time is before begin time,

int

assumes the schedule crosses midnight and calculates accordingly.

Examples:

  • 06:00 to 08:00 = 120 minutes
  • 22:00 to 02:00 = 240 minutes (crosses midnight)

is_valid_time_range()

Validate that the time range is sensible.

Returns:

Type Description
bool

Tuple of (is_valid, error_message)

str | None
  • (True, None) if valid
tuple[bool, str | None]
  • (False, "error message") if invalid
Checks
  • Duration is not zero
  • Times are not identical

overlaps_with(other)

Check if this entry overlaps with another entry.

Only checks for overlap if both entries are: - On the same day - On the same layer - Both enabled

Parameters:

Name Type Description Default
other 'ScheduleEntry'

Another ScheduleEntry to compare with

required

Returns:

Type Description
bool

True if the entries overlap in time

Examples:

  • 06:00-08:00 and 07:00-09:00 = True (overlap)
  • 06:00-08:00 and 08:00-10:00 = False (adjacent, no overlap)
  • 06:00-08:00 and 10:00-12:00 = False (separate)
  • 22:00-02:00 and 01:00-03:00 = True (both cross midnight, overlap)

to_bytes()

Convert to 6-byte binary format for writing to pump.

Format

Byte 0: Enabled flag (0x01 if enabled, 0x00 if disabled) Byte 1: Action code (0x02 for run) Byte 2: Start hour (0-23) Byte 3: Start minute (0-59) Byte 4: End hour (0-23) Byte 5: End minute (0-59)

Returns:

Type Description
bytes

6-byte binary representation

to_dict()

Convert to dictionary format matching get_schedule() output.

Returns:

Type Description
dict

Dictionary with all schedule entry fields

validate_day(v) classmethod

Validate day name is one of the valid weekdays (case-insensitive).

Historical Data Models

EventLogEntry

A single event log entry from the pump's event history.

Bases: BaseModel

Single event log entry from the pump.

The pump maintains a circular buffer of 20 event log entries (SubID 10200-10219), where 0 is the newest and 19 is the oldest.

Each entry is 16 bytes containing timestamp, cycle counter, mode, and event type information.

EventLogMetadata

Metadata for event log entries.

Bases: BaseModel

Metadata about the event log (SubID 10199).

The metadata is 7 bytes containing information about the current cycle counter and number of available entries in the log.

Structure (7 bytes): - Bytes 0-1: Current cycle counter (uint16 BE) - Bytes 2-3: Available entries (uint16 BE) - Bytes 4-5: Max buffer size (uint16 BE, always 20) - Byte 6: Reserved/flags (uint8, typically 0)

TrendDataPoint

A single data point in a trend series.

Bases: BaseModel

Single data point in a trend series.

TrendDataSeries

A series of trend data points for a single parameter.

Bases: BaseModel

A series of trend data points for a specific metric.

Contains two sets of data: - 10-cycle: High frequency recent data - 100-cycle: Lower frequency historical data

TrendDataCollection

Collection of all trend data series (flow, head, temperature, power).

Bases: BaseModel

Collection of all trend data series.