Growcube message
The GrowcubeMessage class is used as an abstraction of the protocol used to communicate with Growcube devices.
- class growcube_client.growcubemessage.GrowcubeMessage(command: int, payload: str, data: bytes)
Bases:
object
Growcube protocol message base class
- DELIMITER = '#'
- EMPTY_MESSAGE = 'elea00###'
- END_DELIMITER = '#'
- HEADER = 'elea'
- property command
Command value Returns:
Command value
- property data: bytes
The complete message as bytes Returns:
The complete message as bytes
- static from_bytes(data: bytearray) -> (<class 'int'>, typing.Self)
Tries to construct a complete GrowcubeMessage from the data, and returns the index of the next non consumed data in the buffer, together with the message Converts a byte array to a GrowcubeMessage instance Args:
data: the current data buffer
- Returns:
The index of the next non consumed data in the buffer, together with the message, or the next found start index and None if the message is incomplete
- property payload
Message payload Returns:
Message payload
- static to_bytes(command: int, data: str) bytes
Creates a bytearray representation of a message as used in the protocol Args:
command: Command value data: Data to send
- Returns:
A bytearray representation of a message as used in the protocol