Automation
The Automation module provides the main interface to the OpenWebNet automation system. This allows controlling shutter, blinds, and other similar devices.
pyown.items.automation.WhatAutomation
¶
This enum contains the possible commands and states for an automation.
Attributes:
Name | Type | Description |
---|---|---|
STOP |
The command to stop the automation. |
|
UP |
The command to go up. |
|
DOWN |
The command to go down. |
pyown.items.automation.AutomationEvents
¶
Bases: Enum
This enum is used internally to register the callbacks to the correct event.
Attributes:
Name | Type | Description |
---|---|---|
STOP |
The event for when the automation stops. |
|
UP |
The event for when the automation goes up. |
|
DOWN |
The event for when the automation goes down. |
|
ALL |
The event for all events. |
pyown.items.automation.Automation
¶
Automation(
client: BaseClient,
where: Where | str,
*,
who: Who | str | None = None
)
Bases: BaseItem
Automation items are usually used to control blinds, shutters, etc...
client: The client to use to communicate with the server.
where: The location of the item.
who: The type of item.
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_status
async
¶
get_status() -> AsyncIterator[tuple[Where, WhatAutomation]]
Requests the status of the automation.
Raises:
Type | Description |
---|---|
AttributeError
|
If the automation is not a light point. |
Returns:
Name | Type | Description |
---|---|---|
WhatAutomation |
AsyncIterator[tuple[Where, WhatAutomation]]
|
The status of the automation. |
on_status_change
classmethod
¶
on_status_change(
callback: Callable[
[Self, WhatAutomation], Coroutine[None, None, None]
]
)
Registers a callback to be called when the status of the automation changes.
If the shutter is already down and a command is sent to go down, the gateway will sometimes return the stop event and before the down event. So, make sure to handle this case in your code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback
|
Callable[[Self, WhatAutomation], Coroutine[None, None, None]]
|
The callback to call. It will receive as arguments the item and the status. |
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. |