Lighting
The Lighting module provides the main interface to the OpenWebNet lighting system.
pyown.items.lighting.base.WhatLight
¶
This enum contains the possible commands for the lights. It is used only internally to send the correct command to the gateway.
Attributes:
Name | Type | Description |
---|---|---|
OFF |
Turns the light off. |
|
ON |
Turns the light on. |
|
ON_20_PERCENT |
Turns the light on at 20%. |
|
ON_30_PERCENT |
Turns the light on at 30%. |
|
ON_40_PERCENT |
Turns the light on at 40%. |
|
ON_50_PERCENT |
Turns the light on at 50%. |
|
ON_60_PERCENT |
Turns the light on at 60%. |
|
ON_70_PERCENT |
Turns the light on at 70%. |
|
ON_80_PERCENT |
Turns the light on at 80%. |
|
ON_90_PERCENT |
Turns the light on at 90%. |
|
ON_100_PERCENT |
Turns the light on at 100%. |
|
ON_1_MIN |
Turns the light on for 1 minute. |
|
ON_2_MIN |
Turns the light on for 2 minutes. |
|
ON_3_MIN |
Turns the light on for 3 minutes. |
|
ON_4_MIN |
Turns the light on for 4 minutes. |
|
ON_5_MIN |
Turns the light on for 5 minutes. |
|
ON_15_MIN |
Turns the light on for 15 minutes. |
|
ON_30_MIN |
Turns the light on for 30 minutes. |
|
ON_0_5_SEC |
Turns the light on for 0.5 seconds. |
|
BLINKING_0_5_SEC |
Blinks the light every 0.5 seconds. |
|
BLINKING_1_0_SEC |
Blinks the light every 1.0 seconds. |
|
BLINKING_1_5_SEC |
Blinks the light every 1.5 seconds. |
|
BLINKING_2_0_SEC |
Blinks the light every 2.0 seconds. |
|
BLINKING_2_5_SEC |
Blinks the light every 2.5 seconds. |
|
BLINKING_3_0_SEC |
Blinks the light every 3.0 seconds. |
|
BLINKING_3_5_SEC |
Blinks the light every 3.5 seconds. |
|
BLINKING_4_0_SEC |
Blinks the light every 4.0 seconds. |
|
BLINKING_4_5_SEC |
Blinks the light every 4.5 seconds. |
|
BLINKING_5_0_SEC |
Blinks the light every 5.0 seconds. |
|
UP_1_PERCENT |
Increases the light luminosity by 1 |
|
DOWN_1_PERCENT |
Decreases the light luminosity by 1 |
|
COMMAND_TRANSLATION |
Not clear what this does. |
pyown.items.lighting.base.LightEvents
¶
Bases: Enum
This enum is used internally to register the callbacks to the correct event.
Attributes:
Name | Type | Description |
---|---|---|
STATUS_CHANGE |
The light status has changed. |
|
LUMINOSITY_CHANGE |
The light luminosity has changed. |
|
LIGHT_TEMPORIZATION |
The light temporization has changed. |
|
HSV_CHANGE |
The light color has changed. |
|
WHITE_TEMP_CHANGE |
The white temperature has changed. |
pyown.items.lighting.base.BaseLight
¶
BaseLight(
client: BaseClient,
where: Where | str,
*,
who: Who | str | None = None
)
Base class for all light items.
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
abstractmethod
async
¶
get_status() -> AsyncIterator[tuple[Where, bool | int]]
Gets the status of the light
temporization_command
async
¶
Sends a temporization command
It will turn the light immediately on and then off after the specified time passed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hour
|
int
|
It indicates show many hours the actuator has to stay ON |
required |
minute
|
int
|
It indicates show many minutes the actuator has to stay ON |
required |
second
|
int
|
It indicates show many seconds the actuator has to stay ON |
required |
temporization_request
async
¶
request_working_time_lamp
async
¶
request_working_time_lamp() -> (
AsyncIterator[tuple[Where, int]]
)
Requests the gateway for how long the light has been on.
Yields:
Type | Description |
---|---|
AsyncIterator[tuple[Where, int]]
|
The time in hours the light has been on. The value is in the range [1-100000]. |
on_status_change
classmethod
¶
Registers a callback function to be called when the light status changes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback
|
Callable[[Self, bool]
|
The callback function to call. It will receive as arguments the item and the status. |
required |
on_temporization_change
classmethod
¶
Registers a callback function to be called when the temporization changes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback
|
Callable[[Self, int, int, int]
|
The callback function to call. It will receive as arguments the item, the hour, the minute, and the second. |
required |
call_callbacks
async
classmethod
¶
call_callbacks(
item: BaseItem, 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. |
pyown.items.lighting.light.Light
¶
Light(
client: BaseClient,
where: Where | str,
*,
who: Who | str | None = None
)
Bases: BaseLight
Light items are item with only two states: on and off.
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.
call_callbacks
async
classmethod
¶
call_callbacks(
item: BaseItem, 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. |
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. |
temporization_command
async
¶
Sends a temporization command
It will turn the light immediately on and then off after the specified time passed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hour
|
int
|
It indicates show many hours the actuator has to stay ON |
required |
minute
|
int
|
It indicates show many minutes the actuator has to stay ON |
required |
second
|
int
|
It indicates show many seconds the actuator has to stay ON |
required |
temporization_request
async
¶
request_working_time_lamp
async
¶
request_working_time_lamp() -> (
AsyncIterator[tuple[Where, int]]
)
Requests the gateway for how long the light has been on.
Yields:
Type | Description |
---|---|
AsyncIterator[tuple[Where, int]]
|
The time in hours the light has been on. The value is in the range [1-100000]. |
on_status_change
classmethod
¶
Registers a callback function to be called when the light status changes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback
|
Callable[[Self, bool]
|
The callback function to call. It will receive as arguments the item and the status. |
required |
on_temporization_change
classmethod
¶
Registers a callback function to be called when the temporization changes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback
|
Callable[[Self, int, int, int]
|
The callback function to call. It will receive as arguments the item, the hour, the minute, and the second. |
required |
get_status
async
¶
get_status() -> AsyncIterator[tuple[Where, bool]]
Gets the status of the light.
Yields:
Type | Description |
---|---|
AsyncIterator[tuple[Where, bool]]
|
tuple[Where, bool]: The where and the status of the light. |
pyown.items.lighting.dimmer.Dimmer
¶
Dimmer(
client: BaseClient,
where: Where | str,
*,
who: Who | str | None = None
)
Bases: BaseLight
Dimmer items are items that can have their brightness level changed or colors changed.
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.
call_callbacks
async
classmethod
¶
call_callbacks(
item: BaseItem, 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. |
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. |
temporization_command
async
¶
Sends a temporization command
It will turn the light immediately on and then off after the specified time passed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hour
|
int
|
It indicates show many hours the actuator has to stay ON |
required |
minute
|
int
|
It indicates show many minutes the actuator has to stay ON |
required |
second
|
int
|
It indicates show many seconds the actuator has to stay ON |
required |
temporization_request
async
¶
request_working_time_lamp
async
¶
request_working_time_lamp() -> (
AsyncIterator[tuple[Where, int]]
)
Requests the gateway for how long the light has been on.
Yields:
Type | Description |
---|---|
AsyncIterator[tuple[Where, int]]
|
The time in hours the light has been on. The value is in the range [1-100000]. |
on_status_change
classmethod
¶
Registers a callback function to be called when the light status changes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback
|
Callable[[Self, bool]
|
The callback function to call. It will receive as arguments the item and the status. |
required |
on_temporization_change
classmethod
¶
Registers a callback function to be called when the temporization changes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback
|
Callable[[Self, int, int, int]
|
The callback function to call. It will receive as arguments the item, the hour, the minute, and the second. |
required |
turn_on
async
¶
turn_on(speed: int | None = None)
Turns the light on.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
speed
|
int | None
|
turn on the light with a specific speed [0-255] |
None
|
turn_off
async
¶
turn_off(speed: int | None = None)
Turns the light off.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
speed
|
int | None
|
turn off the light with a specific speed [0-255] |
None
|
up_percent
async
¶
down_percent
async
¶
get_status
async
¶
get_status() -> AsyncIterator[tuple[Where, int]]
Gets the status of the light.
Yields:
Type | Description |
---|---|
AsyncIterator[tuple[Where, int]]
|
tuple[Where, int]: the first element is the location of the light, |
AsyncIterator[tuple[Where, int]]
|
the second is the brightness level [0-100] |
set_brightness_with_speed
async
¶
set_hsv
async
¶
set_white_temperature
async
¶
set_white_temperature(temperature: int)
Sets the white temperature of the light.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
temperature
|
int
|
the temperature to set [1-65534] using the Mired scale. |
required |
request_current_brightness_speed
async
¶
request_current_brightness_speed() -> (
AsyncIterator[tuple[Where, int, int]]
)
Requests the current brightness and speed of the light.
Yields:
Type | Description |
---|---|
AsyncIterator[tuple[Where, int, int]]
|
A tuple with the where of the item, its brightness level, and its current speed. |
AsyncIterator[tuple[Where, int, int]]
|
The speed is in the range [0-255]. |
AsyncIterator[tuple[Where, int, int]]
|
The brightness is in the range [100-200]. |
request_current_hsv
async
¶
Requests the current HSV of the light, valid only for RGB lights.
Yields:
Type | Description |
---|---|
AsyncIterator[tuple[Where, int, int, int]]
|
A tuple with the where of the item, the hue, the saturation, and the value. The hue is in the range [0-359]. The saturation is in the range [0-100]. The value is in the range [0-100]. |
request_current_white_temperature
async
¶
request_current_white_temperature() -> (
AsyncIterator[tuple[Where, int]]
)
Requests the current white temperature of the light.
Yields:
Type | Description |
---|---|
AsyncIterator[tuple[Where, int]]
|
The where of the item and the temperature. The temperature is in the range [1-65534] using the Mired scale. |