diff --git a/src/defines.h b/src/defines.h index 62f2cc42..68b9c80a 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 5 -#define VERSION_PATCH 44 +#define VERSION_PATCH 45 //------------------------------------- typedef struct { diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index 89d8633b..4862d77e 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -47,7 +47,7 @@ class PubMqtt { mSunrise = sunrise; mSunset = sunset; - snprintf(mLwtTopic, MQTT_TOPIC_LEN + 7, "%s/status", mCfgMqtt->topic); + snprintf(mLwtTopic, MQTT_TOPIC_LEN + 5, "%s/mqtt", mCfgMqtt->topic); #if defined(ESP8266) mHWifiCon = WiFi.onStationModeGotIP(std::bind(&PubMqtt::onWifiConnect, this, std::placeholders::_1)); @@ -358,10 +358,10 @@ class PubMqtt { } snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/available_text", iv->config->name); snprintf(val, 40, "%s%s%s%s", - (status == MQTT_STATUS_NOT_AVAIL_NOT_PROD) ? "not yet " : "", + (status == MQTT_STATUS_NOT_AVAIL_NOT_PROD) ? "not " : "", "available and ", (status == MQTT_STATUS_AVAIL_NOT_PROD) ? "not " : "", - (status == MQTT_STATUS_NOT_AVAIL_NOT_PROD) ? "" : "producing" + "producing" ); publish(topic, val, true); @@ -377,9 +377,19 @@ class PubMqtt { // data if(iv->isAvailable(*mUtcTimestamp, rec)) { for (uint8_t i = 0; i < rec->length; i++) { + bool retained = false; + if (mSendList.front() == RealTimeRunData_Debug) { + switch (rec->assign[i].fieldId) { + case FLD_YT: + case FLD_YD: + retained = true; + break; + } + } + snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/ch%d/%s", iv->config->name, rec->assign[i].ch, fields[rec->assign[i].fieldId]); snprintf(val, 40, "%.3f", iv->getValue(i, rec)); - publish(topic, val); + publish(topic, val, retained); // calculate total values for RealTimeRunData_Debug if (mSendList.front() == RealTimeRunData_Debug) { @@ -428,7 +438,7 @@ class PubMqtt { } snprintf(topic, 32 + MAX_NAME_LENGTH, "total/%s", fields[fieldId]); snprintf(val, 40, "%.3f", total[i]); - publish(topic, val); + publish(topic, val, true); } } } @@ -449,9 +459,9 @@ class PubMqtt { subscriptionCb mSubscriptionCb; // last will topic and payload must be available trough lifetime of 'espMqttClient' - char mLwtTopic[MQTT_TOPIC_LEN+7]; - const char* mLwtOnline = "online"; - const char* mLwtOffline = "offline"; + char mLwtTopic[MQTT_TOPIC_LEN+5]; + const char* mLwtOnline = "connected"; + const char* mLwtOffline = "not connected"; const char *mDevName, *mVersion; }; diff --git a/src/utils/sun.h b/src/utils/sun.h index 476ad0ff..1036f9ec 100644 --- a/src/utils/sun.h +++ b/src/utils/sun.h @@ -11,7 +11,7 @@ namespace ah { // Source: https://en.wikipedia.org/wiki/Sunrise_equation#Complete_calculation_on_Earth // Julian day since 1.1.2000 12:00 + correction 69.12s - double n_JulianDay = (utcTs + offset) / 86400 - 10957.0 + 0.0008; + double n_JulianDay = (utcTs + offset) / 86400 - 10957.0; // Mean solar time double J = n_JulianDay - lon / 360; // Solar mean anomaly @@ -25,7 +25,7 @@ namespace ah { // Declination of the sun double delta = ASIN(SIN(lambda) * SIN(23.44)); // Hour angle - double omega = ACOS(SIN(-0.83) - SIN(lat) * SIN(delta) / COS(lat) * COS(delta)); + double omega = ACOS((SIN(-0.83) - SIN(lat) * SIN(delta) / COS(lat) * COS(delta))); // Calculate sunrise and sunset double Jrise = Jtransit - omega / 360; double Jset = Jtransit + omega / 360; diff --git a/src/web/html/serial.html b/src/web/html/serial.html index c7e3dd8b..ccbd1156 100644 --- a/src/web/html/serial.html +++ b/src/web/html/serial.html @@ -120,7 +120,7 @@ // set time offset for serial console var obj = new Object(); obj.cmd = "serial_utc_offset"; - obj.ts = new Date().getTimezoneOffset() * -60; + obj.val = new Date().getTimezoneOffset() * -60; getAjax("/api/setup", null, "POST", JSON.stringify(obj)); }