Edit the-saloon.yaml

This commit is contained in:
ESPHome Device Builder 2026-10-23 12:15:31 +02:00
parent 9932b3ea39
commit 53d4a9dd14

View File

@ -157,7 +157,37 @@ text_sensor:
name: "Hue lights state"
update_interval: never
interval:
- interval: 6s
then:
- 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 ";
}
id(lights_on_count).publish_state(count);
id(lights_str).publish_state(s);
return true;
});
- interval: 60s
then:
- http_request.get:
@ -184,30 +214,4 @@ interval:
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 ";
}
id(lights_on_count).publish_state(count);
id(lights_str).publish_state(s);
return true;
});