diff --git a/code/espurna/homeassistant.ino b/code/espurna/homeassistant.ino index 14be576b..12b16288 100644 --- a/code/espurna/homeassistant.ino +++ b/code/espurna/homeassistant.ino @@ -23,8 +23,8 @@ void _haSendMagnitude(unsigned char i, JsonObject& config) { unsigned char type = magnitudeType(i); config["name"] = getSetting("hostname") + String(" ") + magnitudeTopic(type); - config["platform"] = "mqtt"; - config["device_class"] = "sensor"; + config.set("platform", "mqtt"); + config.set("device_class", "sensor"); config["state_topic"] = mqttTopic(magnitudeTopicIndex(i).c_str(), false); config["unit_of_measurement"] = String("\"") + magnitudeUnits(type) + String("\""); @@ -67,8 +67,8 @@ void _haSendSwitch(unsigned char i, JsonObject& config) { name += String(" #") + String(i); } - config["name"] = name; - config["platform"] = "mqtt"; + config.set("name", name); + config.set("platform", "mqtt"); if (relayCount()) { config["state_topic"] = mqttTopic(MQTT_TOPIC_RELAY, i, false); diff --git a/code/espurna/system.ino b/code/espurna/system.ino index 46b5fa71..48cf723e 100644 --- a/code/espurna/system.ino +++ b/code/espurna/system.ino @@ -105,12 +105,13 @@ void systemLoop() { static unsigned long last_loadcheck = 0; static unsigned long load_counter_temp = 0; - static unsigned long load_counter = 0; - static unsigned long load_counter_max = 1; load_counter_temp++; if (millis() - last_loadcheck > LOADAVG_INTERVAL) { + static unsigned long load_counter = 0; + static unsigned long load_counter_max = 1; + load_counter = load_counter_temp; load_counter_temp = 0; if (load_counter > load_counter_max) {