Skip to content

Decoding bat_mng_struct.profile... OIDs #49

@SaxonWood

Description

@SaxonWood

In case someone is interesting in the RCT inverters' "forecast", ie. the OIDs:

bat_mng_struct.profile_pdc
bat_mng_struct.profile_pdc_max
bat_mng_struct.profile_load
bat_mng_struct.profile_pext

Note that this is not a real forecast but the inverter's attempt to estimate the future power levels (Pdc, Load, External) based on historic data.

Decoding would require a new non-native type; suggested name BATTERY_MNG_PROFILE = 25.
A possible decoding functions could look like this:

def _decode_bat_mng_profile(data: bytes) -> List[float]:
    '''
    Helper function to decode inverter's internal forecast data series.

    Decodes OIDs named bat_mng_struct.profile_p... 
    Returns an 48-element list of floats, with each float having 
    a power value (Watt). Each item represents a 30 min interval of day, starting at 00:00.
    Data format per 4 octets: float, little endian (DCBA)
    '''
    expected_len = 48*4
    if len(data) != expected_len:
        raise ValueError(f'Forecast payload must be {expected_len} bytes, got {len(data)}')

    fmt = '<48f'                         # format string, repeat 48x
    unpacked = struct.unpack(fmt, data)  # tuple w/ all cell data elements

    return list(unpacked)

More elaborate approaches are of course possible, e.g. returning a dict objects with datetime.time as key and the float as value.

{
    time(0, 0):   0.0,
    time(0, 30): 0.34,
    ...
    time(12, 30): 3456.03,
    ...
    time(23, 30): 0.34,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions