Edit the-saloon.yaml
This commit is contained in:
parent
f13479ca5b
commit
4b0f4e6d6a
@ -156,52 +156,53 @@ interval:
|
||||
- interval: 60s
|
||||
then:
|
||||
- http_request.get:
|
||||
url: http://192.168.1.19:61208/api/4/mem # your NAS IP
|
||||
url: http://192.168.1.19:61208/api/4/mem
|
||||
capture_response: true
|
||||
on_response:
|
||||
then:
|
||||
- lambda: |-
|
||||
json::parse_json(body, [](JsonObject root) -> bool {
|
||||
id(nas_ram_free).publish_state(root["available"].as<float>() / 1073741824.0f);
|
||||
return true;
|
||||
});
|
||||
- then:
|
||||
- lambda: |
|
||||
json::parse_json(body, [](JsonObject root) -> bool {
|
||||
id(nas_ram_free).publish_state(root["available"].as<float>() / 1073741824.0f);
|
||||
return true;
|
||||
});
|
||||
- http_request.get:
|
||||
url: http://192.168.1.19:61208/api/4/fs # your NAS IP
|
||||
url: http://192.168.1.19:61208/api/4/fs
|
||||
capture_response: true
|
||||
on_response:
|
||||
then:
|
||||
- lambda: |-
|
||||
JsonDocument doc;
|
||||
if (deserializeJson(doc, body)) return;
|
||||
for (JsonObject fs : doc.as<JsonArray>()) {
|
||||
if (strcmp(fs["mnt_point"] | "", "/etc/hosts") == 0) { // your mount point
|
||||
id(nas_disk_percent).publish_state(fs["percent"].as<float>());
|
||||
break;
|
||||
- then:
|
||||
- lambda: |
|
||||
JsonDocument doc;
|
||||
if (deserializeJson(doc, body)) return;
|
||||
for (JsonObject fs : doc.as<JsonArray>()) {
|
||||
if (strcmp(fs["mnt_point"] | "", "/etc/hosts") == 0) { // your mount point
|
||||
id(nas_disk_percent).publish_state(fs["percent"].as<float>());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
- http_request.get:
|
||||
url: http://192.168.1.10/api/ZhVM43RTDHhmyU9Up08n0ebbCpD6XJ7RtSlcevw1/lights
|
||||
capture_response: true
|
||||
max_response_buffer_size: 16kB
|
||||
on_response:
|
||||
then:
|
||||
- lambda: |-
|
||||
if (response->status_code != 200) {
|
||||
ESP_LOGD("http_response", "Failed connection to remote sensor. Status code: %d", response->status_code);
|
||||
id(lights_str).publish_state("ERR");
|
||||
return;
|
||||
}
|
||||
json::parse_json(body, [](JsonObject root) -> bool {
|
||||
int count = 0;
|
||||
std::string s;
|
||||
for (JsonPair kv : root) {
|
||||
JsonObject st = kv.value()["state"];
|
||||
bool on = st["on"] | false;
|
||||
bool reachable = st["reachable"] | false;
|
||||
bool lit = on && reachable;
|
||||
if (lit) count++;
|
||||
s += lit ? "\u25CF" : "\u25CB";
|
||||
- then:
|
||||
- lambda: |
|
||||
if (response->status_code != 200) {
|
||||
ESP_LOGD("http_response", "Failed connection to remote sensor. Status code: %d", response->status_code);
|
||||
id(lights_str).publish_state("ERR");
|
||||
return;
|
||||
}
|
||||
id(lights_on_count).publish_state(count);
|
||||
id(lights_str).publish_state(s);
|
||||
return true;
|
||||
});
|
||||
json::parse_json(body, [](JsonObject root) -> bool {
|
||||
int count = 0;
|
||||
std::string s;
|
||||
for (JsonPair kv : root) {
|
||||
JsonObject st = kv.value()["state"];
|
||||
bool on = st["on"] | false;
|
||||
bool reachable = st["reachable"] | false;
|
||||
bool lit = on && reachable;
|
||||
if (lit) count++;
|
||||
s += lit ? "\u25CF" : "\u25CB";
|
||||
}
|
||||
id(lights_on_count).publish_state(count);
|
||||
id(lights_str).publish_state(s);
|
||||
return true;
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user