jvconnected.config

jvconnected.config.get_config_dir(app_name: str) pathlib.Path[source]

Get the platform’s preferred configuration directory

  • For Windows, the %LOCALAPPDATA% environment variable is used. Typically c:\Users\<username>\AppData\Local

  • For MacOS, ~/Library/Preferences

  • All others will be ~/.config

class jvconnected.config.Config(*args, **kwargs)[source]

Bases: pydispatch.dispatch.Dispatcher

Configuration storage

This object provides a dict-like interface and stores the configuration data automatically when it changes. The stored config data is read on initialization.

Parameters

filename (pathlib.Path, optional) – The configuration filename. If not provided, the DEFAULT_FILENAME is used

Attributes
update(other: Dict)[source]

Update from another dict

add_device(device: jvconnected.config.DeviceConfig) jvconnected.config.DeviceConfig[source]

Add a DeviceConfig instance

If a device config already exists, it will be updated with the info provided using DeviceConfig.update_from_other()

If its device_index is set, it will be added to indexed_devices.

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

Add a DeviceConfig from zeroconf data

class jvconnected.config.DeviceConfig(*args, **kwargs)[source]

Bases: pydispatch.dispatch.Dispatcher

Configuration data for a device

Properties
name: str Property(str)

The device name, taken from zeroconf.ServiceInfo.get_name()

dns_name: str Property(str)

The fully qualified name for the service host, taken from ServiceInfo.server

fqdn: str Property(str)

The fully qualified service name, taken from ServiceInfo.name

hostaddr: str Property(str)

The IPv4 address (in string form)

hostport: int Property(int)

The service port

display_name: str Property(str)

A user-defined name for the device, defaults to name

auth_user: str Property(str)

Username to use with authentication

auth_pass: str Property(str)

Password to use with authentication

device_index: int Property(int)

Index for the device for organization purposes. If None (default), no index is assigned. Otherwise, the index will be assigned according to jvconnected.utils.IndexedDict.add()

always_connect: bool Property(bool)

If True, the Engine will attempt to connect to this device without it being discovered on the network

online: bool Property(bool)

True if the device is currently active on the network

active: bool Property(bool)

True if a jvconnected.device.Device is currently communicating with the device

Events
on_change(instance, prop_name, value)

Fired when any property value changes

property model_name str   [read-only]

The model name of the device, taken from ServiceInfo.properties

property serial_number str   [read-only]

The serial number of the device, taken from the service name hc500-XXXXXXXX where XXXXXXXX is the serial number

property id str   [read-only]

A unique id for the device using the model_name and serial_number attributes

classmethod get_id_for_service_info(info: zeroconf.ServiceInfo) str[source]

Get the id attribute for the given zeroconf.ServiceInfo

classmethod get_props_from_service_info(info: zeroconf.ServiceInfo) Dict[source]

Build a dictionary of instance attributes from a zeroconf.ServiceInfo

classmethod from_service_info(info: zeroconf.ServiceInfo) DeviceConfig[source]

Construct an instance from a zeroconf.ServiceInfo

build_service_info() zeroconf._services.info.ServiceInfo[source]

Create a zeroconf.ServiceInfo from the values in this instance

update_from_service_info(info: zeroconf.ServiceInfo)[source]

Update instance attributes from a zeroconf.ServiceInfo

update_from_other(other: jvconnected.config.DeviceConfig)[source]

Update from another instance of DeviceConfig