5.1.2 20170519
* Fix Counter/Timer JSON message and update Counter/Timer on webpage
* Fix WS2812 Domoticz related regression issues
This commit is contained in:
arendst 2017-05-19 16:09:25 +02:00
parent 88648a8099
commit 26d3a8c191
7 changed files with 65 additions and 45 deletions

View File

@ -1,7 +1,7 @@
## 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.
Current version is **5.1.1** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
Current version is **5.1.2** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
### **** ATTENTION Version 5.x.x specific information ****

Binary file not shown.

View File

@ -1,4 +1,8 @@
/* 5.1.1 20170517
/* 5.1.2 20170519
* Fix Counter/Timer JSON message and update Counter/Timer on webpage
* Fix WS2812 Domoticz related regression issues
*
* 5.1.1 20170517
* Allow command FullTopic in group mode
* Prepare for more use of RTC memory
* Add independant WS2812 led string power control (#386, #390)

View File

@ -24,7 +24,7 @@
- Select IDE Tools - Flash size: "1M (no SPIFFS)"
====================================================*/
#define VERSION 0x05010100 // 5.1.1
#define VERSION 0x05010200 // 5.1.2
enum log_t {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL};
enum week_t {Last, First, Second, Third, Fourth};
@ -1799,6 +1799,8 @@ void state_mqttPresent(char* svalue, uint16_t ssvalue)
void sensors_mqttPresent(char* svalue, uint16_t ssvalue, uint8_t* djson)
{
char stemp[16];
snprintf_P(svalue, ssvalue, PSTR("%s{\"Time\":\"%s\""), svalue, getDateTime().c_str());
for (byte i = 0; i < 4; i++) {
if (pin[GPIO_SWT1 +i] < 99) {
@ -1809,7 +1811,12 @@ void sensors_mqttPresent(char* svalue, uint16_t ssvalue, uint8_t* djson)
}
for (byte i = 0; i < 4; i++) {
if (pin[GPIO_CNTR1 +i] < 99) {
snprintf_P(svalue, ssvalue, PSTR("%s, {\"Counter%d\":%d}"), svalue, i +1, rtcMem.pCounter[i]);
if (bitRead(sysCfg.pCounterType, i)) {
dtostrf((double)rtcMem.pCounter[i] / 1000, 1, 3, stemp);
} else {
dtostrf(rtcMem.pCounter[i], 1, 0, stemp);
}
snprintf_P(svalue, ssvalue, PSTR("%s, \"Counter%d\":%s"), svalue, i +1, stemp);
*djson = 1;
}
}
@ -2467,7 +2474,6 @@ void GPIO_init()
analogWrite(pin[GPIO_PWM1 +i], sysCfg.pwmvalue[i]);
}
}
counter_init();
if (EXS_RELAY == sysCfg.module) {
setLatchingRelay(0,2);
@ -2475,6 +2481,21 @@ void GPIO_init()
}
setLed(sysCfg.ledstate &8);
#ifdef USE_WS2812
if (pin[GPIO_WS2812] < 99) {
Maxdevice++;
ws2812_init(Maxdevice);
}
#endif // USE_WS2812
#ifdef USE_IR_REMOTE
if (pin[GPIO_IRSEND] < 99) {
ir_send_init();
}
#endif // USE_IR_REMOTE
counter_init();
hlw_flg = ((pin[GPIO_HLW_SEL] < 99) && (pin[GPIO_HLW_CF1] < 99) && (pin[GPIO_HLW_CF] < 99));
if (hlw_flg) {
hlw_init();
@ -2498,19 +2519,6 @@ void GPIO_init()
Wire.begin(pin[GPIO_I2C_SDA], pin[GPIO_I2C_SCL]);
}
#endif // USE_I2C
#ifdef USE_WS2812
if (pin[GPIO_WS2812] < 99) {
Maxdevice++;
ws2812_init(Maxdevice);
}
#endif // USE_WS2812
#ifdef USE_IR_REMOTE
if (pin[GPIO_IRSEND] < 99) {
ir_send_init();
}
#endif // USE_IR_REMOTE
}
extern "C" {

View File

@ -251,7 +251,7 @@ const char HTTP_TABLE100[] PROGMEM =
const char HTTP_COUNTER[] PROGMEM =
"<br/><div id='t' name='t' style='text-align:center;'></div>";
const char HTTP_SNS_COUNTER[] PROGMEM =
"<tr><th>Counter%d</th><td>%d</td></tr>";
"<tr><th>Counter%d</th><td>%s%s</td></tr>";
const char HTTP_SNS_TEMP[] PROGMEM =
"<tr><th>%s Temperature</th><td>%s&deg;%c</td></tr>";
const char HTTP_SNS_HUM[] PROGMEM =
@ -449,7 +449,8 @@ void handleRoot()
void handleAjax2()
{
char svalue[80];
char svalue[16];
char sensor[80];
if (strlen(webServer->arg("o").c_str())) {
do_cmnd_power(atoi(webServer->arg("o").c_str()), 2);
@ -462,8 +463,13 @@ void handleAjax2()
String tpage = "";
for (byte i = 0; i < 4; i++) {
if (pin[GPIO_CNTR1 +i] < 99) {
snprintf_P(svalue, sizeof(svalue), HTTP_SNS_COUNTER, i+1, rtcMem.pCounter[i]);
tpage += svalue;
if (bitRead(sysCfg.pCounterType, i)) {
dtostrf((double)rtcMem.pCounter[i] / 1000, 1, 3, svalue);
} else {
dtostrf(rtcMem.pCounter[i], 1, 0, svalue);
}
snprintf_P(sensor, sizeof(sensor), HTTP_SNS_COUNTER, i+1, svalue, (bitRead(sysCfg.pCounterType, i)) ? " Sec" : "");
tpage += sensor;
}
}
if (hlw_flg) {

View File

@ -42,6 +42,7 @@ const char HTTP_FORM_DOMOTICZ_TIMER[] PROGMEM =
const char domoticz_sensors[DOMOTICZ_MAX_SENSORS][14] PROGMEM =
{ "Temp", "Temp,Hum", "Temp,Hum,Baro", "Power,Energy", "Illuminance" };
boolean domoticz_subscribe = false;
int domoticz_update_timer = 0;
byte domoticz_update_flag = 1;
@ -59,7 +60,7 @@ void mqtt_publishDomoticzPowerState(byte device)
sysCfg.domoticz_relay_idx[device -1], sysCfg.led_dimmer[device -1]);
mqtt_publish(sysCfg.domoticz_in_topic, svalue);
}
else if ((1 == device) && (pin[GPIO_WS2812] < 99)) {
else if ((Maxdevice == device) && (pin[GPIO_WS2812] < 99)) {
snprintf_P(svalue, sizeof(svalue), PSTR("{\"idx\":%d,\"nvalue\":2,\"svalue\":\"%d\"}"),
sysCfg.domoticz_relay_idx[device -1], sysCfg.ws_dimmer);
mqtt_publish(sysCfg.domoticz_in_topic, svalue);
@ -80,7 +81,7 @@ void domoticz_updatePowerState(byte device)
void domoticz_mqttUpdate()
{
if ((sysCfg.domoticz_update_timer || domoticz_update_timer) && sysCfg.domoticz_relay_idx[0]) {
if (domoticz_subscribe && (sysCfg.domoticz_update_timer || domoticz_update_timer)) {
domoticz_update_timer--;
if (domoticz_update_timer <= 0) {
domoticz_update_timer = sysCfg.domoticz_update_timer;
@ -98,7 +99,12 @@ void domoticz_setUpdateTimer(uint16_t value)
void domoticz_mqttSubscribe()
{
if (sysCfg.domoticz_relay_idx[0] && (strlen(sysCfg.domoticz_out_topic) != 0)) {
for (byte i = 0; i < Maxdevice; i++) {
if (sysCfg.domoticz_relay_idx[i]) {
domoticz_subscribe = true;
}
}
if (domoticz_subscribe && (strlen(sysCfg.domoticz_out_topic) != 0)) {
char stopic[TOPSZ];
snprintf_P(stopic, sizeof(stopic), PSTR("%s/#"), sysCfg.domoticz_out_topic); // domoticz topic
mqttClient.subscribe(stopic);

View File

@ -537,14 +537,12 @@ boolean ws2812_command(char *type, uint16_t index, char *dataBuf, uint16_t data_
}
else if (!strcmp_P(type,PSTR("LED")) && (index > 0) && (index <= sysCfg.ws_pixels)) {
if (6 == data_len) {
// ws2812_setColor(index, dataBufUc);
ws2812_setColor(index, dataBuf);
}
ws2812_getColor(index, svalue, ssvalue);
}
else if (!strcmp_P(type,PSTR("COLOR"))) {
if (6 == data_len) {
// ws2812_setColor(0, dataBufUc);
ws2812_setColor(0, dataBuf);
bitSet(power, ws_bit);
}
@ -555,7 +553,8 @@ boolean ws2812_command(char *type, uint16_t index, char *dataBuf, uint16_t data_
sysCfg.ws_dimmer = payload;
bitSet(power, ws_bit);
#ifdef USE_DOMOTICZ
mqtt_publishDomoticzPowerState(index);
// mqtt_publishDomoticzPowerState(index);
mqtt_publishDomoticzPowerState(ws_bit +1);
#endif // USE_DOMOTICZ
}
snprintf_P(svalue, ssvalue, PSTR("{\"Dimmer\":%d}"), sysCfg.ws_dimmer);
@ -601,23 +600,6 @@ boolean ws2812_command(char *type, uint16_t index, char *dataBuf, uint16_t data_
}
snprintf_P(svalue, ssvalue, PSTR("{\"Width\":%d}"), sysCfg.ws_width);
}
else if (!strcmp_P(type,PSTR("UNDOCA"))) { // Theos WS2812 legacy status
RgbColor mcolor;
char mtopic[TOPSZ];
getTopic_P(mtopic, 1, sysCfg.mqtt_topic, type);
ws2812_setDim(sysCfg.ws_dimmer);
mcolor = dcolor;
uint32_t color = (uint32_t)mcolor.R << 16;
color += (uint32_t)mcolor.G << 8;
color += (uint32_t)mcolor.B;
snprintf_P(svalue, ssvalue, PSTR("%s, %s, %d, %d, %d, %06X, %d, 0, %d, %d, %d, %d, %d, %d"),
Version, sysCfg.mqtt_topic, bitRead(power, ws_bit), sysCfg.ws_fade, sysCfg.ws_dimmer, color,
sysCfg.ws_pixels, sysCfg.ws_wakeup,
sysCfg.ws_scheme, sysCfg.ws_speed, sysCfg.ws_width, sysCfg.timezone, sysCfg.ws_ledtable);
mqtt_publish(mtopic, svalue);
// snprintf_P(svalue, ssvalue, PSTR("{\"UndocA\":\"Done\"}"));
svalue[0] = '\0';
}
else if (!strcmp_P(type,PSTR("WAKEUP"))) {
if ((data_len > 0) && (payload > 0) && (payload < 3601)) {
sysCfg.ws_wakeup = payload;
@ -638,6 +620,20 @@ boolean ws2812_command(char *type, uint16_t index, char *dataBuf, uint16_t data_
}
snprintf_P(svalue, ssvalue, PSTR("{\"Scheme\":%d}"), sysCfg.ws_scheme);
}
else if (!strcmp_P(type,PSTR("UNDOCA"))) { // Theos WS2812 legacy status
RgbColor mcolor;
char mtopic[TOPSZ];
getTopic_P(mtopic, 1, sysCfg.mqtt_topic, type);
ws2812_setDim(sysCfg.ws_dimmer);
mcolor = dcolor;
uint32_t color = (uint32_t)mcolor.R << 16;
color += (uint32_t)mcolor.G << 8;
color += (uint32_t)mcolor.B;
snprintf_P(svalue, ssvalue, PSTR("%06X, %d, %d, %d, %d, %d"),
color, sysCfg.ws_fade, sysCfg.ws_ledtable, sysCfg.ws_scheme, sysCfg.ws_speed, sysCfg.ws_width);
mqtt_publish(mtopic, svalue);
svalue[0] = '\0';
}
else {
serviced = false; // Unknown command
}