Messages
This module represents all the possible types of messages that can be sent or received.
Generally, messages are composed of a series of specific tags, each of which represents a specific piece of information. They follow the following structure:
*tag1*tag2*tag3*tagN##
Each tag can have a set of parameters that further define its meaning.
pyown.messages.base.parse_message
¶
parse_message(message: str) -> BaseMessage
Parses a message from the OpenWebNet bus.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
The message to parse |
required |
Returns:
Name | Type | Description |
---|---|---|
BaseMessage |
BaseMessage
|
The appropriate message class instance, GenericMessage if the message has an unknown WHO tag or its structure is unknown |
pyown.messages.base.BaseMessage
¶
BaseMessage(*args, **kwargs)
Bases: ABC
Base class for all the messages from the OpenWebNet bus.
It defines the structure of the messages and the methods to parse and create them.
Attributes:
Name | Type | Description |
---|---|---|
prefix |
str
|
Prefix of the message |
suffix |
str
|
Suffix of the message |
separator |
str
|
Separator of the tags |
tags
property
¶
type
property
¶
type: MessageType
Returns the type of the message.
Returns:
Name | Type | Description |
---|---|---|
MessageType |
MessageType
|
The type of the message |
message
abstractmethod
property
¶
message: str
Returns the message represented by the class.
This function is equivalent to the __str__
method.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The message |
bytes
property
¶
bytes: bytes
Returns the message encoded in bytes.
Returns:
Name | Type | Description |
---|---|---|
bytes |
bytes
|
The message encoded in bytes |
pattern
classmethod
¶
Returns the regex pattern used to match the message represented by the class. Returns: Pattern[str]: The regex pattern used to match the message
parse
abstractmethod
classmethod
¶
parse(tags: list[str]) -> BaseMessage
Parses the tags of a message and returns an instance of the class.
pyown.messages.base.GenericMessage
¶
Bases: BaseMessage
Represents a generic message.
This is used when the message has an unknown structure, or to send specific messages that don't need a specific class to represent them.
tags
property
¶
type
property
¶
type: MessageType
Returns the type of the message.
Returns:
Name | Type | Description |
---|---|---|
MessageType |
MessageType
|
The type of the message |
bytes
property
¶
bytes: bytes
Returns the message encoded in bytes.
Returns:
Name | Type | Description |
---|---|---|
bytes |
bytes
|
The message encoded in bytes |
message
property
¶
message: str
Returns the string representation of the message.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The message |
pattern
classmethod
¶
Returns the regex pattern used to match the message represented by the class. Returns: Pattern[str]: The regex pattern used to match the message
parse
classmethod
¶
pyown.messages.ack.ACK
¶
ACK()
Bases: BaseMessage
Represents an ACK message. Used to acknowledge a command sent or to end a list of messages sent as a result of a command.
Syntax: *#*1##
(constant string)
tags
property
¶
type
property
¶
type: MessageType
Returns the type of the message.
Returns:
Name | Type | Description |
---|---|---|
MessageType |
MessageType
|
The type of the message |
bytes
property
¶
bytes: bytes
Returns the message encoded in bytes.
Returns:
Name | Type | Description |
---|---|---|
bytes |
bytes
|
The message encoded in bytes |
message
property
¶
message: str
Returns the string representation of the message.
It's a constant string: *#*1##
pattern
classmethod
¶
Returns the regex pattern used to match the message represented by the class. Returns: Pattern[str]: The regex pattern used to match the message
pyown.messages.nack.NACK
¶
NACK()
Bases: BaseMessage
Represents a NACK message. Used to signal that a command sent wasn’t executed correctly, or it's not supported.
Syntax: *#*0##
(constant string)
tags
property
¶
type
property
¶
type: MessageType
Returns the type of the message.
Returns:
Name | Type | Description |
---|---|---|
MessageType |
MessageType
|
The type of the message |
bytes
property
¶
bytes: bytes
Returns the message encoded in bytes.
Returns:
Name | Type | Description |
---|---|---|
bytes |
bytes
|
The message encoded in bytes |
message
property
¶
message: str
Returns the string representation of the message.
It's a constant string: *#*0##
pattern
classmethod
¶
Returns the regex pattern used to match the message represented by the class. Returns: Pattern[str]: The regex pattern used to match the message
pyown.messages.normal.NormalMessage
¶
Bases: BaseMessage
Represents a Normal message
Syntax: *who*what*where##
tags
property
¶
type
property
¶
type: MessageType
Returns the type of the message.
Returns:
Name | Type | Description |
---|---|---|
MessageType |
MessageType
|
The type of the message |
bytes
property
¶
bytes: bytes
Returns the message encoded in bytes.
Returns:
Name | Type | Description |
---|---|---|
bytes |
bytes
|
The message encoded in bytes |
message
property
¶
message: str
Returns the message represented by the class.
This function is equivalent to the __str__
method.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The message |
pattern
classmethod
¶
Returns the regex pattern used to match the message represented by the class. Returns: Pattern[str]: The regex pattern used to match the message
pyown.messages.status.StatusRequest
¶
Bases: BaseMessage
Represents a status request message
Syntax: *#who*where##
tags
property
¶
type
property
¶
type: MessageType
Returns the type of the message.
Returns:
Name | Type | Description |
---|---|---|
MessageType |
MessageType
|
The type of the message |
bytes
property
¶
bytes: bytes
Returns the message encoded in bytes.
Returns:
Name | Type | Description |
---|---|---|
bytes |
bytes
|
The message encoded in bytes |
message
property
¶
message: str
Returns the message represented by the class.
This function is equivalent to the __str__
method.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The message |
pattern
classmethod
¶
Returns the regex pattern used to match the message represented by the class. Returns: Pattern[str]: The regex pattern used to match the message
pyown.messages.dimension.DimensionRequest
¶
Bases: BaseMessage
Represents a dimension request message
Syntax: *#who*where*dimension##
tags
property
¶
type
property
¶
type: MessageType
Returns the type of the message.
Returns:
Name | Type | Description |
---|---|---|
MessageType |
MessageType
|
The type of the message |
bytes
property
¶
bytes: bytes
Returns the message encoded in bytes.
Returns:
Name | Type | Description |
---|---|---|
bytes |
bytes
|
The message encoded in bytes |
message
property
¶
message: str
Returns the message represented by the class.
This function is equivalent to the __str__
method.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The message |
pattern
classmethod
¶
Returns the regex pattern used to match the message represented by the class. Returns: Pattern[str]: The regex pattern used to match the message
pyown.messages.dimension.DimensionWriting
¶
Bases: BaseMessage
Represents a dimension writing message
Syntax: *#who*where*#dimension*value1*value2*...*valueN##
tags
property
¶
type
property
¶
type: MessageType
Returns the type of the message.
Returns:
Name | Type | Description |
---|---|---|
MessageType |
MessageType
|
The type of the message |
bytes
property
¶
bytes: bytes
Returns the message encoded in bytes.
Returns:
Name | Type | Description |
---|---|---|
bytes |
bytes
|
The message encoded in bytes |
message
property
¶
message: str
Returns the message represented by the class.
This function is equivalent to the __str__
method.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The message |
pattern
classmethod
¶
Returns the regex pattern used to match the message represented by the class. Returns: Pattern[str]: The regex pattern used to match the message
pyown.messages.dimension.DimensionResponse
¶
Bases: DimensionWriting
, BaseMessage
Represents a dimension writing message
Syntax: *#who*where*dimension*value1*value2*...*valueN##
tags
property
¶
type
property
¶
type: MessageType
Returns the type of the message.
Returns:
Name | Type | Description |
---|---|---|
MessageType |
MessageType
|
The type of the message |
bytes
property
¶
bytes: bytes
Returns the message encoded in bytes.
Returns:
Name | Type | Description |
---|---|---|
bytes |
bytes
|
The message encoded in bytes |
message
property
¶
message: str
Returns the message represented by the class.
This function is equivalent to the __str__
method.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The message |
pattern
classmethod
¶
Returns the regex pattern used to match the message represented by the class. Returns: Pattern[str]: The regex pattern used to match the message