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