mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-29 22:24:26 +00:00 
			
		
		
		
	Separate OTABackend from OTA component (#6459)
				
					
				
			Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
		| @@ -3,28 +3,29 @@ wifi: | ||||
|   password: password1 | ||||
|  | ||||
| ota: | ||||
|   safe_mode: true | ||||
|   password: "superlongpasswordthatnoonewillknow" | ||||
|   port: 3286 | ||||
|   reboot_timeout: 2min | ||||
|   num_attempts: 5 | ||||
|   on_begin: | ||||
|     then: | ||||
|       - logger.log: "OTA start" | ||||
|   on_progress: | ||||
|     then: | ||||
|       - logger.log: | ||||
|           format: "OTA progress %0.1f%%" | ||||
|           args: ["x"] | ||||
|   on_end: | ||||
|     then: | ||||
|       - logger.log: "OTA end" | ||||
|   on_error: | ||||
|     then: | ||||
|       - logger.log: | ||||
|           format: "OTA update error %d" | ||||
|           args: ["x"] | ||||
|   on_state_change: | ||||
|     then: | ||||
|       lambda: >- | ||||
|         ESP_LOGD("ota", "State %d", state); | ||||
|   - platform: esphome | ||||
|     safe_mode: true | ||||
|     password: "superlongpasswordthatnoonewillknow" | ||||
|     port: 3286 | ||||
|     reboot_timeout: 2min | ||||
|     num_attempts: 5 | ||||
|     on_begin: | ||||
|       then: | ||||
|         - logger.log: "OTA start" | ||||
|     on_progress: | ||||
|       then: | ||||
|         - logger.log: | ||||
|             format: "OTA progress %0.1f%%" | ||||
|             args: ["x"] | ||||
|     on_end: | ||||
|       then: | ||||
|         - logger.log: "OTA end" | ||||
|     on_error: | ||||
|       then: | ||||
|         - logger.log: | ||||
|             format: "OTA update error %d" | ||||
|             args: ["x"] | ||||
|     on_state_change: | ||||
|       then: | ||||
|         lambda: >- | ||||
|           ESP_LOGD("ota", "State %d", state); | ||||
|   | ||||
| @@ -3,6 +3,8 @@ wifi: | ||||
|   password: password1 | ||||
|  | ||||
| ota: | ||||
|   - platform: esphome | ||||
|     safe_mode: true | ||||
|  | ||||
| button: | ||||
|   - platform: safe_mode | ||||
|   | ||||
| @@ -5,7 +5,7 @@ | ||||
|  | ||||
| #include <esphome/components/gpio/switch/gpio_switch.h> | ||||
| #include <esphome/components/logger/logger.h> | ||||
| #include <esphome/components/ota/ota_component.h> | ||||
| #include <esphome/components/esphome/ota/ota_esphome.h> | ||||
| #include <esphome/components/wifi/wifi_component.h> | ||||
| #include <esphome/core/application.h> | ||||
|  | ||||
| @@ -25,7 +25,7 @@ void setup() { | ||||
|   ap.set_password("password1"); | ||||
|   wifi->add_sta(ap); | ||||
|  | ||||
|   auto *ota = new ota::OTAComponent();  // NOLINT | ||||
|   auto *ota = new esphome::ESPHomeOTAComponent();  // NOLINT | ||||
|   ota->set_port(8266); | ||||
|  | ||||
|   App.setup(); | ||||
|   | ||||
| @@ -265,29 +265,30 @@ uart: | ||||
|     baud_rate: 9600 | ||||
|  | ||||
| ota: | ||||
|   safe_mode: true | ||||
|   password: "superlongpasswordthatnoonewillknow" | ||||
|   port: 3286 | ||||
|   reboot_timeout: 2min | ||||
|   num_attempts: 5 | ||||
|   on_state_change: | ||||
|     then: | ||||
|       lambda: >- | ||||
|         ESP_LOGD("ota", "State %d", state); | ||||
|   on_begin: | ||||
|     then: | ||||
|       logger.log: OTA begin | ||||
|   on_progress: | ||||
|     then: | ||||
|       lambda: >- | ||||
|         ESP_LOGD("ota", "Got progress %f", x); | ||||
|   on_end: | ||||
|     then: | ||||
|       logger.log: OTA end | ||||
|   on_error: | ||||
|     then: | ||||
|       lambda: >- | ||||
|         ESP_LOGD("ota", "Got error code %d", x); | ||||
|   - platform: esphome | ||||
|     safe_mode: true | ||||
|     password: "superlongpasswordthatnoonewillknow" | ||||
|     port: 3286 | ||||
|     reboot_timeout: 2min | ||||
|     num_attempts: 5 | ||||
|     on_state_change: | ||||
|       then: | ||||
|         lambda: >- | ||||
|           ESP_LOGD("ota", "State %d", state); | ||||
|     on_begin: | ||||
|       then: | ||||
|         logger.log: OTA begin | ||||
|     on_progress: | ||||
|       then: | ||||
|         lambda: >- | ||||
|           ESP_LOGD("ota", "Got progress %f", x); | ||||
|     on_end: | ||||
|       then: | ||||
|         logger.log: OTA end | ||||
|     on_error: | ||||
|       then: | ||||
|         lambda: >- | ||||
|           ESP_LOGD("ota", "Got error code %d", x); | ||||
|  | ||||
| logger: | ||||
|   baud_rate: 0 | ||||
|   | ||||
| @@ -31,6 +31,7 @@ network: | ||||
| api: | ||||
|  | ||||
| ota: | ||||
|   - platform: esphome | ||||
|  | ||||
| logger: | ||||
|  | ||||
|   | ||||
| @@ -80,9 +80,10 @@ uart: | ||||
|       - lambda: UARTDebug::log_hex(direction, bytes, ':'); | ||||
|  | ||||
| ota: | ||||
|   safe_mode: true | ||||
|   port: 3286 | ||||
|   num_attempts: 15 | ||||
|   - platform: esphome | ||||
|     safe_mode: true | ||||
|     port: 3286 | ||||
|     num_attempts: 15 | ||||
|  | ||||
| logger: | ||||
|   level: DEBUG | ||||
|   | ||||
| @@ -49,7 +49,8 @@ spi: | ||||
|     number: GPIO14 | ||||
|  | ||||
| ota: | ||||
|   version: 2 | ||||
|   - platform: esphome | ||||
|     version: 2 | ||||
|  | ||||
| logger: | ||||
|  | ||||
|   | ||||
| @@ -328,9 +328,10 @@ vbus: | ||||
|   uart_id: uart_4 | ||||
|  | ||||
| ota: | ||||
|   safe_mode: true | ||||
|   port: 3286 | ||||
|   reboot_timeout: 15min | ||||
|   - platform: esphome | ||||
|     safe_mode: true | ||||
|     port: 3286 | ||||
|     reboot_timeout: 15min | ||||
|  | ||||
| logger: | ||||
|   hardware_uart: UART1 | ||||
|   | ||||
| @@ -103,8 +103,9 @@ uart: | ||||
|     parity: EVEN | ||||
|  | ||||
| ota: | ||||
|   safe_mode: true | ||||
|   port: 3286 | ||||
|   - platform: esphome | ||||
|     safe_mode: true | ||||
|     port: 3286 | ||||
|  | ||||
| logger: | ||||
|   level: DEBUG | ||||
|   | ||||
| @@ -28,6 +28,7 @@ network: | ||||
| api: | ||||
|  | ||||
| ota: | ||||
|   - platform: esphome | ||||
|  | ||||
| logger: | ||||
|  | ||||
|   | ||||
| @@ -22,6 +22,7 @@ network: | ||||
| api: | ||||
|  | ||||
| ota: | ||||
|   - platform: esphome | ||||
|  | ||||
| logger: | ||||
|  | ||||
|   | ||||
| @@ -12,6 +12,7 @@ esphome: | ||||
| logger: | ||||
|  | ||||
| ota: | ||||
|   - platform: esphome | ||||
|  | ||||
| captive_portal: | ||||
|  | ||||
|   | ||||
| @@ -12,6 +12,7 @@ esphome: | ||||
| logger: | ||||
|  | ||||
| ota: | ||||
|   - platform: esphome | ||||
|  | ||||
| captive_portal: | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user