pyscenario.manager

Device Manager Module.

This module contains classes for managing devices, including lights and covers. It provides methods for handling device states and configurations.

Classes

Cover(unique_id, name, zone, up, stop, down)

Class representing a cover device.

Device()

Base class for all devices.

DeviceManager(lights, covers, zones)

Class for managing a collection of devices.

Light(unique_id, name, zone, is_rgb, address)

Class representing a light device.

Documentation

class pyscenario.manager.Device[source]

Bases: object

Base class for all devices.

unique_id(str)
Type:

Unique identifier for the device.

name(str)
Type:

Name of the device.

zone(str)
Type:

Zone where the device is located.

callback_(Callable[[], None] | None)
Type:

Callback function for updates.

Initialize a Device object.

__init__() None[source]

Initialize a Device object.

get_device_id() str[source]

Return the unique ID of the device.

Returns:

str

Return type:

Unique ID of the device.

get_name() str[source]

Return the name of the device.

Returns:

str

Return type:

Name of the device.

add_subscriber(callback_: Callable[[], None]) None[source]

Set a callback function to be called when a response is received.

Parameters:

callback (Callable[[], None]) – The callback function.

remove_subscriber() None[source]

Remove the callback function.

class pyscenario.manager.Light(unique_id: str, name: str, zone: str, is_rgb: bool, address: list[dict[str, str]])[source]

Bases: Device

Class representing a light device.

unique_id(str)
Type:

Unique identifier for the light.

name(str)
Type:

Name of the light.

zone(str)
Type:

Zone where the light is located.

is_rgb(bool)
Type:

Indicates if the light supports RGB.

address(list[dict[str, str]])
Type:

List of addresses for the light.

Initialize a Light object.

Parameters:
  • unique_id (str) – Unique identifier for the light.

  • name (str) – Name of the light.

  • zone (str) – Zone where the light is located.

  • is_rgb (bool) – Indicates if the light supports RGB.

  • address (list[dict[str, str]]) – List of addresses for the light.

__init__(unique_id: str, name: str, zone: str, is_rgb: bool, address: list[dict[str, str]]) None[source]

Initialize a Light object.

Parameters:
  • unique_id (str) – Unique identifier for the light.

  • name (str) – Name of the light.

  • zone (str) – Zone where the light is located.

  • is_rgb (bool) – Indicates if the light supports RGB.

  • address (list[dict[str, str]]) – List of addresses for the light.

get_is_rgb() bool[source]

Return if the light supports RGB.

Returns:

bool

Return type:

True if the light supports RGB, False otherwise.

__annotations__ = {}
class pyscenario.manager.Cover(unique_id: str, name: str, zone: str, up: str, stop: str, down: str, module: int | None = None, open_channel: int | None = None, close_channel: int | None = None)[source]

Bases: Device

Class representing a cover device.

unique_id(str)
Type:

Unique identifier for the cover.

name(str)
Type:

Name of the cover.

zone(str)
Type:

Zone where the cover is located.

up(str)
Type:

Address for the up command.

stop(str)
Type:

Address for the stop command.

down(str)
Type:

Address for the down command.

is_closed(bool)
Type:

Indicates if the cover is closed.

Initialize a Cover object.

Parameters:
  • unique_id (str) – Unique identifier for the cover.

  • name (str) – Name of the cover.

  • zone (str) – Zone where the cover is located.

  • up (str) – Address for the up command.

  • stop (str) – Address for the stop command.

  • down (str) – Address for the down command.

  • module (int | None) – Opcional module address of the physical relay.

  • open_channel (int | None) – Opcional channel of the opening physical relay.

  • close_channel (int | None) – Opcional channel of the closing physical relay.

__init__(unique_id: str, name: str, zone: str, up: str, stop: str, down: str, module: int | None = None, open_channel: int | None = None, close_channel: int | None = None) None[source]

Initialize a Cover object.

Parameters:
  • unique_id (str) – Unique identifier for the cover.

  • name (str) – Name of the cover.

  • zone (str) – Zone where the cover is located.

  • up (str) – Address for the up command.

  • stop (str) – Address for the stop command.

  • down (str) – Address for the down command.

  • module (int | None) – Opcional module address of the physical relay.

  • open_channel (int | None) – Opcional channel of the opening physical relay.

  • close_channel (int | None) – Opcional channel of the closing physical relay.

__annotations__ = {}
class pyscenario.manager.DeviceManager(lights: list[Light], covers: list[Cover], zones: dict[str, str])[source]

Bases: object

Class for managing a collection of devices.

lights(list[Light])
Type:

List of light devices.

covers(list[Cover])
Type:

List of cover devices.

zones(dict[str, str])
Type:

Dictionary mapping zone IDs to zone names.

Initialize a DeviceManager object.

Parameters:
  • lights (list[Light]) – List of light devices.

  • covers (list[Cover]) – List of cover devices.

  • zones (dict[str, str]) – Dictionary mapping zone IDs to zone names.

__init__(lights: list[Light], covers: list[Cover], zones: dict[str, str]) None[source]

Initialize a DeviceManager object.

Parameters:
  • lights (list[Light]) – List of light devices.

  • covers (list[Cover]) – List of cover devices.

  • zones (dict[str, str]) – Dictionary mapping zone IDs to zone names.

classmethod from_config(config_file: str)[source]

Create a DeviceManager object from a configuration file.

Parameters:

config_file (str) – Path to the configuration file.

Returns:

DeviceManager | None

Return type:

An instance of the DeviceManager class, or None if the file is not found.

get_devices_by_type(device_type: str) list[Light] | list[Cover] | None[source]

Get devices by type.

Parameters:

device_type (str) – The type of device to retrieve (LIGHT_DEVICES or COVER_DEVICES).

Returns:

list[Light] | list[Cover] | None

Return type:

List of devices of the specified type, or None if the type is invalid.

get_device_by_id(id: str) Device | None[source]

Get a device by its unique ID.

Parameters:

id (str) – The unique ID of the device.

Returns:

Device | None

Return type:

The device with the specified ID, or None if not found.

async async_handle_zone_state_change(module_number: int, channel: int, state: int) None[source]

Asynchronously update the intensity of a device.

Parameters:
  • module_number (int) – The module number.

  • channel (int) – The channel number.

  • state (int) – The new state to set.

async async_handle_scene_state_change(change_address: str, state: str) None[source]

Asynchronously update the state of a scene.

Parameters:
  • change_address (str) – The address to change.

  • state (str) – The new state to set.

notify_subscriber(**kwargs: str) None[source]

Notify subscribers about changes.

Parameters:

**kwargs (str) – Keyword arguments containing the state changes.