From 7e95dddb413d97ff4934c0cbcbe8ff138f16dbf1 Mon Sep 17 00:00:00 2001 From: neri Date: Sat, 29 Jun 2024 00:38:18 +0200 Subject: [PATCH] feat: update ota config to new format --- mlock-common.yaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mlock-common.yaml b/mlock-common.yaml index 385266a..51f356a 100644 --- a/mlock-common.yaml +++ b/mlock-common.yaml @@ -37,7 +37,8 @@ api: key: $api_enckey ota: - password: $ota_password + - platform: esphome + password: $ota_password wifi: ssid: $wifi_ssid @@ -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,7 +113,6 @@ 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: @@ -119,8 +120,9 @@ rc522_spi: lambda: 'return 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: