mirror of https://github.com/arendst/Tasmota.git
v4.0.1
4.0.1 20170305 * Fix char default sizes and set MESSZ to 360 (#143) * Fix SerialLog setting status * Disable syslog when emulation is active * Add DS18B20 web page display refresh
This commit is contained in:
parent
acb5252b54
commit
47d711b1b2
|
@ -1,7 +1,7 @@
|
||||||
## Sonoff-Tasmota
|
## Sonoff-Tasmota
|
||||||
Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE.
|
Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE.
|
||||||
|
|
||||||
Current version is **4.0.0** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
|
Current version is **4.0.1** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
|
||||||
|
|
||||||
- This version provides all (Sonoff) modules in one file and starts up with Sonoff Basic.
|
- This version provides all (Sonoff) modules in one file and starts up with Sonoff Basic.
|
||||||
- Once uploaded select module using the configuration webpage or the commands ```Modules``` and ```Module```.
|
- Once uploaded select module using the configuration webpage or the commands ```Modules``` and ```Module```.
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,4 +1,10 @@
|
||||||
/* 4.0.0 20170303
|
/* 4.0.1 20170305
|
||||||
|
* Fix char default sizes and set MESSZ to 360 (#143)
|
||||||
|
* Fix SerialLog setting status
|
||||||
|
* Disable syslog when emulation is active
|
||||||
|
* Add DS18B20 web page display refresh
|
||||||
|
*
|
||||||
|
* 4.0.0 20170303
|
||||||
* Add define to remove config migration code for versions below 3.0 (See Wiki-Upgrade-Migration path)
|
* Add define to remove config migration code for versions below 3.0 (See Wiki-Upgrade-Migration path)
|
||||||
* Free memory by switching from String to char[]
|
* Free memory by switching from String to char[]
|
||||||
* Raised Sonoff Led PWM frequency from 200Hz to 432Hz in search of stability (hardware watchdog timeouts) (#122)
|
* Raised Sonoff Led PWM frequency from 200Hz to 432Hz in search of stability (hardware watchdog timeouts) (#122)
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
|
|
||||||
//#define ALLOW_MIGRATE_TO_V3
|
//#define ALLOW_MIGRATE_TO_V3
|
||||||
#ifdef ALLOW_MIGRATE_TO_V3
|
#ifdef ALLOW_MIGRATE_TO_V3
|
||||||
#define VERSION 0x03091700 // 3.9.23
|
#define VERSION 0x03091800 // 3.9.24
|
||||||
#else
|
#else
|
||||||
#define VERSION 0x04000000 // 4.0.0
|
#define VERSION 0x04000100 // 4.0.1
|
||||||
#endif // ALLOW_MIGRATE_TO_V3
|
#endif // ALLOW_MIGRATE_TO_V3
|
||||||
|
|
||||||
enum log_t {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL};
|
enum log_t {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL};
|
||||||
|
@ -36,8 +36,6 @@ enum emul_t {EMUL_NONE, EMUL_WEMO, EMUL_HUE, EMUL_MAX};
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
//#define USE_SPIFFS // Switch persistent configuration from flash to spiffs (+24k code, +0.6k mem)
|
//#define USE_SPIFFS // Switch persistent configuration from flash to spiffs (+24k code, +0.6k mem)
|
||||||
//#define BE_MINIMAL // Compile a minimal version if upgrade memory gets tight (-45k code, -2k mem)
|
|
||||||
// To be used as step 1. Next step is compile and use desired version
|
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* No user configurable items below
|
* No user configurable items below
|
||||||
|
@ -52,9 +50,9 @@ enum emul_t {EMUL_NONE, EMUL_WEMO, EMUL_HUE, EMUL_MAX};
|
||||||
//#define DEBUG_THEO // Add debug code
|
//#define DEBUG_THEO // Add debug code
|
||||||
|
|
||||||
#ifdef BE_MINIMAL
|
#ifdef BE_MINIMAL
|
||||||
//#ifdef USE_MQTT_TLS
|
#ifdef USE_MQTT_TLS
|
||||||
//#undef USE_MQTT_TLS // Disable TLS support won't work as the MQTTHost is not set
|
#undef USE_MQTT_TLS // Disable TLS support won't work as the MQTTHost is not set
|
||||||
//#endif
|
#endif
|
||||||
#ifdef USE_DISCOVERY
|
#ifdef USE_DISCOVERY
|
||||||
#undef USE_DISCOVERY // Disable Discovery services for both MQTT and web server
|
#undef USE_DISCOVERY // Disable Discovery services for both MQTT and web server
|
||||||
#endif
|
#endif
|
||||||
|
@ -145,10 +143,10 @@ enum butt_t {PRESSED, NOT_PRESSED};
|
||||||
#include "support.h" // Global support
|
#include "support.h" // Global support
|
||||||
#include <PubSubClient.h> // MQTT
|
#include <PubSubClient.h> // MQTT
|
||||||
|
|
||||||
#define MESSZ 352 // Max number of characters in JSON message string
|
#define MESSZ 360 // Max number of characters in JSON message string (4 x DS18x20 sensors)
|
||||||
#if (MQTT_MAX_PACKET_SIZE -TOPSZ -60 -40) < MESSZ // If the max message size is too small, throw an error at compile time
|
#if (MQTT_MAX_PACKET_SIZE -TOPSZ -7) < MESSZ // If the max message size is too small, throw an error at compile time
|
||||||
// 60 bytes for the IPv4 TCP header, 40 bytes to keep the original 400/240 headroom
|
// See pubsubclient.c line 359
|
||||||
#error "MQTT_MAX_PACKET_SIZE is too small in libraries/PubSubClient/src/PubSubClient.h, increase it to at least 512"
|
#error "MQTT_MAX_PACKET_SIZE is too small in libraries/PubSubClient/src/PubSubClient.h, increase it to at least 427"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Ticker.h> // RTC
|
#include <Ticker.h> // RTC
|
||||||
|
@ -415,7 +413,7 @@ void json2legacy(char* stopic, char* svalue)
|
||||||
|
|
||||||
void mqtt_publish_sec(const char* topic, const char* data, boolean retained)
|
void mqtt_publish_sec(const char* topic, const char* data, boolean retained)
|
||||||
{
|
{
|
||||||
char log[TOPSZ+MESSZ];
|
char log[TOPSZ + MESSZ];
|
||||||
|
|
||||||
if (sysCfg.mqtt_enabled) {
|
if (sysCfg.mqtt_enabled) {
|
||||||
if (mqttClient.publish(topic, data, retained)) {
|
if (mqttClient.publish(topic, data, retained)) {
|
||||||
|
@ -459,7 +457,7 @@ void mqtt_publish_topic_P(uint8_t prefix, const char* subtopic, const char* data
|
||||||
|
|
||||||
void mqtt_publishPowerState(byte device)
|
void mqtt_publishPowerState(byte device)
|
||||||
{
|
{
|
||||||
char stopic[TOPSZ], svalue[MESSZ], sdevice[10];
|
char stopic[TOPSZ], sdevice[10], svalue[64]; // was MESSZ
|
||||||
|
|
||||||
if ((device < 1) || (device > Maxdevice)) device = 1;
|
if ((device < 1) || (device > Maxdevice)) device = 1;
|
||||||
snprintf_P(sdevice, sizeof(sdevice), PSTR("%d"), device);
|
snprintf_P(sdevice, sizeof(sdevice), PSTR("%d"), device);
|
||||||
|
@ -473,7 +471,7 @@ void mqtt_publishPowerState(byte device)
|
||||||
|
|
||||||
void mqtt_publishPowerBlinkState(byte device)
|
void mqtt_publishPowerBlinkState(byte device)
|
||||||
{
|
{
|
||||||
char svalue[MESSZ], sdevice[10];
|
char sdevice[10], svalue[64]; // was MESSZ
|
||||||
|
|
||||||
if ((device < 1) || (device > Maxdevice)) device = 1;
|
if ((device < 1) || (device > Maxdevice)) device = 1;
|
||||||
snprintf_P(sdevice, sizeof(sdevice), PSTR("%d"), device);
|
snprintf_P(sdevice, sizeof(sdevice), PSTR("%d"), device);
|
||||||
|
@ -484,7 +482,7 @@ void mqtt_publishPowerBlinkState(byte device)
|
||||||
|
|
||||||
void mqtt_connected()
|
void mqtt_connected()
|
||||||
{
|
{
|
||||||
char stopic[TOPSZ], svalue[MESSZ];
|
char stopic[TOPSZ], svalue[128]; // was MESSZ
|
||||||
|
|
||||||
if (sysCfg.mqtt_enabled) {
|
if (sysCfg.mqtt_enabled) {
|
||||||
|
|
||||||
|
@ -596,7 +594,6 @@ void mqtt_reconnect()
|
||||||
void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
char svalue[MESSZ];
|
|
||||||
|
|
||||||
if (!strcmp(SUB_PREFIX,PUB_PREFIX)) {
|
if (!strcmp(SUB_PREFIX,PUB_PREFIX)) {
|
||||||
str = strstr(topic,SUB_PREFIX);
|
str = strstr(topic,SUB_PREFIX);
|
||||||
|
@ -606,10 +603,10 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t i = 0, grpflg = 0, index;
|
char topicBuf[TOPSZ], dataBuf[data_len+1], dataBufUc[128], svalue[MESSZ];
|
||||||
char topicBuf[TOPSZ], dataBuf[data_len+1], dataBufUc[MESSZ];
|
|
||||||
char *p, *mtopic = NULL, *type = NULL;
|
char *p, *mtopic = NULL, *type = NULL;
|
||||||
char stemp1[TOPSZ], stemp2[10];
|
char stemp1[TOPSZ], stemp2[10];
|
||||||
|
uint16_t i = 0, grpflg = 0, index;
|
||||||
|
|
||||||
strncpy(topicBuf, topic, sizeof(topicBuf));
|
strncpy(topicBuf, topic, sizeof(topicBuf));
|
||||||
memcpy(dataBuf, data, sizeof(dataBuf));
|
memcpy(dataBuf, data, sizeof(dataBuf));
|
||||||
|
@ -823,19 +820,16 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
||||||
sysCfg.seriallog_level = payload;
|
sysCfg.seriallog_level = payload;
|
||||||
seriallog_level = payload;
|
seriallog_level = payload;
|
||||||
seriallog_timer = 0;
|
seriallog_timer = 0;
|
||||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"SerialLog\":%d}"), sysCfg.syslog_level);
|
|
||||||
}
|
}
|
||||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"SerialLog\":\"%d (Setting %d)\"}"), seriallog_level, sysCfg.seriallog_level);
|
snprintf_P(svalue, sizeof(svalue), PSTR("{\"SerialLog\":\"%d (Active %d)\"}"), sysCfg.seriallog_level, seriallog_level);
|
||||||
}
|
}
|
||||||
else if (!strcmp(type,"SYSLOG")) {
|
else if (!strcmp(type,"SYSLOG")) {
|
||||||
if ((data_len > 0) && (payload >= LOG_LEVEL_NONE) && (payload <= LOG_LEVEL_ALL)) {
|
if ((data_len > 0) && (payload >= LOG_LEVEL_NONE) && (payload <= LOG_LEVEL_ALL)) {
|
||||||
sysCfg.syslog_level = payload;
|
sysCfg.syslog_level = payload;
|
||||||
syslog_level = payload;
|
syslog_level = (sysCfg.emulation) ? 0 : payload;
|
||||||
syslog_timer = 0;
|
syslog_timer = 0;
|
||||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"SysLog\":%d}"), sysCfg.syslog_level);
|
|
||||||
} else {
|
|
||||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"SysLog\":\"%d (Setting %d)\"}"), syslog_level, sysCfg.syslog_level);
|
|
||||||
}
|
}
|
||||||
|
snprintf_P(svalue, sizeof(svalue), PSTR("{\"SysLog\":\"%d (Active %d)\"}"), sysCfg.syslog_level, syslog_level);
|
||||||
}
|
}
|
||||||
else if (!strcmp(type,"LOGHOST")) {
|
else if (!strcmp(type,"LOGHOST")) {
|
||||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.syslog_host))) {
|
if ((data_len > 0) && (data_len < sizeof(sysCfg.syslog_host))) {
|
||||||
|
@ -1507,7 +1501,7 @@ void every_second()
|
||||||
if (syslog_timer) { // Restore syslog level
|
if (syslog_timer) { // Restore syslog level
|
||||||
syslog_timer--;
|
syslog_timer--;
|
||||||
if (!syslog_timer) {
|
if (!syslog_timer) {
|
||||||
syslog_level = sysCfg.syslog_level;
|
syslog_level = (sysCfg.emulation) ? 0 : sysCfg.syslog_level;
|
||||||
if (sysCfg.syslog_level) {
|
if (sysCfg.syslog_level) {
|
||||||
addLog_P(LOG_LEVEL_INFO, PSTR("SYSL: Syslog logging re-enabled")); // Might trigger disable again (on purpose)
|
addLog_P(LOG_LEVEL_INFO, PSTR("SYSL: Syslog logging re-enabled")); // Might trigger disable again (on purpose)
|
||||||
}
|
}
|
||||||
|
@ -1591,7 +1585,7 @@ void every_second()
|
||||||
void stateloop()
|
void stateloop()
|
||||||
{
|
{
|
||||||
uint8_t button = NOT_PRESSED, flag, switchflag, power_now;
|
uint8_t button = NOT_PRESSED, flag, switchflag, power_now;
|
||||||
char scmnd[20], log[LOGSZ], svalue[MESSZ];
|
char scmnd[20], log[LOGSZ], svalue[80]; // was MESSZ
|
||||||
|
|
||||||
timerxs = millis() + (1000 / STATES);
|
timerxs = millis() + (1000 / STATES);
|
||||||
state++;
|
state++;
|
||||||
|
@ -2038,7 +2032,10 @@ void setup()
|
||||||
savedatacounter = sysCfg.savedata;
|
savedatacounter = sysCfg.savedata;
|
||||||
seriallog_timer = SERIALLOG_TIMER;
|
seriallog_timer = SERIALLOG_TIMER;
|
||||||
seriallog_level = sysCfg.seriallog_level;
|
seriallog_level = sysCfg.seriallog_level;
|
||||||
syslog_level = sysCfg.syslog_level;
|
#ifndef USE_EMULATION
|
||||||
|
sysCfg.emulation = 0;
|
||||||
|
#endif // USE_EMULATION
|
||||||
|
syslog_level = (sysCfg.emulation) ? 0 : sysCfg.syslog_level;
|
||||||
sleep = sysCfg.sleep;
|
sleep = sysCfg.sleep;
|
||||||
|
|
||||||
GPIO_init();
|
GPIO_init();
|
||||||
|
|
|
@ -807,7 +807,7 @@ void rtc_init(rtcCallback cb)
|
||||||
|
|
||||||
void syslog(const char *message)
|
void syslog(const char *message)
|
||||||
{
|
{
|
||||||
char str[TOPSZ+MESSZ];
|
char str[TOPSZ + MESSZ];
|
||||||
|
|
||||||
if (portUDP.beginPacket(sysCfg.syslog_host, sysCfg.syslog_port)) {
|
if (portUDP.beginPacket(sysCfg.syslog_host, sysCfg.syslog_port)) {
|
||||||
snprintf_P(str, sizeof(str), PSTR("%s ESP-%s"), Hostname, message);
|
snprintf_P(str, sizeof(str), PSTR("%s ESP-%s"), Hostname, message);
|
||||||
|
@ -835,12 +835,13 @@ void addLog(byte loglevel, const char *line)
|
||||||
if (logidx > MAX_LOG_LINES -1) logidx = 0;
|
if (logidx > MAX_LOG_LINES -1) logidx = 0;
|
||||||
}
|
}
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
|
// if (sysCfg.emulation) return; // Disable syslog (UDP) when emulation using UDP is selected
|
||||||
if ((WiFi.status() == WL_CONNECTED) && (loglevel <= syslog_level)) syslog(line);
|
if ((WiFi.status() == WL_CONNECTED) && (loglevel <= syslog_level)) syslog(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addLog_P(byte loglevel, const char *formatP)
|
void addLog_P(byte loglevel, const char *formatP)
|
||||||
{
|
{
|
||||||
char mess[MESSZ];
|
char mess[LOGSZ]; // was MESSZ
|
||||||
|
|
||||||
snprintf_P(mess, sizeof(mess), formatP);
|
snprintf_P(mess, sizeof(mess), formatP);
|
||||||
addLog(loglevel, mess);
|
addLog(loglevel, mess);
|
||||||
|
|
|
@ -126,7 +126,7 @@
|
||||||
#define ENERGY_RESOLUTION 3 // Maximum number of decimals (0 - 5) showing energy usage in kWh
|
#define ENERGY_RESOLUTION 3 // Maximum number of decimals (0 - 5) showing energy usage in kWh
|
||||||
|
|
||||||
// -- Sensor code selection -----------------------
|
// -- Sensor code selection -----------------------
|
||||||
//#define USE_DS18x20 // Optional using OneWire library for multiple DS18B20 and/or DS18S20
|
//#define USE_DS18x20 // Optional using OneWire library for multiple DS18B20 and/or DS18S20 (+2k code)
|
||||||
|
|
||||||
#define USE_I2C // I2C using library wire (+10k code, 0.2k mem) - Disable by //
|
#define USE_I2C // I2C using library wire (+10k code, 0.2k mem) - Disable by //
|
||||||
#define USE_BH1750 // Add I2C code for BH1750 sensor
|
#define USE_BH1750 // Add I2C code for BH1750 sensor
|
||||||
|
@ -140,6 +140,15 @@
|
||||||
// #define USE_WS2812_DMA // DMA supports only GPIO03 (= Serial TXD) (+1k mem)
|
// #define USE_WS2812_DMA // DMA supports only GPIO03 (= Serial TXD) (+1k mem)
|
||||||
// When USE_WS2812_DMA is enabled expect Exceptions on Pow
|
// When USE_WS2812_DMA is enabled expect Exceptions on Pow
|
||||||
|
|
||||||
|
/*********************************************************************************************\
|
||||||
|
* Compile a minimal version if upgrade memory gets tight.
|
||||||
|
* To be used as step 1 during upgrade.
|
||||||
|
* Step 2 is re-compile with option BE_MINIMAL commented out.
|
||||||
|
* !!! Needed for next release of Arduino/ESP8266 (+22k code, +2k mem) !!!
|
||||||
|
\*********************************************************************************************/
|
||||||
|
|
||||||
|
//#define BE_MINIMAL // Minimal version if upgrade memory gets tight (-45k code, -2k mem)
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* No user configurable items below
|
* No user configurable items below
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
|
@ -423,11 +423,7 @@ void handleAjax2()
|
||||||
if (pin[GPIO_DSB] < 99) tpage += dsb_webPresent();
|
if (pin[GPIO_DSB] < 99) tpage += dsb_webPresent();
|
||||||
#endif // USE_DS18B20
|
#endif // USE_DS18B20
|
||||||
#ifdef USE_DS18x20
|
#ifdef USE_DS18x20
|
||||||
if (pin[GPIO_DSB] < 99) {
|
if (pin[GPIO_DSB] < 99) tpage += ds18x20_webPresent();
|
||||||
tpage += ds18x20_webPresent();
|
|
||||||
ds18x20_search(); // Check for changes in sensors number
|
|
||||||
ds18x20_convert(); // Start Conversion, takes up to one second
|
|
||||||
}
|
|
||||||
#endif // USE_DS18x20
|
#endif // USE_DS18x20
|
||||||
#ifdef USE_DHT
|
#ifdef USE_DHT
|
||||||
if (dht_type) tpage += dht_webPresent();
|
if (dht_type) tpage += dht_webPresent();
|
||||||
|
@ -874,7 +870,7 @@ void handleReset()
|
||||||
{
|
{
|
||||||
if (httpUser()) return;
|
if (httpUser()) return;
|
||||||
|
|
||||||
char svalue[MESSZ];
|
char svalue[16]; // was MESSZ
|
||||||
|
|
||||||
addLog_P(LOG_LEVEL_DEBUG, PSTR("HTTP: Reset parameters"));
|
addLog_P(LOG_LEVEL_DEBUG, PSTR("HTTP: Reset parameters"));
|
||||||
|
|
||||||
|
@ -923,7 +919,7 @@ void handleUpgrade()
|
||||||
void handleUpgradeStart()
|
void handleUpgradeStart()
|
||||||
{
|
{
|
||||||
if (httpUser()) return;
|
if (httpUser()) return;
|
||||||
char svalue[MESSZ];
|
char svalue[16]; // was MESSZ
|
||||||
|
|
||||||
addLog_P(LOG_LEVEL_DEBUG, PSTR("HTTP: Firmware upgrade start"));
|
addLog_P(LOG_LEVEL_DEBUG, PSTR("HTTP: Firmware upgrade start"));
|
||||||
WIFI_configCounter();
|
WIFI_configCounter();
|
||||||
|
@ -1097,7 +1093,7 @@ void handleUploadLoop()
|
||||||
void handleCmnd()
|
void handleCmnd()
|
||||||
{
|
{
|
||||||
if (httpUser()) return;
|
if (httpUser()) return;
|
||||||
char svalue[MESSZ];
|
char svalue[128]; // was MESSZ
|
||||||
|
|
||||||
addLog_P(LOG_LEVEL_DEBUG, PSTR("HTTP: Handle cmnd"));
|
addLog_P(LOG_LEVEL_DEBUG, PSTR("HTTP: Handle cmnd"));
|
||||||
|
|
||||||
|
@ -1166,7 +1162,7 @@ void handleConsole()
|
||||||
void handleAjax()
|
void handleAjax()
|
||||||
{
|
{
|
||||||
if (httpUser()) return;
|
if (httpUser()) return;
|
||||||
char svalue[MESSZ], log[LOGSZ];
|
char log[LOGSZ], svalue[128]; // was MESSZ
|
||||||
byte cflg = 1, counter = 99;
|
byte cflg = 1, counter = 99;
|
||||||
|
|
||||||
if (strlen(webServer->arg("c1").c_str())) {
|
if (strlen(webServer->arg("c1").c_str())) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ byte domoticz_update_flag = 1;
|
||||||
|
|
||||||
void mqtt_publishDomoticzPowerState(byte device)
|
void mqtt_publishDomoticzPowerState(byte device)
|
||||||
{
|
{
|
||||||
char svalue[MESSZ];
|
char svalue[64]; // was MESSZ
|
||||||
|
|
||||||
if (sysCfg.domoticz_relay_idx[device -1] && (strlen(sysCfg.domoticz_in_topic) != 0)) {
|
if (sysCfg.domoticz_relay_idx[device -1] && (strlen(sysCfg.domoticz_in_topic) != 0)) {
|
||||||
if ((device < 1) || (device > Maxdevice)) device = 1;
|
if ((device < 1) || (device > Maxdevice)) device = 1;
|
||||||
|
@ -236,7 +236,7 @@ void domoticz_commands(char *svalue, uint16_t ssvalue)
|
||||||
boolean domoticz_button(byte key, byte device, byte state, byte svalflg)
|
boolean domoticz_button(byte key, byte device, byte state, byte svalflg)
|
||||||
{
|
{
|
||||||
if ((sysCfg.domoticz_key_idx[device -1] || sysCfg.domoticz_switch_idx[device -1]) && (svalflg)) {
|
if ((sysCfg.domoticz_key_idx[device -1] || sysCfg.domoticz_switch_idx[device -1]) && (svalflg)) {
|
||||||
char svalue[MESSZ];
|
char svalue[80]; // was MESSZ
|
||||||
|
|
||||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"command\":\"switchlight\",\"idx\":%d,\"switchcmd\":\"%s\"}"),
|
snprintf_P(svalue, sizeof(svalue), PSTR("{\"command\":\"switchlight\",\"idx\":%d,\"switchcmd\":\"%s\"}"),
|
||||||
(key) ? sysCfg.domoticz_switch_idx[device -1] : sysCfg.domoticz_key_idx[device -1], (state) ? (state == 2) ? "Toggle" : "On" : "Off");
|
(key) ? sysCfg.domoticz_switch_idx[device -1] : sysCfg.domoticz_key_idx[device -1], (state) ? (state == 2) ? "Toggle" : "On" : "Off");
|
||||||
|
|
|
@ -122,7 +122,8 @@ void sl_setPower(uint8_t power)
|
||||||
|
|
||||||
void sl_animate()
|
void sl_animate()
|
||||||
{
|
{
|
||||||
char svalue[MESSZ];
|
// {"Wakeup":"Done"}
|
||||||
|
char svalue[32]; // was MESSZ
|
||||||
uint8_t fadeValue;
|
uint8_t fadeValue;
|
||||||
|
|
||||||
if ((sl_power == 0) || sl_blankv) { // Power Off
|
if ((sl_power == 0) || sl_blankv) { // Power Off
|
||||||
|
|
|
@ -214,7 +214,7 @@ String dht_webPresent()
|
||||||
float t, h;
|
float t, h;
|
||||||
|
|
||||||
if (dht_readTempHum(TEMP_CONVERSION, t, h)) { // Read temperature as Celsius (the default)
|
if (dht_readTempHum(TEMP_CONVERSION, t, h)) { // Read temperature as Celsius (the default)
|
||||||
char stemp[10], sensor[128];
|
char stemp[10], sensor[80];
|
||||||
dtostrf(t, 1, TEMP_RESOLUTION &3, stemp);
|
dtostrf(t, 1, TEMP_RESOLUTION &3, stemp);
|
||||||
snprintf_P(sensor, sizeof(sensor), HTTP_SNS_TEMP, dhtstype, stemp, (TEMP_CONVERSION) ? 'F' : 'C');
|
snprintf_P(sensor, sizeof(sensor), HTTP_SNS_TEMP, dhtstype, stemp, (TEMP_CONVERSION) ? 'F' : 'C');
|
||||||
page += sensor;
|
page += sensor;
|
||||||
|
|
|
@ -30,6 +30,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
* Source: Marinus vd Broek https://github.com/ESP8266nu/ESPEasy and AlexTransit (CRC)
|
* Source: Marinus vd Broek https://github.com/ESP8266nu/ESPEasy and AlexTransit (CRC)
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
|
float dsb_mt = 0;
|
||||||
|
|
||||||
uint8_t dsb_reset()
|
uint8_t dsb_reset()
|
||||||
{
|
{
|
||||||
uint8_t r;
|
uint8_t r;
|
||||||
|
@ -131,11 +133,15 @@ boolean dsb_readTemp(bool S, float &t)
|
||||||
int16_t DSTemp;
|
int16_t DSTemp;
|
||||||
byte msb, lsb, crc;
|
byte msb, lsb, crc;
|
||||||
|
|
||||||
t = NAN;
|
if (!dsb_mt) {
|
||||||
|
t = NAN;
|
||||||
|
} else {
|
||||||
|
t = dsb_mt;
|
||||||
|
}
|
||||||
|
|
||||||
if (!dsb_read_bit()) { //check measurement end
|
if (!dsb_read_bit()) { //check measurement end
|
||||||
addLog_P(LOG_LEVEL_DEBUG, PSTR("DSB: Sensor busy"));
|
addLog_P(LOG_LEVEL_DEBUG, PSTR("DSB: Sensor busy"));
|
||||||
return false;
|
return !isnan(t);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
dsb_reset();
|
dsb_reset();
|
||||||
|
@ -165,6 +171,7 @@ boolean dsb_readTemp(bool S, float &t)
|
||||||
t = (float(DSTemp) * 0.0625);
|
t = (float(DSTemp) * 0.0625);
|
||||||
if(S) t = dsb_convertCtoF(t);
|
if(S) t = dsb_convertCtoF(t);
|
||||||
}
|
}
|
||||||
|
if (!isnan(t)) dsb_mt = t;
|
||||||
return !isnan(t);
|
return !isnan(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +184,7 @@ void dsb_mqttPresent(char* svalue, uint16_t ssvalue, uint8_t* djson)
|
||||||
char stemp1[10];
|
char stemp1[10];
|
||||||
float t;
|
float t;
|
||||||
|
|
||||||
if (dsb_readTemp(TEMP_CONVERSION, t)) { // Check if read failed
|
if (dsb_readTemp(TEMP_CONVERSION, t)) { // Check if read failed
|
||||||
dtostrf(t, 1, TEMP_RESOLUTION &3, stemp1);
|
dtostrf(t, 1, TEMP_RESOLUTION &3, stemp1);
|
||||||
snprintf_P(svalue, ssvalue, PSTR("%s, \"DS18B20\":{\"Temperature\":%s}"), svalue, stemp1);
|
snprintf_P(svalue, ssvalue, PSTR("%s, \"DS18B20\":{\"Temperature\":%s}"), svalue, stemp1);
|
||||||
*djson = 1;
|
*djson = 1;
|
||||||
|
@ -194,12 +201,13 @@ String dsb_webPresent()
|
||||||
String page = "";
|
String page = "";
|
||||||
float st;
|
float st;
|
||||||
|
|
||||||
if (dsb_readTemp(TEMP_CONVERSION, st)) { // Check if read failed
|
if (dsb_readTemp(TEMP_CONVERSION, st)) { // Check if read failed
|
||||||
char stemp[10], sensor[80];
|
char stemp[10], sensor[80];
|
||||||
dtostrf(st, 1, TEMP_RESOLUTION &3, stemp);
|
dtostrf(st, 1, TEMP_RESOLUTION &3, stemp);
|
||||||
snprintf_P(sensor, sizeof(sensor), HTTP_SNS_TEMP, "DS18B20", stemp, (TEMP_CONVERSION) ? 'F' : 'C');
|
snprintf_P(sensor, sizeof(sensor), HTTP_SNS_TEMP, "DS18B20", stemp, (TEMP_CONVERSION) ? 'F' : 'C');
|
||||||
page += sensor;
|
page += sensor;
|
||||||
}
|
}
|
||||||
|
dsb_readTempPrep();
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
|
|
|
@ -200,6 +200,8 @@ String ds18x20_webPresent()
|
||||||
page += sensor;
|
page += sensor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ds18x20_search(); // Check for changes in sensors number
|
||||||
|
ds18x20_convert(); // Start Conversion, takes up to one second
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
|
|
|
@ -282,7 +282,7 @@ void hlw_setPowerSteadyCounter(byte value)
|
||||||
|
|
||||||
void hlw_margin_chk()
|
void hlw_margin_chk()
|
||||||
{
|
{
|
||||||
char log[LOGSZ], svalue[MESSZ];
|
char log[LOGSZ], svalue[200]; // was MESSZ
|
||||||
float ped, pi, pc;
|
float ped, pi, pc;
|
||||||
uint16_t uped, piv, pe, pw, pu;
|
uint16_t uped, piv, pe, pw, pu;
|
||||||
byte flag, jsonflg;
|
byte flag, jsonflg;
|
||||||
|
@ -543,7 +543,8 @@ void hlw_mqttStat(byte option, char* svalue, uint16_t ssvalue)
|
||||||
|
|
||||||
void hlw_mqttPresent()
|
void hlw_mqttPresent()
|
||||||
{
|
{
|
||||||
char svalue[MESSZ];
|
// {"Time":"2017-03-04T13:37:24", "Yesterday":0.013, "Today":0.000, "Period":0, "Power":0, "Factor":0.00, "Voltage":0, "Current":0.000}
|
||||||
|
char svalue[200]; // was MESSZ
|
||||||
|
|
||||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Time\":\"%04d-%02d-%02dT%02d:%02d:%02d\", "),
|
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Time\":\"%04d-%02d-%02dT%02d:%02d:%02d\", "),
|
||||||
rtcTime.Year, rtcTime.Month, rtcTime.Day, rtcTime.Hour, rtcTime.Minute, rtcTime.Second);
|
rtcTime.Year, rtcTime.Month, rtcTime.Day, rtcTime.Hour, rtcTime.Minute, rtcTime.Second);
|
||||||
|
|
|
@ -275,7 +275,7 @@ String htu_webPresent()
|
||||||
{
|
{
|
||||||
String page = "";
|
String page = "";
|
||||||
if (htutype) {
|
if (htutype) {
|
||||||
char stemp[10], sensor[128];
|
char stemp[10], sensor[80];
|
||||||
|
|
||||||
float t_htu21 = htu21_readTemperature(TEMP_CONVERSION);
|
float t_htu21 = htu21_readTemperature(TEMP_CONVERSION);
|
||||||
float h_htu21 = htu21_readHumidity();
|
float h_htu21 = htu21_readHumidity();
|
||||||
|
|
Loading…
Reference in New Issue