How to use the solaar.configuration.attach_to function in solaar

To help you get started, we’ve selected a few solaar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pwr-Solaar / Solaar / lib / solaar / cli / config.py View on Github external
def run(receivers, args, find_receiver, find_device):
	assert receivers
	assert args.device

	device_name = args.device.lower()
	dev = find_device(receivers, device_name)

	if not dev.ping():
		raise Exception('%s is offline' % dev.name)

	if not dev.settings:
		raise Exception('no settings for %s' % dev.name)

	_configuration.attach_to(dev)

	if not args.setting:
		print (dev.name, '(%s) [%s:%s]' % (dev.codename, dev.wpid, dev.serial))
		for s in dev.settings:
			print ('')
			_print_setting(s)
		return

	setting_name = args.setting.lower()
	setting = None
	for s in dev.settings:
		if setting_name == s.name.lower():
			setting = s
			break
	if setting is None:
		raise Exception("no setting '%s' for %s" % (args.setting, dev.name))