Skip to content

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

tags: tuple[str] | list[str]

Returns a copy of the tags.

The tags are the elements that compose the message, like the WHO, WHAT, WHERE, etc.

Returns:

Type Description
tuple[str] | list[str]

tuple[str] | list[str]: The tags of the message

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

who property

who: Who | None

Returns the WHO tag of the message.

where property

where: Where | None

Returns the WHERE tag of the message.

pattern classmethod

pattern() -> Pattern[str]

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

GenericMessage(tags: list[str])

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

tags: tuple[str] | list[str]

Returns a copy of the tags.

The tags are the elements that compose the message, like the WHO, WHAT, WHERE, etc.

Returns:

Type Description
tuple[str] | list[str]

tuple[str] | list[str]: The tags of the message

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

who property

who: Who | None

Returns the WHO tag of the message.

where property

where: Where | None

Returns the WHERE tag of the message.

message property

message: str

Returns the string representation of the message.

Returns:

Name Type Description
str str

The message

pattern classmethod

pattern() -> Pattern[str]

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

parse(tags: list[str]) -> Self

Parses the tags of a message from the OpenWebNet bus. In this case, it only checks if the tags are correct.

Parameters:

Name Type Description Default
tags list[str]

The tags of the message

required

Returns:

Name Type Description
GenericMessage Self

The instance of the class

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

tags: tuple[str] | list[str]

Returns a copy of the tags.

The tags are the elements that compose the message, like the WHO, WHAT, WHERE, etc.

Returns:

Type Description
tuple[str] | list[str]

tuple[str] | list[str]: The tags of the message

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

who property

who: Who | None

Returns the WHO tag of the message.

where property

where: Where | None

Returns the WHERE tag of the message.

message property

message: str

Returns the string representation of the message.

It's a constant string: *#*1##

pattern classmethod

pattern() -> Pattern[str]

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

parse(tags: list[str]) -> Self

Parses the tags of a message from the OpenWebNet bus. In this case, it only checks if the tags are correct.

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

tags: tuple[str] | list[str]

Returns a copy of the tags.

The tags are the elements that compose the message, like the WHO, WHAT, WHERE, etc.

Returns:

Type Description
tuple[str] | list[str]

tuple[str] | list[str]: The tags of the message

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

who property

who: Who | None

Returns the WHO tag of the message.

where property

where: Where | None

Returns the WHERE tag of the message.

message property

message: str

Returns the string representation of the message.

It's a constant string: *#*0##

pattern classmethod

pattern() -> Pattern[str]

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

parse(tags: list[str]) -> Self

Parses the tags of a message from the OpenWebNet bus. In this case, it only checks if the tags are correct.

pyown.messages.normal.NormalMessage

NormalMessage(tags: tuple[Who, What, Where])

Bases: BaseMessage

Represents a Normal message

Syntax: *who*what*where##

tags property

tags: tuple[str] | list[str]

Returns a copy of the tags.

The tags are the elements that compose the message, like the WHO, WHAT, WHERE, etc.

Returns:

Type Description
tuple[str] | list[str]

tuple[str] | list[str]: The tags of the message

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

who property

who: Who

Returns the WHO tag of the message.

where property

where: Where

Returns the WHERE tag of the message.

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

pattern() -> Pattern[str]

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

parse(tags: list[str]) -> Self

Parses the tags of a message from the OpenWebNet bus.

pyown.messages.status.StatusRequest

StatusRequest(tags: tuple[Who, Where])

Bases: BaseMessage

Represents a status request message

Syntax: *#who*where##

tags property

tags: tuple[str] | list[str]

Returns a copy of the tags.

The tags are the elements that compose the message, like the WHO, WHAT, WHERE, etc.

Returns:

Type Description
tuple[str] | list[str]

tuple[str] | list[str]: The tags of the message

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

who property

who: Who

Returns the WHO tag of the message.

where property

where: Where

Returns the WHERE tag of the message.

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

pattern() -> Pattern[str]

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

parse(tags: list[str]) -> Self

Parses the tags of a message from the OpenWebNet bus.

pyown.messages.dimension.DimensionRequest

DimensionRequest(tags: tuple[Who, Where, Dimension])

Bases: BaseMessage

Represents a dimension request message

Syntax: *#who*where*dimension##

tags property

tags: tuple[str] | list[str]

Returns a copy of the tags.

The tags are the elements that compose the message, like the WHO, WHAT, WHERE, etc.

Returns:

Type Description
tuple[str] | list[str]

tuple[str] | list[str]: The tags of the message

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

who property

who: Who

Returns the WHO tag of the message.

where property

where: Where

Returns the WHERE tag of the message.

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

pattern() -> Pattern[str]

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

parse(tags: list[str]) -> Self

Parses the tags of a message from the OpenWebNet bus.

pyown.messages.dimension.DimensionWriting

DimensionWriting(
    tags: tuple[Who, Where, Dimension, Value, ...]
)

Bases: BaseMessage

Represents a dimension writing message

Syntax: *#who*where*#dimension*value1*value2*...*valueN##

tags property

tags: tuple[str] | list[str]

Returns a copy of the tags.

The tags are the elements that compose the message, like the WHO, WHAT, WHERE, etc.

Returns:

Type Description
tuple[str] | list[str]

tuple[str] | list[str]: The tags of the message

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

who property

who: Who

Returns the WHO tag of the message.

where property

where: Where

Returns the WHERE tag of the message.

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

pattern() -> Pattern[str]

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

parse(tags: list[str]) -> Self

Parses the tags of a message from the OpenWebNet bus.

pyown.messages.dimension.DimensionResponse

DimensionResponse(
    tags: tuple[Who, Where, Dimension, Value, ...]
)

Bases: DimensionWriting, BaseMessage

Represents a dimension writing message

Syntax: *#who*where*dimension*value1*value2*...*valueN##

tags property

tags: tuple[str] | list[str]

Returns a copy of the tags.

The tags are the elements that compose the message, like the WHO, WHAT, WHERE, etc.

Returns:

Type Description
tuple[str] | list[str]

tuple[str] | list[str]: The tags of the message

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

who property

who: Who

Returns the WHO tag of the message.

where property

where: Where

Returns the WHERE tag of the message.

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

pattern() -> Pattern[str]

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

parse(tags: list[str]) -> Self

Parses the tags of a message from the OpenWebNet bus.