mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			96 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			96 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
| <<: !include http_request.yaml
 | |
| 
 | |
| wifi:
 | |
|   ssid: MySSID
 | |
|   password: password1
 | |
| 
 | |
| esphome:
 | |
|   on_boot:
 | |
|     then:
 | |
|       - http_request.get:
 | |
|           url: https://esphome.io
 | |
|           request_headers:
 | |
|             Content-Type: application/json
 | |
|           collect_headers:
 | |
|             - age
 | |
|           on_error:
 | |
|             logger.log: "Request failed"
 | |
|           on_response:
 | |
|             then:
 | |
|               - logger.log:
 | |
|                   format: "Response status: %d, Duration: %lu ms, age: %s"
 | |
|                   args:
 | |
|                     - response->status_code
 | |
|                     - (long) response->duration_ms
 | |
|                     - response->get_response_header("age").c_str()
 | |
|       - http_request.post:
 | |
|           url: https://esphome.io
 | |
|           request_headers:
 | |
|             Content-Type: application/json
 | |
|           json:
 | |
|             key: value
 | |
|       - http_request.send:
 | |
|           method: PUT
 | |
|           url: https://esphome.io
 | |
|           request_headers:
 | |
|             Content-Type: application/json
 | |
|           body: "Some data"
 | |
| 
 | |
| http_request:
 | |
|   useragent: esphome/tagreader
 | |
|   timeout: 10s
 | |
|   verify_ssl: ${verify_ssl}
 | |
| 
 | |
| script:
 | |
|   - id: does_not_compile
 | |
|     parameters:
 | |
|       api_url: string
 | |
|     then:
 | |
|       - http_request.get:
 | |
|           url: "http://google.com"
 | |
| 
 | |
| ota:
 | |
|   - platform: http_request
 | |
|     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);'
 | |
| 
 | |
| button:
 | |
|   - platform: template
 | |
|     name: Firmware update
 | |
|     on_press:
 | |
|       then:
 | |
|         - ota.http_request.flash:
 | |
|             md5_url: http://my.ha.net:8123/local/esphome/firmware.md5
 | |
|             url: http://my.ha.net:8123/local/esphome/firmware.bin
 | |
| 
 | |
|         - ota.http_request.flash:
 | |
|             md5: 0123456789abcdef0123456789abcdef
 | |
|             url: http://my.ha.net:8123/local/esphome/firmware.bin
 | |
| 
 | |
|         - logger.log: "This message should be not displayed (reboot)"
 | |
| 
 | |
| update:
 | |
|   - platform: http_request
 | |
|     name: OTA Update
 | |
|     id: ota_update
 | |
|     source: http://my.ha.net:8123/local/esphome/manifest.json
 | |
|     on_update_available:
 | |
|       - logger.log: "A new update is available"
 |