I might be wrong - looking at the code the way I interpret it, it looks for devices for 15seconds then if nothing new is discovered after another 5 it then checks to see if it found one that matches the MAC in the .ini and then tries to connect.
It would be straight forward to detect the failure to connect to the given device and build say 3 retries around it though
You can see though from the Journal it works first time for mine (consistently)
Mar 08 17:07:51 solarpi systemd[1]: Started Solar Monitor.
Mar 08 17:07:55 solarpi solar-monitor.py[8384]: INFO: Adapter status - Powered: True
Mar 08 17:07:55 solarpi solar-monitor.py[8384]: INFO: Starting discovery...
Mar 08 17:08:10 solarpi solar-monitor.py[8384]: INFO: Found 13 BLE-devices
Mar 08 17:08:10 solarpi solar-monitor.py[8384]: INFO: Trying to connect to 80:6f:b0:10:4d:c6...
Mar 08 17:08:10 solarpi solar-monitor.py[8384]: INFO: Successfully imported SolarLink.
Mar 08 17:08:10 solarpi solar-monitor.py[8384]: INFO: [regulator] Connecting to 80:6f:b0:10:4d:c6
Mar 08 17:08:11 solarpi solar-monitor.py[8384]: INFO: [regulator] Connected to BT-TH-B0104DC6
Mar 08 17:08:11 solarpi solar-monitor.py[8384]: INFO: [regulator] Resolved services
.....
for dev in device_manager.devices():
logging.debug("Processing device {} {}".format(dev.mac_address, dev.alias()))
for section in config.sections():
if config.get(section, "mac", fallback=None) and config.get(section, "type", fallback=None):
mac = config.get(section, "mac").lower()
if dev.mac_address.lower() == mac:
logging.info("Trying to connect to {}...".format(dev.mac_address))
try:
device = SolarDevice(mac_address=dev.mac_address, manager=device_manager, logger_name=section, config=config, datalogger=datalogger)
except Exception as e:
logging.error(e)
continue
device.connect()
It would be straight forward to detect the failure to connect to the given device and build say 3 retries around it though
You can see though from the Journal it works first time for mine (consistently)
Mar 08 17:07:51 solarpi systemd[1]: Started Solar Monitor.
Mar 08 17:07:55 solarpi solar-monitor.py[8384]: INFO: Adapter status - Powered: True
Mar 08 17:07:55 solarpi solar-monitor.py[8384]: INFO: Starting discovery...
Mar 08 17:08:10 solarpi solar-monitor.py[8384]: INFO: Found 13 BLE-devices
Mar 08 17:08:10 solarpi solar-monitor.py[8384]: INFO: Trying to connect to 80:6f:b0:10:4d:c6...
Mar 08 17:08:10 solarpi solar-monitor.py[8384]: INFO: Successfully imported SolarLink.
Mar 08 17:08:10 solarpi solar-monitor.py[8384]: INFO: [regulator] Connecting to 80:6f:b0:10:4d:c6
Mar 08 17:08:11 solarpi solar-monitor.py[8384]: INFO: [regulator] Connected to BT-TH-B0104DC6
Mar 08 17:08:11 solarpi solar-monitor.py[8384]: INFO: [regulator] Resolved services
.....
for dev in device_manager.devices():
logging.debug("Processing device {} {}".format(dev.mac_address, dev.alias()))
for section in config.sections():
if config.get(section, "mac", fallback=None) and config.get(section, "type", fallback=None):
mac = config.get(section, "mac").lower()
if dev.mac_address.lower() == mac:
logging.info("Trying to connect to {}...".format(dev.mac_address))
try:
device = SolarDevice(mac_address=dev.mac_address, manager=device_manager, logger_name=section, config=config, datalogger=datalogger)
except Exception as e:
logging.error(e)
continue
device.connect()