Gateway
The Gateway module provides the main interface to the OpenWebNet gateway.
pyown.items.gateway.gateway.WhatGateway
¶
This enum is used to define the various types of data that can be retrieved from a gateway.
Attributes:
Name | Type | Description |
---|---|---|
TIME |
str
|
get or set the time of the gateway and bus. |
DATE |
str
|
get or set the date of the gateway and bus. |
IP_ADDRESS |
str
|
get the IP address of the gateway. |
NET_MASK |
str
|
get the net mask of the gateway. |
MAC_ADDRESS |
str
|
get the MAC address of the gateway. |
DEVICE_TYPE |
str
|
get the device type of the gateway. |
FIRMWARE_VERSION |
str
|
get the firmware version of the gateway. |
UPTIME |
str
|
get the uptime of the gateway. |
DATE_TIME |
str
|
get or set the date and time of the gateway. |
KERNEL_VERSION |
str
|
get the linux kernel version of the gateway. |
DISTRIBUTION_VERSION |
str
|
get the linux distribution version of the gateway. |
pyown.items.gateway.gateway.GatewayModel
¶
Bases: StrEnum
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 |
|
pyown.items.gateway.gateway.Gateway
¶
Gateway(client: BaseClient, where: Where | str = '')
Bases: BaseItem
client: The client to use to communicate with the server.
client
property
writable
¶
client: BaseClient
Returns the client used to communicate with the server.
create_normal_message
¶
create_normal_message(what: What | str) -> NormalMessage
Creates a normal message for the item. Args: what: The action to perform. Returns: A normal message.
create_status_message
¶
create_status_message() -> StatusRequest
create_dimension_writing_message
¶
create_dimension_writing_message(
dimension: Dimension, *args: Value
) -> DimensionWriting
Creates a dimension message for the item. Args: dimension: the dimension value to set. *args: the values to set.
Returns:
create_dimension_request_message
¶
create_dimension_request_message(
dimension: Dimension,
) -> DimensionRequest
Creates a dimension request message for the item. Args: dimension: the dimension value to request.
Returns:
send_normal_message
async
¶
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
¶
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. |
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. Args: bus_time: the time to set with the timezone.
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: 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: Self, message: BaseMessage
) -> list[Task]
Calls the registered callbacks for the event. Used internally by the client to dispatch the events to the correct callbacks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item
|
BaseItem
|
The item that triggered the event. |
required |
message
|
BaseMessage
|
The message that triggered the event. |
required |
Returns:
Type | Description |
---|---|
list[Task]
|
list[Task]: A list of tasks scheduled to run the callbacks. |