esphome/tests/components/http_request/common.yaml
Clyde Stubbs ee3ee3a63b
Some checks failed
CI / Create common environment (push) Has been cancelled
YAML lint / yamllint (push) Has been cancelled
CI / Check black (push) Has been cancelled
CI / Check flake8 (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Check pyupgrade (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (push) Has been cancelled
CI / Check clang-format (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / list-components (push) Has been cancelled
CI / Component test (push) Has been cancelled
CI / Split components for testing into 20 groups maximum (push) Has been cancelled
CI / Test split components (push) Has been cancelled
CI / CI Status (push) Has been cancelled
[http_request] Implement on_error trigger for requests (#7696)
2024-10-30 14:10:58 +13:00

83 lines
2 KiB
YAML

substitutions:
verify_ssl: "true"
wifi:
ssid: MySSID
password: password1
esphome:
on_boot:
then:
- http_request.get:
url: https://esphome.io
headers:
Content-Type: application/json
on_error:
logger.log: "Request failed"
on_response:
then:
- logger.log:
format: "Response status: %d, Duration: %lu ms"
args:
- response->status_code
- (long) response->duration_ms
- http_request.post:
url: https://esphome.io
headers:
Content-Type: application/json
json:
key: value
- http_request.send:
method: PUT
url: https://esphome.io
headers:
Content-Type: application/json
body: "Some data"
http_request:
useragent: esphome/tagreader
timeout: 10s
verify_ssl: ${verify_ssl}
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