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 theirid
as keysdevices
is apydispatch.DictProperty
object.
- DictProperty interfaces: Dict[str, jvconnected.interfaces.base.Interface]
Container for
Interface
instancesinterfaces
is apydispatch.DictProperty
object.
- Event on_config_device_added(conf_device: DeviceConfig)[source]
Fired when an instance of
DeviceConfig
is addedon_config_device_added
is apydispatch.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 argumenton_device_discovered
is apydispatch.Event
object.
- Event on_device_added(device: Device)[source]
Fired when an instance of
Device
is added todevices
on_device_added
is apydispatch.Event
object.
- Event on_device_connected(device: Device)[source]
Fired when an instance of
Device
has been added and successfully connectedon_device_connected
is apydispatch.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 apydispatch.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 usingadd_device_from_conf()
auto_add_devices
is apydispatch.Property
object.
- connection_status: Dict[str, ReconnectStatus]
Mapping of
ReconnectStatus
instances using the associateddevice_id
as keys
- async add_always_connected_devices()[source]
Create and open any devices with
always_connect
set to True
- async add_device_from_conf(device_conf: jvconnected.config.DeviceConfig)[source]
Add a client
Device
instance from the givenDeviceConfig
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
device_conf (DeviceConfig) – The
DeviceConfig
to reconnectwait_for_status (bool) – If
True
, attempt to wait for the connection state (usingReconnectStatus.wait_for_connect_or_failure()
). Default is False
- add_discovered_device(info: zeroconf.ServiceInfo) DeviceConfig [source]
Create a
DeviceConfig
and add it todiscovered_devices