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. Typicallyc:\Users\<username>\AppData\LocalFor MacOS,
~/Library/PreferencesAll others will be
~/.config
- class jvconnected.config.Config(*args, **kwargs)[source]
Bases:
DispatcherConfiguration 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, theDEFAULT_FILENAMEis used
- DEFAULT_FILENAME: Path = PosixPath('/home/docs/.config/jvconnected/config.json')
Platform-dependent default filename (
<config_dir>/jvconnected/config.json). Where<config_dir>is chosen inget_config_dir()
- Event on_device_added(device: DeviceConfig)[source]
Triggered when a device is added to the config
on_device_addedis apydispatch.Eventobject.
- indexed_devices: IndexedDict
An instance of
jvconnected.utils.IndexedDictto handle device indexing
- property devices: Dict[str, DeviceConfig]
Mapping of
DeviceConfigusing theiridas keys
- add_device(device: DeviceConfig) DeviceConfig[source]
Add a
DeviceConfiginstanceIf a device config already exists, it will be updated with the info provided using
DeviceConfig.update_from_other()If its
device_indexis set, it will be added toindexed_devices.
- add_discovered_device(info: zeroconf.ServiceInfo) DeviceConfig[source]
Add a
DeviceConfigfrom zeroconf data
- class jvconnected.config.DeviceConfig(*args, **kwargs)[source]
Bases:
DispatcherConfiguration data for a device
- Property name: str = ''
The device name, taken from
zeroconf.ServiceInfo.get_name()nameis apydispatch.Propertyobject.
- Property dns_name: str = ''
The fully qualified name for the service host, taken from
ServiceInfo.serverdns_nameis apydispatch.Propertyobject.
- Property fqdn: str = ''
The fully qualified service name, taken from
ServiceInfo.namefqdnis apydispatch.Propertyobject.
- Property hostaddr: str = ''
The IPv4 address (in string form)
hostaddris apydispatch.Propertyobject.
- Property hostport: int = 80
The service port
hostportis apydispatch.Propertyobject.
- Property auth_user: str | None = None
Username to use with authentication
auth_useris apydispatch.Propertyobject.
- Property auth_pass: str | None = None
Password to use with authentication
auth_passis apydispatch.Propertyobject.
- Property device_index: int | None = None
Index for the device for organization purposes.
If
None(default), no index is assigned. Otherwise, the index will be assigned according tojvconnected.utils.IndexedDict.add()device_indexis apydispatch.Propertyobject.
- Property always_connect: bool = False
If
True, theEnginewill attempt to connect to this device without it being discovered on the networkalways_connectis apydispatch.Propertyobject.
- Property stored_in_config: bool = False
Trueif the device is stored inConfigstored_in_configis apydispatch.Propertyobject.
- Property online: bool = False
Trueif the device is currently active on the networkonlineis apydispatch.Propertyobject.
- Property active: bool = False
Trueif ajvconnected.device.Deviceis currently communicating with the deviceactiveis apydispatch.Propertyobject.
- Property connection_state: ConnectionState = ConnectionState.UNKNOWN
The device’s
ConnectionStateconnection_stateis apydispatch.Propertyobject.
- Event on_change(prop_name: str, value: Any)[source]
Fired when any property value changes
- Parameters
instance (DeviceConfig) – The instance whose property changed
prop_name (str) – The Property name
value (Any) – New value for the Property
on_changeis apydispatch.Eventobject.
- Property display_name: str = ''
A user-defined name for the device, defaults to
namedisplay_nameis apydispatch.Propertyobject.
- property model_name: str
The model name of the device, taken from
ServiceInfo.properties
- property serial_number: str
The serial number of the device, taken from the service name
hc500-XXXXXXXXwhereXXXXXXXXis the serial number
- property id: str
A unique id for the device using the
model_nameandserial_numberattributes
- classmethod get_id_for_service_info(info: zeroconf.ServiceInfo) str[source]
Get the
idattribute for the givenzeroconf.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() ServiceInfo[source]
Create a
zeroconf.ServiceInfofrom the values in this instance
- update_from_service_info(info: zeroconf.ServiceInfo)[source]
Update instance attributes from a
zeroconf.ServiceInfo
- update_from_other(other: DeviceConfig)[source]
Update from another instance of
DeviceConfig