Update from Tasmota

Update from Tasmota
This commit is contained in:
Adrian Scillato 2018-04-28 23:46:25 -03:00 committed by GitHub
commit 9852aaa0f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 57 additions and 9 deletions

View File

@ -146,7 +146,7 @@ If you like **Sonoff-Tasmota**, give it a star, or fork it and contribute!
### Development: ### Development:
[![Build Status](https://img.shields.io/travis/arendst/Sonoff-Tasmota.svg)](https://travis-ci.org/arendst/Sonoff-Tasmota) [![Build Status](https://img.shields.io/travis/arendst/Sonoff-Tasmota.svg)](https://travis-ci.org/arendst/Sonoff-Tasmota)
Current version is **5.12.0m** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information. Current version is **5.12.0n** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
### Quick install ### Quick install
Download one of the released binaries from https://github.com/arendst/Sonoff-Tasmota/releases and flash it to your hardware as documented in the wiki. Download one of the released binaries from https://github.com/arendst/Sonoff-Tasmota/releases and flash it to your hardware as documented in the wiki.
@ -266,7 +266,7 @@ Different firmware images are released based on Features and Sensors selection g
|--------------------------------|--------|---------|---------|------|------------| |--------------------------------|--------|---------|---------|------|------------|
| ESP/Arduino lib v2.3.0 | 526k | 488k | 427k | 535k | 549k | | ESP/Arduino lib v2.3.0 | 526k | 488k | 427k | 535k | 549k |
| ESP/Arduino lib v2.4.0 | 531k | 496k | 435k | 540k | 552k | | ESP/Arduino lib v2.4.0 | 531k | 496k | 435k | 540k | 552k |
| ESP/Arduino lib v2.4.1 | 533k | 498k | 436k | 542k | 554k | | ESP/Arduino lib v2.4.1 | 534k | 499k | 437k | 543k | 555k |
### Contribute ### Contribute
You can contribute to Sonoff-Tasmota by You can contribute to Sonoff-Tasmota by

View File

@ -1,6 +1,13 @@
/* 5.12.0m /* 5.12.0n
* Change ESP8266 Analog JSON message from {"Analog0:123"} to {"ANALOG":{"A0:123"}} to accomodate rules (#2560)
* Change Counter JSON message from {"Counter1":0,"Counter3":0} to {"COUNTER":{"C1":0,"C3":0}} to accomodate rules
* Change ADS1115 JSON message from {"ADS1115":{"Analog0":123,"Analog1":123}} to {"ADS1115":{"A0":123,"A1":123}}
* Add ANALOG#A0div10 trigger to rules to be used in rule like on analog#a0div10 do publish cmnd/ailight/dimmer %value% endon
*
* 5.12.0m
* Reinit timers to accomodate random window (#2447) * Reinit timers to accomodate random window (#2447)
* Remove sonoff-xxl * Remove sonoff-xxl
* Disable sleep when using Esp/Arduino core 2.4.1 (#2559)
* Add sonoff-classic, sonoff-allsensors and sonoff-knx * Add sonoff-classic, sonoff-allsensors and sonoff-knx
* Add some coloring to important web buttons * Add some coloring to important web buttons
* Add rule variables and teleperiod trigger to accomodate user HA messages * Add rule variables and teleperiod trigger to accomodate user HA messages

View File

@ -25,7 +25,7 @@
- Select IDE Tools - Flash Size: "1M (no SPIFFS)" - Select IDE Tools - Flash Size: "1M (no SPIFFS)"
====================================================*/ ====================================================*/
#define VERSION 0x050C000D // 5.12.0m #define VERSION 0x050C000E // 5.12.0n
// Location specific includes // Location specific includes
#include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0) #include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0)

View File

@ -615,7 +615,9 @@ void WifiBegin(uint8_t flag)
delay(200); delay(200);
WiFi.mode(WIFI_STA); // Disable AP mode WiFi.mode(WIFI_STA); // Disable AP mode
if (Settings.sleep) { if (Settings.sleep) {
#ifndef ARDUINO_ESP8266_RELEASE_2_4_1 // See https://github.com/arendst/Sonoff-Tasmota/issues/2559
WiFi.setSleepMode(WIFI_LIGHT_SLEEP); // Allow light sleep during idle times WiFi.setSleepMode(WIFI_LIGHT_SLEEP); // Allow light sleep during idle times
#endif
} }
// if (WiFi.getPhyMode() != WIFI_PHY_MODE_11N) { // if (WiFi.getPhyMode() != WIFI_PHY_MODE_11N) {
// WiFi.setPhyMode(WIFI_PHY_MODE_11N); // WiFi.setPhyMode(WIFI_PHY_MODE_11N);
@ -1384,7 +1386,10 @@ void RtcInit()
* ADC support * ADC support
\*********************************************************************************************/ \*********************************************************************************************/
void AdcShow(boolean json) uint8_t adc_counter = 0;
uint16_t adc_last_value = 0;
uint16_t AdcRead()
{ {
uint16_t analog = 0; uint16_t analog = 0;
for (byte i = 0; i < 32; i++) { for (byte i = 0; i < 32; i++) {
@ -1392,9 +1397,29 @@ void AdcShow(boolean json)
delay(1); delay(1);
} }
analog >>= 5; analog >>= 5;
return analog;
}
void AdcEvery50ms()
{
adc_counter++;
if (!(adc_counter % 4)) {
uint16_t new_value = AdcRead();
if ((new_value < adc_last_value -10) || (new_value > adc_last_value +10)) {
adc_last_value = new_value;
uint16_t value = adc_last_value / 10;
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"ANALOG\":{\"A0div10\":%d}}"), (0 == value) ? 1 : (value > 99) ? 100 : value);
RulesProcess();
}
}
}
void AdcShow(boolean json)
{
uint16_t analog = AdcRead();
if (json) { if (json) {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"" D_JSON_ANALOG_INPUT "0\":%d"), mqtt_data, analog); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"ANALOG\":{\"A0\":%d}"), mqtt_data, analog);
#ifdef USE_WEBSERVER #ifdef USE_WEBSERVER
} else { } else {
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_ANALOG, mqtt_data, "", 0, analog); snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_ANALOG, mqtt_data, "", 0, analog);
@ -1414,6 +1439,9 @@ boolean Xsns02(byte function)
if (pin[GPIO_ADC0] < 99) { if (pin[GPIO_ADC0] < 99) {
switch (function) { switch (function) {
case FUNC_EVERY_50_MSECOND:
AdcEvery50ms();
break;
case FUNC_JSON_APPEND: case FUNC_JSON_APPEND:
AdcShow(1); AdcShow(1);
break; break;

View File

@ -90,9 +90,11 @@ const char HTTP_SNS_COUNTER[] PROGMEM =
void CounterShow(boolean json) void CounterShow(boolean json)
{ {
char stemp[10];
char counter[16]; char counter[16];
byte dsxflg = 0; byte dsxflg = 0;
byte header = 0;
for (byte i = 0; i < MAX_COUNTERS; i++) { for (byte i = 0; i < MAX_COUNTERS; i++) {
if (pin[GPIO_CNTR1 +i] < 99) { if (pin[GPIO_CNTR1 +i] < 99) {
if (bitRead(Settings.pulse_counter_type, i)) { if (bitRead(Settings.pulse_counter_type, i)) {
@ -103,7 +105,13 @@ void CounterShow(boolean json)
} }
if (json) { if (json) {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"" D_JSON_COUNTER "%d\":%s"), mqtt_data, i +1, counter); if (!header) {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"COUNTER\":{"), mqtt_data);
stemp[0] = '\0';
}
header++;
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s%s\"C%d\":%s"), mqtt_data, stemp, i +1, counter);
strcpy(stemp, ",");
#ifdef USE_DOMOTICZ #ifdef USE_DOMOTICZ
if ((0 == tele_period) && (1 == dsxflg)) { if ((0 == tele_period) && (1 == dsxflg)) {
DomoticzSensor(DZ_COUNT, RtcSettings.pulse_counter[i]); DomoticzSensor(DZ_COUNT, RtcSettings.pulse_counter[i]);
@ -117,6 +125,11 @@ void CounterShow(boolean json)
} }
} }
} }
if (json) {
if (header) {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data);
}
}
} }
/*********************************************************************************************\ /*********************************************************************************************\

View File

@ -190,7 +190,7 @@ void Ads1115Show(boolean json)
stemp[0] = '\0'; stemp[0] = '\0';
} }
dsxflg++; dsxflg++;
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s%s\"" D_JSON_ANALOG_INPUT "%d\":%d"), mqtt_data, stemp, i, adc_value); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s%s\"A%d\":%d"), mqtt_data, stemp, i, adc_value);
strcpy(stemp, ","); strcpy(stemp, ",");
#ifdef USE_WEBSERVER #ifdef USE_WEBSERVER
} else { } else {

View File

@ -110,7 +110,7 @@ void Ads1115Show(boolean json)
stemp[0] = '\0'; stemp[0] = '\0';
} }
dsxflg++; dsxflg++;
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s%s\"" D_JSON_ANALOG_INPUT "%d\":%d"), mqtt_data, stemp, i, adc_value); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s%s\"A%d\":%d"), mqtt_data, stemp, i, adc_value);
strcpy(stemp, ","); strcpy(stemp, ",");
#ifdef USE_WEBSERVER #ifdef USE_WEBSERVER
} else { } else {