Skip to content

Gateway module

The Gateway module provides the main interface to the OpenWebNet gateway.

pyown.items.gateway.gateway.WhatGateway

WhatGateway(string: str | int = '', *args, **kwargs)

Bases: What, StrEnum


              flowchart TD
              pyown.items.gateway.gateway.WhatGateway[WhatGateway]
              pyown.tags.what.What[What]
              pyown.tags.base.TagWithParameters[TagWithParameters]
              pyown.tags.base.Tag[Tag]

                              pyown.tags.what.What --> pyown.items.gateway.gateway.WhatGateway
                                pyown.tags.base.TagWithParameters --> pyown.tags.what.What
                                pyown.tags.base.Tag --> pyown.tags.base.TagWithParameters
                




              click pyown.items.gateway.gateway.WhatGateway href "" "pyown.items.gateway.gateway.WhatGateway"
              click pyown.tags.what.What href "" "pyown.tags.what.What"
              click pyown.tags.base.TagWithParameters href "" "pyown.tags.base.TagWithParameters"
              click pyown.tags.base.Tag href "" "pyown.tags.base.Tag"
            

This enum is used to define the various types of data that can be retrieved from a gateway.

Attributes:

Name Type Description
TIME

get or set the time of the gateway and bus.

DATE

get or set the date of the gateway and bus.

IP_ADDRESS

get the IP address of the gateway.

NET_MASK

get the net mask of the gateway.

MAC_ADDRESS

get the MAC address of the gateway.

DEVICE_TYPE

get the device type of the gateway.

FIRMWARE_VERSION

get the firmware version of the gateway.

UPTIME

get the uptime of the gateway.

DATE_TIME

get or set the date and time of the gateway.

KERNEL_VERSION

get the linux kernel version of the gateway.

DISTRIBUTION_VERSION

get the linux distribution version of the gateway.

string property

string: str

Returns the value of the tag.

tag property

tag: str

Returns the value of the tag without its parameters or prefix.

parameters property

parameters: list[str]

Returns the parameters of the tag.

with_parameter

with_parameter(parameter: str | int) -> Self

Returns the tag with the specified parameter.

pyown.items.gateway.gateway.GatewayModel

Bases: StrEnum


              flowchart TD
              pyown.items.gateway.gateway.GatewayModel[GatewayModel]

              

              click pyown.items.gateway.gateway.GatewayModel href "" "pyown.items.gateway.gateway.GatewayModel"
            

This enum is used to define the various models of gateways that are supported by the library.

This is not a complete list of all the gateways because there are many different models of gateways that are not listed in the official documentation. So, if you have a gateway not listed here, you can send an issue on GitHub.

Attributes:

Name Type Description
MHServer
MH200
F452
F452V
MHServer2
H4684
MH202

pyown.items.gateway.gateway.Gateway

Gateway(client: BaseClient, where: Where | str = '')

Bases: BaseItem


              flowchart TD
              pyown.items.gateway.gateway.Gateway[Gateway]
              pyown.items.base.BaseItem[BaseItem]

                              pyown.items.base.BaseItem --> pyown.items.gateway.gateway.Gateway
                


              click pyown.items.gateway.gateway.Gateway href "" "pyown.items.gateway.gateway.Gateway"
              click pyown.items.base.BaseItem href "" "pyown.items.base.BaseItem"
            

Gateway item used to query and configure the gateway device itself.

Parameters:

Name Type Description Default
client BaseClient

The client to use to communicate with the server.

required

where property

where: Where

Returns the where value of the item.

who classmethod property

who: Who

Returns the who value of the item.

client property writable

client: BaseClient

Returns the client used to communicate with the server.

get_time async

get_time(*, message: EventMessage = None) -> time

Requests the time of the gateway and bus.

Parameters:

Name Type Description Default
message EventMessage

The message to parse the time from. If not provided, it will send a request to the server. It's used by call_callbacks to parse the message.

None

Returns:

Type Description
time

datetime.time: The time of the gateway and bus.

set_time async

set_time(bus_time: time)

Sets the time of the gateway and bus.

Parameters:

Name Type Description Default
bus_time time

the time to set with the timezone.

required

Raises:

Type Description
ValueError

if bus_time.tzinfo is None or bus_time.tzinfo.utcoffset(None) is None.

get_date async

get_date(*, message: EventMessage = None) -> date

Requests the date of the gateway and bus.

Parameters:

Name Type Description Default
message EventMessage

The message to parse the date from. If not provided, it will send a request to the server. It's used by call_callbacks to parse the message.

None

Returns:

Type Description
date

datetime.date: The date of the gateway and bus.

set_date async

set_date(bus_date: date)

Sets the date of the gateway and bus.

Parameters:

Name Type Description Default
bus_date date

the date to set.

required

get_ip async

get_ip(*, message: EventMessage = None) -> IPv4Address

Requests the IP address of the gateway.

Parameters:

Name Type Description Default
message EventMessage

The message to parse the IP address from. If not provided, it will send a request to the server. It's used by call_callbacks to parse the message.

None

Returns:

Type Description
IPv4Address

ipaddress.IPv4Address: The IP address of the gateway.

get_netmask async

get_netmask(*, message: EventMessage = None) -> str

Requests the net mask of the gateway.

Parameters:

Name Type Description Default
message EventMessage

The message to parse the net mask from. If not provided, it will send a request to the server. It's used by call_callbacks to parse the message.

None

Returns:

Name Type Description
str str

The net mask of the gateway.

get_macaddress async

get_macaddress(*, message: EventMessage = None) -> str

