|
|
@ -148,7 +148,7 @@ void _haSendSwitches() { |
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void _haDumpConfig(std::function<void(String&)> printer) { |
|
|
|
void _haDumpConfig(std::function<void(String&)> printer, bool wrapJson = false) { |
|
|
|
|
|
|
|
#if (LIGHT_PROVIDER != LIGHT_PROVIDER_NONE) || (defined(ITEAD_SLAMPHER))
|
|
|
|
String type = String("light"); |
|
|
@ -165,6 +165,10 @@ void _haDumpConfig(std::function<void(String&)> printer) { |
|
|
|
String output; |
|
|
|
output.reserve(config.measureLength() + 32); |
|
|
|
|
|
|
|
if (wrapJson) { |
|
|
|
output += "{\"haConfig\": \""; |
|
|
|
} |
|
|
|
|
|
|
|
output += "\n\n" + type + ":\n"; |
|
|
|
bool first = true; |
|
|
|
|
|
|
@ -182,6 +186,10 @@ void _haDumpConfig(std::function<void(String&)> printer) { |
|
|
|
} |
|
|
|
output += " "; |
|
|
|
|
|
|
|
if (wrapJson) { |
|
|
|
output += "\"}"; |
|
|
|
} |
|
|
|
|
|
|
|
jsonBuffer.clear(); |
|
|
|
|
|
|
|
printer(output); |
|
|
@ -199,6 +207,10 @@ void _haDumpConfig(std::function<void(String&)> printer) { |
|
|
|
String output; |
|
|
|
output.reserve(config.measureLength() + 32); |
|
|
|
|
|
|
|
if (wrapJson) { |
|
|
|
output += "{\"haConfig\": \""; |
|
|
|
} |
|
|
|
|
|
|
|
output += "\n\nsensor:\n"; |
|
|
|
bool first = true; |
|
|
|
|
|
|
@ -218,6 +230,10 @@ void _haDumpConfig(std::function<void(String&)> printer) { |
|
|
|
} |
|
|
|
output += " "; |
|
|
|
|
|
|
|
if (wrapJson) { |
|
|
|
output += "\"}"; |
|
|
|
} |
|
|
|
|
|
|
|
jsonBuffer.clear(); |
|
|
|
|
|
|
|
printer(output); |
|
|
@ -324,12 +340,9 @@ void _haLoop() { |
|
|
|
|
|
|
|
// TODO check wsConnected after each "printer" call?
|
|
|
|
_haDumpConfig([client_id](String& output) { |
|
|
|
output.replace(" ", " "); |
|
|
|
output.replace("\n", "<br />"); |
|
|
|
output = String("{\"haConfig\": \"") + output + String("\"}"); |
|
|
|
wsSend(client_id, output.c_str()); |
|
|
|
yield(); |
|
|
|
}); |
|
|
|
}, true); |
|
|
|
} |
|
|
|
#endif
|
|
|
|
|
|
|
|