Browse Source

Single quote % units only in ha.config (#1227)

ota
Xose Pérez 6 years ago
parent
commit
acf68ac5c8
1 changed files with 9 additions and 4 deletions
  1. +9
    -4
      code/espurna/homeassistant.ino

+ 9
- 4
code/espurna/homeassistant.ino View File

@ -163,7 +163,7 @@ String _haGetConfig() {
JsonObject& config = jsonBuffer.createObject();
_haSendSwitch(i, config);
output += type + ":\n";
output += "\n" + type + ":\n";
bool first = true;
for (auto kv : config) {
if (first) {
@ -174,7 +174,6 @@ String _haGetConfig() {
}
output += kv.key + String(": ") + kv.value.as<String>() + String("\n");
}
output += "\n";
jsonBuffer.clear();
@ -188,7 +187,7 @@ String _haGetConfig() {
JsonObject& config = jsonBuffer.createObject();
_haSendMagnitude(i, config);
output += "sensor:\n";
output += "\nsensor:\n";
bool first = true;
for (auto kv : config) {
if (first) {
@ -197,7 +196,9 @@ String _haGetConfig() {
} else {
output += " ";
}
output += kv.key + String(": ") + kv.value.as<String>() + String("\n");
String value = kv.value.as<String>();
value.replace("%", "'%'");
output += kv.key + String(": ") + value + String("\n");
}
output += "\n";
@ -265,10 +266,12 @@ void _haWebSocketOnAction(uint32_t client_id, const char * action, JsonObject& d
#if TERMINAL_SUPPORT
void _haInitCommands() {
settingsRegisterCommand(F("HA.CONFIG"), [](Embedis* e) {
DEBUG_MSG(_haGetConfig().c_str());
DEBUG_MSG_P(PSTR("+OK\n"));
});
settingsRegisterCommand(F("HA.SEND"), [](Embedis* e) {
setSetting("haEnabled", "1");
_haConfigure();
@ -277,6 +280,7 @@ void _haInitCommands() {
#endif
DEBUG_MSG_P(PSTR("+OK\n"));
});
settingsRegisterCommand(F("HA.CLEAR"), [](Embedis* e) {
setSetting("haEnabled", "0");
_haConfigure();
@ -285,6 +289,7 @@ void _haInitCommands() {
#endif
DEBUG_MSG_P(PSTR("+OK\n"));
});
}
#endif


Loading…
Cancel
Save