def upload_program(config, args, port): _LOGGER.info("Uploading binary...") if port != 'OTA': if core.ESP_PLATFORM == ESP_PLATFORM_ESP8266 and args.use_esptoolpy: return upload_using_esptool(config, port) return run_platformio('platformio', 'run', '-d', get_base_path(config), '-t', 'upload', '--upload-port', port) if 'ota' not in config: _LOGGER.error( "No serial port found and OTA not enabled. Can't upload!") return -1 host = get_upload_host(config) from esphomeyaml.components import ota from esphomeyaml import espota bin_file = os.path.join(get_base_path(config), '.pioenvs', get_name(config), 'firmware.bin') if args.host_port is not None: host_port = args.host_port else: host_port = int( os.getenv('ESPHOMEYAML_OTA_HOST_PORT', random.randint(10000, 60000))) espota_args = [ 'espota.py', '--debug', '--progress', '-i', host, '-p', str(ota.get_port(config)), '-f', bin_file, '-a', ota.get_auth(config), '-P', str(host_port) ] return espota.main(espota_args)
def upload_program(config, args, port): _LOGGER.info("Uploading binary...") if port is not None: return run_platformio('platformio', 'run', '-d', get_base_path(config), '-t', 'upload', '--upload-port', port) if CONF_MANUAL_IP in config[CONF_WIFI]: host = str(config[CONF_WIFI][CONF_MANUAL_IP][CONF_STATIC_IP]) elif CONF_HOSTNAME in config[CONF_WIFI]: host = config[CONF_WIFI][CONF_HOSTNAME] + u'.local' else: host = config[CONF_ESPHOMEYAML][CONF_NAME] + u'.local' from esphomeyaml.components import ota from esphomeyaml import espota bin_file = os.path.join(get_base_path(config), '.pioenvs', get_name(config), 'firmware.bin') if args.host_port is not None: host_port = args.host_port else: host_port = int( os.getenv('ESPHOMEYAML_OTA_HOST_PORT', random.randint(10000, 60000))) espota_args = [ 'espota.py', '--debug', '--progress', '-i', host, '-p', str(ota.get_port(config)), '-f', bin_file, '-a', ota.get_auth(config), '-P', str(host_port) ] return espota.main(espota_args)
def run_legacy_ota(verbose, host_port, remote_host, remote_port, password, filename): from esphomeyaml import espota espota_args = ['espota.py', '--debug', '--progress', '-i', remote_host, '-p', str(remote_port), '-f', filename, '-a', password, '-P', str(host_port)] if verbose: espota_args.append('-d') return espota.main(espota_args)
def upload_program(config, args, port): _LOGGER.info("Uploading binary...") build_path = relative_path(config[CONF_ESPHOMEYAML][CONF_BUILD_PATH]) # if upload is to a serial port use platformio, otherwise assume ota serial_port = port.startswith('/') or port.startswith('COM') if port != 'OTA' and serial_port: if core.ESP_PLATFORM == ESP_PLATFORM_ESP8266 and args.use_esptoolpy: return upload_using_esptool(config, port) command = [ 'platformio', 'run', '-d', build_path, '-t', 'upload', '--upload-port', port ] if args.verbose: command.append('-v') return run_platformio(*command) if 'ota' not in config: _LOGGER.error( "No serial port found and OTA not enabled. Can't upload!") return -1 # If hostname/ip is explicitly provided as upload-port argument, use this instead of zeroconf # hostname. This is to support use cases where zeroconf (hostname.local) does not work. if port != 'OTA': host = port else: host = get_upload_host(config) from esphomeyaml.components import ota from esphomeyaml import espota bin_file = os.path.join(build_path, '.pioenvs', core.NAME, 'firmware.bin') if args.host_port is not None: host_port = args.host_port else: host_port = int( os.getenv('ESPHOMEYAML_OTA_HOST_PORT', random.randint(10000, 60000))) espota_args = [ 'espota.py', '--debug', '--progress', '-i', host, '-p', str(ota.get_port(config)), '-f', bin_file, '-a', ota.get_auth(config), '-P', str(host_port) ] if args.verbose: espota_args.append('-d') return espota.main(espota_args)