powermon.protocols.neey module

protocols / neey.py

class powermon.protocols.neey.Neey

Bases: AbstractProtocol

Neey Active Balancer protocol handler

check_crc(response: str, command_definition: CommandDefinition = None) bool

crc check, needs override in protocol

check_valid(response: str, command_definition: CommandDefinition = None) bool

check if the response is valid

Parameters:
  • response (str) – the response to check

  • command_definition (CommandDefinition, optional) – not used in the check for this protocol. Defaults to None.

Raises:

InvalidResponse – exception raised if the response is invalid for any reason

Returns:

True if response doesnt meet any ‘invalid’ tests

Return type:

bool

checksum(response: bytes) int

Calculate neey checksum of supplied bytes (OR of each byte)

Parameters:

response (_type_) – bytes to calculate checksum of

Returns:

calculated checksum

Return type:

int

crc(response: bytes) int

Calculate neey crc of supplied bytes (sum bytes & 0xFF)

Parameters:

response (bytes) – bytes to calculate crc of

Returns:

calculated crc

Return type:

int

get_full_command(command: bytes | str) bytes

generate the full command including crc and as needed

split_response(response: str, command_definition: CommandDefinition = None) list

split response into individual items, return as ordered list or list of tuples

trim_response(response: str, command_definition: CommandDefinition = None) str

Remove extra characters from response