From 1f880e0cde32f322e0508c6d3e01e6912f84101a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Sat, 31 Mar 2018 12:34:39 +0200 Subject: [PATCH] Codacy changes --- code/espurna/homeassistant.ino | 8 ++++---- code/espurna/system.ino | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) 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) {