Edit the-saloon.yaml
This commit is contained in:
parent
bc0b03bc46
commit
654895d075
@ -69,11 +69,20 @@ display:
|
||||
rotation: 270
|
||||
update_interval: 5s
|
||||
lambda: |-
|
||||
it.printf(10, 10, id(roboto), "NAS RAM");
|
||||
if (id(nas_ram_free).has_state()) {
|
||||
it.printf(10, 60, id(roboto_big), "%.0f MB", id(nas_ram_free).state);
|
||||
} else {
|
||||
it.printf(10, 60, id(roboto), "waiting...");
|
||||
// RAM
|
||||
it.printf(10, 8, id(roboto), "RAM libre");
|
||||
if (id(nas_ram_free).has_state())
|
||||
it.printf(10, 36, id(roboto_big), "%.0f MB", id(nas_ram_free).state);
|
||||
|
||||
// Disk bar
|
||||
it.printf(10, 105, id(roboto), "Disque");
|
||||
if (id(nas_disk_percent).has_state()) {
|
||||
float pct = id(nas_disk_percent).state;
|
||||
int x = 10, y = 135, w = 300, h = 22;
|
||||
Color c = pct > 90 ? Color(255, 0, 0) : (pct > 75 ? Color(255, 165, 0) : Color(0, 200, 0));
|
||||
it.rectangle(x, y, w, h, Color(255, 255, 255));
|
||||
it.filled_rectangle(x + 2, y + 2, (int)((w - 4) * pct / 100.0f), h - 4, c);
|
||||
it.printf(w - 30, 105, id(roboto), TextAlign::TOP_RIGHT, "%.0f%%", pct);
|
||||
}
|
||||
|
||||
font:
|
||||
@ -95,6 +104,12 @@ sensor:
|
||||
unit_of_measurement: "MB"
|
||||
accuracy_decimals: 0
|
||||
state_class: measurement
|
||||
- platform: template
|
||||
id: nas_disk_percent
|
||||
name: "NAS disque utilisé"
|
||||
unit_of_measurement: "%"
|
||||
accuracy_decimals: 1
|
||||
state_class: measurement
|
||||
|
||||
interval:
|
||||
- interval: 60s
|
||||
@ -108,4 +123,18 @@ interval:
|
||||
json::parse_json(body, [](JsonObject root) -> bool {
|
||||
id(nas_ram_free).publish_state(root["available"].as<float>() / 1048576.0f);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
- http_request.get:
|
||||
url: http://192.168.1.50: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"] | "", "/data") == 0) { // your mount point
|
||||
id(nas_disk_percent).publish_state(fs["percent"].as<float>());
|
||||
break;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user