Lighting module
The Lighting module provides the main interface to the OpenWebNet lighting system.
pyown.items.lighting.base.WhatLight
¶
flowchart TD
pyown.items.lighting.base.WhatLight[WhatLight]
pyown.tags.what.What[What]
pyown.tags.base.TagWithParameters[TagWithParameters]
pyown.tags.base.Tag[Tag]
pyown.tags.what.What --> pyown.items.lighting.base.WhatLight
pyown.tags.base.TagWithParameters --> pyown.tags.what.What
pyown.tags.base.Tag --> pyown.tags.base.TagWithParameters
click pyown.items.lighting.base.WhatLight href "" "pyown.items.lighting.base.WhatLight"
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 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
flowchart TD
pyown.items.lighting.base.LightEvents[LightEvents]
click pyown.items.lighting.base.LightEvents href "" "pyown.items.lighting.base.LightEvents"
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,
)
flowchart TD
pyown.items.lighting.base.BaseLight[BaseLight]
pyown.items.base.BaseItem[BaseItem]
pyown.items.base.BaseItem --> pyown.items.lighting.base.BaseLight
click pyown.items.lighting.base.BaseLight href "" "pyown.items.lighting.base.BaseLight"
click pyown.items.base.BaseItem href "" "pyown.items.base.BaseItem"
Base class for all light items.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
BaseClient
|
The client to use to communicate with the server. |
required |
where
|
Where | str
|
The location of the item. |
required |
who
|
Who | str | None
|
The type of item. |
None
|
client
property
writable
¶
client: BaseClient
Returns the client used to communicate with the server.
get_status
abstractmethod
¶
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
¶
on_temporization_change(
callback: Callable[
[Self, int, int, int], Coroutine[None, None, None]
],
)
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]
Dispatches the message to the registered light 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
create_dimension_writing_message
¶
create_dimension_writing_message(
dimension: Dimension, *args: Value
) -> DimensionWriting
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
¶
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. |
pyown.items.lighting.light.Light
¶
Light(
client: BaseClient,
where: Where | str,
*,
who: Who | str | None = None,
)
Bases: BaseLight
flowchart TD
pyown.items.lighting.light.Light[Light]
pyown.items.lighting.base.BaseLight[BaseLight]
pyown.items.base.BaseItem[BaseItem]
pyown.items.lighting.base.BaseLight --> pyown.items.lighting.light.Light
pyown.items.base.BaseItem --> pyown.items.lighting.base.BaseLight
click pyown.items.lighting.light.Light href "" "pyown.items.lighting.light.Light"
click pyown.items.lighting.base.BaseLight href "" "pyown.items.lighting.base.BaseLight"
click pyown.items.base.BaseItem href "" "pyown.items.base.BaseItem"
Light items are item with only two states: on and off.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
BaseClient
|
The client to use to communicate with the server. |
required |
where
|
Where | str
|
The location of the item. |
required |
who
|
Who | str | None
|
The type of item. |
None
|
client
property
writable
¶
client: BaseClient
Returns the client used to communicate with the server.
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. |
call_callbacks
async
classmethod
¶
call_callbacks(
item: BaseItem, message: BaseMessage
) -> list[Task]
Dispatches the message to the registered light 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
create_dimension_writing_message
¶
create_dimension_writing_message(
dimension: Dimension, *args: Value
) -> DimensionWriting
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
¶
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
¶
on_temporization_change(
callback: Callable[
[Self, int, int, int], Coroutine[None, None, None]
],
)
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 |
pyown.items.lighting.dimmer.Dimmer
¶
Dimmer(
client: BaseClient,
where: Where | str,
*,
who: Who | str | None = None,
)
Bases: BaseLight
flowchart TD
pyown.items.lighting.dimmer.Dimmer[Dimmer]
pyown.items.lighting.base.BaseLight[BaseLight]
pyown.items.base.BaseItem[BaseItem]
pyown.items.lighting.base.BaseLight --> pyown.items.lighting.dimmer.Dimmer
pyown.items.base.BaseItem --> pyown.items.lighting.base.BaseLight
click pyown.items.lighting.dimmer.Dimmer href "" "pyown.items.lighting.dimmer.Dimmer"
click pyown.items.lighting.base.BaseLight href "" "pyown.items.lighting.base.BaseLight"
click pyown.items.base.BaseItem href "" "pyown.items.base.BaseItem"
Dimmer items are items that can have their brightness level changed or colors changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
BaseClient
|
The client to use to communicate with the server. |
required |
where
|
Where | str
|
The location of the item. |
required |
who
|
Who | str | None
|
The type of item. |
None
|
client
property
writable
¶
client: BaseClient
Returns the client used to communicate with the server.
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. |
on_luminosity_change
classmethod
¶
on_hsv_change
classmethod
¶
on_white_temp_change
classmethod
¶
call_callbacks
async
classmethod
¶
call_callbacks(
item: BaseItem, message: BaseMessage
) -> list[Task]
Dispatches the message to the registered light 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
create_dimension_writing_message
¶
create_dimension_writing_message(
dimension: Dimension, *args: Value
) -> DimensionWriting
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
¶
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
¶
on_temporization_change(
callback: Callable[
[Self, int, int, int], Coroutine[None, None, None]
],
)
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 |