Edit the-saloon.yaml
This commit is contained in:
parent
ba68bce64d
commit
dc8a09c8f0
@ -76,12 +76,13 @@ display:
|
||||
it.printf(10, 10, id(roboto), "%.1f GB", id(nas_ram_free).state);
|
||||
|
||||
// Disk bar
|
||||
it.printf(10, 105, id(roboto), "HDD");
|
||||
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.filled_rectangle(x + 2, y + 2, (int)((w - 4) * pct / 100.0f), h - 4, c);
|
||||
it.printf(10, 105, id(roboto), "%.0f%%", pct);
|
||||
it.printf(10, 105, id(roboto), "%.1f%%", pct);
|
||||
}
|
||||
|
||||
script:
|
||||
@ -138,6 +139,17 @@ sensor:
|
||||
unit_of_measurement: "%"
|
||||
accuracy_decimals: 1
|
||||
state_class: measurement
|
||||
- platform: template
|
||||
id: lights_on_count
|
||||
name: "Hue lights on"
|
||||
accuracy_decimals: 0
|
||||
update_interval: never
|
||||
|
||||
text_sensor:
|
||||
- platform: template
|
||||
id: lights_str
|
||||
name: "Hue lights state"
|
||||
update_interval: never
|
||||
|
||||
interval:
|
||||
- interval: 60s
|
||||
@ -165,4 +177,29 @@ interval:
|
||||
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
|
||||
on_response:
|
||||
then:
|
||||
- lambda: |-
|
||||
if (response->status_code != 200) {
|
||||
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";
|
||||
}
|
||||
id(lights_on_count).publish_state(count);
|
||||
id(lights_str).publish_state(s);
|
||||
return true;
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user