chore: revert mlock-common to esphome 2024.5.x
This commit is contained in:
parent
f2b95e3eb0
commit
0bf20c32c4
|
@ -37,8 +37,7 @@ api:
|
|||
key: $api_enckey
|
||||
|
||||
ota:
|
||||
- platform: esphome
|
||||
password: $ota_password
|
||||
password: $ota_password
|
||||
|
||||
wifi:
|
||||
ssid: $wifi_ssid
|
||||
|
@ -66,7 +65,6 @@ http_request:
|
|||
useragent: esphome
|
||||
timeout: 2s
|
||||
id: http_request_data
|
||||
verify_ssl: false
|
||||
|
||||
globals:
|
||||
- id: my_token
|
||||
|
@ -97,6 +95,7 @@ rc522_spi:
|
|||
# login to vault with role_id to fetch short lived token
|
||||
- http_request.post:
|
||||
url: https://vault.ctdo.de/v1/auth/approle/login
|
||||
verify_ssl: false
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
json:
|
||||
|
@ -106,26 +105,25 @@ rc522_spi:
|
|||
# fetch token from response, store into my_token
|
||||
then:
|
||||
- lambda: |-
|
||||
json::parse_json(body, [](JsonObject root) -> bool {
|
||||
json::parse_json(id(http_request_data).get_string(), [](JsonObject root) {
|
||||
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:
|
||||
url: !lambda |-
|
||||
return ((std::string) "https://vault.ctdo.de/v1/maschinenlock/" + id(my_tag));
|
||||
verify_ssl: false
|
||||
headers:
|
||||
X-Vault-Token: !lambda return id(my_token).c_str();
|
||||
on_response:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return response->status_code == 200;'
|
||||
lambda: 'return status_code == 200;'
|
||||
then: # when found, check if machine is allowed, turn on output or blink LED red
|
||||
- lambda: |-
|
||||
json::parse_json(body, [](JsonObject root) -> bool {
|
||||
json::parse_json(id(http_request_data).get_string(), [](JsonObject root) {
|
||||
id(may_switch_output) = root["data"]["mlock-$name_of_board"];
|
||||
return true;
|
||||
});
|
||||
- if:
|
||||
condition:
|
||||
|
|
Loading…
Reference in New Issue