Requests the MAC address of the gateway.

Parameters:

Name Type Description Default
message EventMessage

The message to parse the MAC address from. If not provided, it will send a request to the server. It's used by call_callbacks to parse the message.

None

Returns:

Name Type Description
str str

The MAC address of the gateway.

get_netinfo async

get_netinfo() -> IPv4Network

Combines the net mask and the IP address to get the network info.

Returns:

Type Description
IPv4Network

ipaddress.IPv4Network: The network info.

get_model async

get_model(*, message: EventMessage = None) -> GatewayModel

Requests the device type of the gateway.

Parameters:

Name Type Description Default
message EventMessage

The message to parse the device type from. If not provided, it will send a request to the server. It's used by call_callbacks to parse the message.

None

Returns:

Name Type Description
GatewayModel GatewayModel

The device type of the gateway.

get_firmware async

get_firmware(*, message: EventMessage = None) -> str

Requests the firmware version of the gateway.

Parameters:

Name Type Description Default
message EventMessage

The message to parse the firmware version from. If not provided, it will send a request to the server. It's used by call_callbacks to parse the message.

None

Returns:

Name Type Description
str str

The firmware version of the gateway.

get_uptime async

get_uptime(*, message: EventMessage = None) -> timedelta

Requests the uptime of the gateway.

Parameters:

Name Type Description Default
message EventMessage

The message to parse the uptime from. If not provided, it will send a request to the server. It's used by call_callbacks to parse the message.

None

Returns:

Type Description
timedelta

datetime.timedelta: The uptime of the gateway.

get_datetime async

get_datetime(*, message: EventMessage = None) -> datetime

Requests the date and time of the gateway.

Parameters:

Name Type Description Default
message EventMessage

The message to parse the date and time from. If not provided, it will send a request to the server. It's used by call_callbacks to parse the message.

None

Returns:

Type Description
datetime

datetime.datetime: The date and time of the gateway.

set_datetime async

set_datetime(bus_time: datetime)

Sets the date and time of the gateway.

Parameters:

Name Type Description Default
bus_time datetime

the date and time to set with the timezone.

required

Raises:

Type Description
ValueError

if bus_time.tzinfo is None or bus_time.tzinfo.utcoffset(None) is None.

get_kernel_version async

get_kernel_version(*, message: EventMessage = None) -> str

Requests the linux kernel version of the gateway.

Parameters:

Name Type Description Default
message EventMessage

The message to parse the kernel version from. If not provided, it will send a request to the server. It's used by call_callbacks to parse the message.

None

Returns:

Name Type Description
str str

The linux kernel version used by the gateway.

get_distribution_version async

get_distribution_version(
    *, message: EventMessage = None
) -> str

Requests the os distribution version of the gateway.

Parameters:

Name Type Description Default
message EventMessage

The message to parse the distribution version from. If not provided, it will send a request to the server. It's used by call_callbacks to parse the message.

None

Returns:

Name Type Description
str str

The os distribution version used by the gateway.

register_callback classmethod

register_callback(
    what: WhatGateway, callback: CoroutineCallback
)

Register a callback for a specific event.

Parameters:

Name Type Description Default
what WhatGateway

The event to register the callback for.

required
callback CoroutineCallback

The callback to call when the event occurs.

required

call_callbacks async classmethod

call_callbacks(
    item: BaseItem, message: BaseMessage
) -> list[Task]

Dispatches the message to the registered gateway callbacks.

create_normal_message

create_normal_message(what: What | str) -> NormalMessage

Creates a normal message for the item.

Parameters:

Name Type Description Default
what What | str

The action to perform.

required

Returns:

Type Description
NormalMessage

A normal message.

create_status_message

create_status_message() -> StatusRequest

Creates a status message for the item.

Returns:

Type Description
StatusRequest

A status message.

create_dimension_writing_message

create_dimension_writing_message(
    dimension: Dimension, *args: Value
) -> DimensionWriting

Creates a dimension message for the item.

Parameters:

Name Type Description Default
dimension Dimension

the dimension value to set.

required
*args Value

the values to set.

()

create_dimension_request_message

create_dimension_request_message(
    dimension: Dimension,
) -> DimensionRequest

Creates a dimension request message for the item.

Parameters:

Name Type Description Default
dimension Dimension

the dimension value to request.

required

send_normal_message async

send_normal_message(what: What | str) -> None

Sends a normal message to the server and check the response.

Parameters:

Name Type Description Default
what What | str

The action to perform.

required

Raises:

Type Description
ResponseError

If the server does not acknowledge the message.

send_status_request async

send_status_request() -> AsyncIterator[NormalMessage]

Sends a status request and receive multiple responses from the server.

Raises:

Type Description
ResponseError

If the server responds with an invalid message.

Returns:

Type Description
AsyncIterator[NormalMessage]

The responses from the server.

send_dimension_request async

send_dimension_request(
    dimension: Dimension | str,
) -> AsyncIterator[DimensionResponse]

Sends a dimension request and receive multiple responses from the server.

Raises:

Type Description
ResponseError

If the server responds with an invalid message.

Returns:

Type Description
AsyncIterator[DimensionResponse]

The responses from the server.

send_dimension_writing async

send_dimension_writing(
    dimension: Dimension | str, *args: Value
) -> None

Sends a dimension writing message to the server and check the response.

Parameters:

Name Type Description Default
dimension Dimension | str

the dimension value to set.

required
*args Value

the values to set.

()

Raises:

Type Description
ResponseError

If the server does not acknowledge the message.