jvconnected.engine

class jvconnected.engine.Engine(*args, **kwargs)[source]

Bases: Dispatcher

Top level component to handle config, discovery and device control

DictProperty devices: Dict[str, Device]

Mapping of Device instances using their id as keys

devices is a pydispatch.DictProperty object.

DictProperty interfaces: Dict[str, jvconnected.interfaces.base.Interface]

Container for Interface instances

interfaces is a pydispatch.DictProperty object.

Event on_config_device_added(conf_device: DeviceConfig)[source]

Fired when an instance of DeviceConfig is added

on_config_device_added is a pydispatch.Event object.

Event on_device_discovered(conf_device: DeviceConfig)[source]

Fired when a device is detected on the network. An instance of DeviceConfig is found (or created) and passed as the argument

on_device_discovered is a pydispatch.Event object.

Event on_device_added(device: Device)[source]

Fired when an instance of Device is added to devices

on_device_added is a pydispatch.Event object.

Event on_device_connected(device: Device)[source]

Fired when an instance of Device has been added and successfully connected

on_device_connected is a pydispatch.Event object.

Event on_device_removed(device: Device, reason: RemovalReason)[source]

Fired when an instance of Device is removed

Parameters
  • device (Device) – The device that was removed

  • reason (RemovalReason) – Reason for removal

on_device_removed is a pydispatch.Event object.

Property auto_add_devices = True

If True, devices will be added automatically when discovered on the network. Otherwise, they must be added manually using add_device_from_conf()

auto_add_devices is a pydispatch.Property object.

config: Config

The Config instance

discovery: Discovery

The Discovery instance

connection_status: Dict[str, ReconnectStatus]

Mapping of ReconnectStatus instances using the associated device_id as keys

run_forever()[source]

Convenience method to open and run until interrupted

async open()[source]

Open all communication methods

async add_always_connected_devices()[source]

Create and open any devices with always_connect set to True

async close()[source]

Close the discovery engine and any running device clients

async add_device_from_conf(device_conf: jvconnected.config.DeviceConfig)[source]

Add a client Device instance from the given DeviceConfig and attempt to connect.

If auth information is incorrect or does not exist, display the error and remove the newly added device.

async disconnect_device(device_id: str)[source]

Disconnect the device matching the given id (if connected)

async reconnect_device(device_conf: DeviceConfig, wait_for_status: bool = False)[source]

Attempt to reestablish a device connection

This method is primarily useful when a new device is discovered and authentication information is needed for it. Once the information is set on the device_conf, this method may be used to retry the connection.

Parameters
add_discovered_device(info: zeroconf.ServiceInfo) DeviceConfig[source]

Create a DeviceConfig and add it to discovered_devices