feat: update ota config to new format

This commit is contained in:
neri 2024-06-29 00:38:18 +02:00
parent 2eff076d5b
commit 709e0529aa
1 changed files with 9 additions and 7 deletions

View File

@ -37,6 +37,7 @@ api:
key: $api_enckey
ota:
- platform: esphome
password: $ota_password
wifi:
@ -65,6 +66,7 @@ http_request:
useragent: esphome
timeout: 2s
id: http_request_data
verify_ssl: false
globals:
- id: my_token
@ -97,13 +99,13 @@ rc522_spi:
json:
role_id: $vault_role_id
secret_id: $vault_secret_id
verify_ssl: false
on_response:
# fetch token from response, store into my_token
then:
- lambda: |-
json::parse_json(id(http_request_data).get_string(), [](JsonObject root) {
json::parse_json(body, [](JsonObject root) -> bool {
id(my_token) = (const char*) root["auth"]["client_token"];
return true;
});
# use the token to get json of scanned tag from vault
- http_request.get:
@ -111,16 +113,16 @@ rc522_spi:
return ((std::string) "https://vault.ctdo.de/v1/maschinenlock/" + id(my_tag));
headers:
X-Vault-Token: !lambda return id(my_token).c_str();
verify_ssl: false
on_response:
then:
- if:
condition:
lambda: 'return status_code == 200;'
lambda: 'return response->status_code == 200;'
then: # when found, check if machine is allowed, turn on output or blink LED red
- lambda: |-
json::parse_json(id(http_request_data).get_string(), [](JsonObject root) {
json::parse_json(body, [](JsonObject root) -> bool {
id(may_switch_output) = root["data"]["mlock-$name_of_board"];
return true;
});
- if:
condition: