v5.9.1e - Fixes and Additions

5.9.1e
 * Add + (plus) and - (minus) to command color to select 1 out of
12 preset colors
 * Add + (plus) and - (minus) to command ct to control
ColdWarm led ColorTemperature (+34/-34)
 * Tune Arilux RF code
 * Fix
possible iram1_0_seg compile error by shrinking ICACHE_RAM_ATTR code
 *
Update core_esp8266_wiring_digital.c to latest (staged) level
 *
Workaround Sonoff Bridge Learn Mode hang caused by unrecognised RF code
(#1181)
 * Fix blank console log window by using XML character encoding
(#1187)
This commit is contained in:
arendst 2017-11-17 17:52:31 +01:00
parent db4a3a4a1e
commit 9c74a4a041
12 changed files with 216 additions and 164 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.9.1d** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
Current version is **5.9.1e** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
### ATTENTION All versions

View File

@ -1,5 +1,14 @@
/* 5.9.1d
* Add support for Arilux LC11 (CLearing RF home code when selecting no Arilux module)
/* 5.9.1e
* Add + (plus) and - (minus) to command color to select 1 out of 12 preset colors
* Add + (plus) and - (minus) to command ct to control ColdWarm led ColorTemperature (+34/-34)
* Tune Arilux RF code
* Fix possible iram1_0_seg compile error by shrinking ICACHE_RAM_ATTR code
* Update core_esp8266_wiring_digital.c to latest (staged) level
* Workaround Sonoff Bridge Learn Mode hang caused by unrecognised RF code (#1181)
* Fix blank console log window by using XML character encoding (#1187)
*
* 5.9.1d
* Add support for Arilux LC11 (Clearing RF home code when selecting no Arilux module)
* Add fixed color options 1..12 to command Color
* Add + (plus) and - (minus) to commands Dimmer (+10/-10), Speed and Scheme
*

View File

@ -384,7 +384,7 @@
#define D_DOMOTICZ_CURRENT "Current"
#define D_DOMOTICZ_UPDATE_TIMER "Update timer"
// xdrv_ir-send.ino
// xdrv_irremote.ino
#define D_INVALID_JSON "ungültiger JSON"
#define D_PROTOCOL_NOT_SUPPORTED "Protokoll nicht unterstützt"
#define D_IR_PROTOCOL "PROTOKOLL"
@ -427,18 +427,7 @@
#define D_HUE_POST_ARGS "Hue POST args"
#define D_3_RESPONSE_PACKETS_SENT "3 Antwortpakete gesendet"
// xsns_dht.ino
#define D_TIMEOUT_WAITING_FOR "Timeout wartet auf"
#define D_START_SIGNAL_LOW "Startausschlag niedrig"
#define D_START_SIGNAL_HIGH "Startausschlag hoch"
#define D_PULSE "pulse"
#define D_CHECKSUM_FAILURE "Checksum-Fehler"
// xsns_ds18b20.ino
#define D_SENSOR_BUSY "Sensor beschäftigt"
#define D_SENSOR_CRC_ERROR "Sensor CRC-Fehler"
// xsns_hlw8012.ino
// xsns_03_hlw8012.ino
#define D_MAXPOWERREACHED "MaxPowerReached"
#define D_MAXPOWERREACHEDRETRY "MaxPowerReachedRetry"
#define D_POWERMONITOR "PowerMonitor"
@ -448,7 +437,18 @@
#define D_ENERGY_YESTERDAY "Energie gestern"
#define D_ENERGY_TOTAL "Energie insgesamt"
// xsns_sht1x.ino
// xsns_05_ds18b20.ino
#define D_SENSOR_BUSY "Sensor beschäftigt"
#define D_SENSOR_CRC_ERROR "Sensor CRC-Fehler"
// xsns_06_dht.ino
#define D_TIMEOUT_WAITING_FOR "Timeout wartet auf"
#define D_START_SIGNAL_LOW "Startausschlag niedrig"
#define D_START_SIGNAL_HIGH "Startausschlag hoch"
#define D_PULSE "pulse"
#define D_CHECKSUM_FAILURE "Checksum-Fehler"
// xsns_07_sht1x.ino
#define D_SENSOR_DID_NOT_ACK_COMMAND "Sensor hat ACK-Befehl nicht ausgeführt"
#define D_SHT1X_FOUND "SHT1X gefunden"
@ -643,19 +643,11 @@
#define D_CMND_SENSORIDX "SensorIdx"
#define D_CMND_UPDATETIMER "UpdateTimer"
// Commands xdrv_ir_send.ino
// Commands xdrv_irremote.ino
#define D_CMND_IRSEND "IRSend"
#define D_CMND_IRHVAC "IRHVAC"
// Commands xdrv_snfbridge.ino
#define D_CMND_RFCODE "RfCode"
#define D_CMND_RFHIGH "RfHigh"
#define D_CMND_RFHOST "RfHost"
#define D_CMND_RFKEY "RfKey"
#define D_CMND_RFLOW "RfLow"
#define D_CMND_RFSYNC "RfSync"
// Commands xdrv_snfled.ino
// Commands xdrv_light.ino
#define D_CMND_COLOR "Color"
#define D_CMND_COLORTEMPERATURE "CT"
#define D_CMND_DIMMER "Dimmer"
@ -669,7 +661,15 @@
#define D_CMND_WAKEUPDURATION "WakeUpDuration"
#define D_CMND_WIDTH "Width"
// Commands xsns_hlw8012.ino
// Commands xdrv_snfbridge.ino
#define D_CMND_RFCODE "RfCode"
#define D_CMND_RFHIGH "RfHigh"
#define D_CMND_RFHOST "RfHost"
#define D_CMND_RFKEY "RfKey"
#define D_CMND_RFLOW "RfLow"
#define D_CMND_RFSYNC "RfSync"
// Commands xsns_03_hlw8012.ino
#define D_CMND_POWERLOW "PowerLow"
#define D_CMND_POWERHIGH "PowerHigh"
#define D_CMND_VOLTAGELOW "VoltageLow"

View File

@ -384,7 +384,7 @@
#define D_DOMOTICZ_CURRENT "Current"
#define D_DOMOTICZ_UPDATE_TIMER "Update timer"
// xdrv_ir-send.ino
// xdrv_irremote.ino
#define D_INVALID_JSON "Invalid JSON"
#define D_PROTOCOL_NOT_SUPPORTED "Protocol not supported"
#define D_IR_PROTOCOL "PROTOCOL"
@ -427,18 +427,7 @@
#define D_HUE_POST_ARGS "Hue POST args"
#define D_3_RESPONSE_PACKETS_SENT "3 response packets sent"
// xsns_dht.ino
#define D_TIMEOUT_WAITING_FOR "Timeout waiting for"
#define D_START_SIGNAL_LOW "start signal low"
#define D_START_SIGNAL_HIGH "start signal high"
#define D_PULSE "pulse"
#define D_CHECKSUM_FAILURE "Checksum failure"
// xsns_ds18b20.ino
#define D_SENSOR_BUSY "Sensor busy"
#define D_SENSOR_CRC_ERROR "Sensor CRC error"
// xsns_hlw8012.ino
// xsns_03_hlw8012.ino
#define D_MAXPOWERREACHED "MaxPowerReached"
#define D_MAXPOWERREACHEDRETRY "MaxPowerReachedRetry"
#define D_POWERMONITOR "PowerMonitor"
@ -448,7 +437,18 @@
#define D_ENERGY_YESTERDAY "Energy Yesterday"
#define D_ENERGY_TOTAL "Energy Total"
// xsns_sht1x.ino
// xsns_05_ds18b20.ino
#define D_SENSOR_BUSY "Sensor busy"
#define D_SENSOR_CRC_ERROR "Sensor CRC error"
// xsns_06_dht.ino
#define D_TIMEOUT_WAITING_FOR "Timeout waiting for"
#define D_START_SIGNAL_LOW "start signal low"
#define D_START_SIGNAL_HIGH "start signal high"
#define D_PULSE "pulse"
#define D_CHECKSUM_FAILURE "Checksum failure"
// xsns_07_sht1x.ino
#define D_SENSOR_DID_NOT_ACK_COMMAND "Sensor did not ACK command"
#define D_SHT1X_FOUND "SHT1X found"
@ -643,19 +643,11 @@
#define D_CMND_SENSORIDX "SensorIdx"
#define D_CMND_UPDATETIMER "UpdateTimer"
// Commands xdrv_ir_send.ino
// Commands xdrv_irremote.ino
#define D_CMND_IRSEND "IRSend"
#define D_CMND_IRHVAC "IRHVAC"
// Commands xdrv_snfbridge.ino
#define D_CMND_RFCODE "RfCode"
#define D_CMND_RFHIGH "RfHigh"
#define D_CMND_RFHOST "RfHost"
#define D_CMND_RFKEY "RfKey"
#define D_CMND_RFLOW "RfLow"
#define D_CMND_RFSYNC "RfSync"
// Commands xdrv_snfled.ino
// Commands xdrv_light.ino
#define D_CMND_COLOR "Color"
#define D_CMND_COLORTEMPERATURE "CT"
#define D_CMND_DIMMER "Dimmer"
@ -669,7 +661,15 @@
#define D_CMND_WAKEUPDURATION "WakeUpDuration"
#define D_CMND_WIDTH "Width"
// Commands xsns_hlw8012.ino
// Commands xdrv_snfbridge.ino
#define D_CMND_RFCODE "RfCode"
#define D_CMND_RFHIGH "RfHigh"
#define D_CMND_RFHOST "RfHost"
#define D_CMND_RFKEY "RfKey"
#define D_CMND_RFLOW "RfLow"
#define D_CMND_RFSYNC "RfSync"
// Commands xsns_03_hlw8012.ino
#define D_CMND_POWERLOW "PowerLow"
#define D_CMND_POWERHIGH "PowerHigh"
#define D_CMND_VOLTAGELOW "VoltageLow"

View File

@ -384,7 +384,7 @@
#define D_DOMOTICZ_CURRENT "Stroom"
#define D_DOMOTICZ_UPDATE_TIMER "Bijwerk timer"
// xdrv_ir-send.ino
// xdrv_irremote.ino
#define D_INVALID_JSON "Ongeldig JSON"
#define D_PROTOCOL_NOT_SUPPORTED "Protocol wordt niet ondersteund"
#define D_IR_PROTOCOL "PROTOCOL"
@ -427,18 +427,7 @@
#define D_HUE_POST_ARGS "Hue POST argumenten"
#define D_3_RESPONSE_PACKETS_SENT "3 antwoord paketten verstuurd"
// xsns_dht.ino
#define D_TIMEOUT_WAITING_FOR "Te lang wachten op"
#define D_START_SIGNAL_LOW "laag start signaal"
#define D_START_SIGNAL_HIGH "hoog start signaal"
#define D_PULSE "signaal"
#define D_CHECKSUM_FAILURE "Controle mislukt"
// xsns_ds18b20.ino
#define D_SENSOR_BUSY "Sensor bezet"
#define D_SENSOR_CRC_ERROR "Sensor CRC fout"
// xsns_hlw8012.ino
// xsns_03_hlw8012.ino
#define D_MAXPOWERREACHED "MaxPowerReached"
#define D_MAXPOWERREACHEDRETRY "MaxPowerReachedRetry"
#define D_POWERMONITOR "PowerMonitor"
@ -448,7 +437,18 @@
#define D_ENERGY_YESTERDAY "Verbruik gisteren"
#define D_ENERGY_TOTAL "Verbruik totaal"
// xsns_sht1x.ino
// xsns_05_ds18b20.ino
#define D_SENSOR_BUSY "Sensor bezet"
#define D_SENSOR_CRC_ERROR "Sensor CRC fout"
// xsns_06_dht.ino
#define D_TIMEOUT_WAITING_FOR "Te lang wachten op"
#define D_START_SIGNAL_LOW "laag start signaal"
#define D_START_SIGNAL_HIGH "hoog start signaal"
#define D_PULSE "signaal"
#define D_CHECKSUM_FAILURE "Controle mislukt"
// xsns_07_sht1x.ino
#define D_SENSOR_DID_NOT_ACK_COMMAND "Geen opdracht ACK van sensor"
#define D_SHT1X_FOUND "SHT1X gevonden"
@ -643,19 +643,11 @@
#define D_CMND_SENSORIDX "SensorIdx"
#define D_CMND_UPDATETIMER "UpdateTimer"
// Commands xdrv_ir_send.ino
// Commands xdrv_irremote.ino
#define D_CMND_IRSEND "IRSend"
#define D_CMND_IRHVAC "IRHVAC"
// Commands xdrv_snfbridge.ino
#define D_CMND_RFCODE "RfCode"
#define D_CMND_RFHIGH "RfHigh"
#define D_CMND_RFHOST "RfHost"
#define D_CMND_RFKEY "RfKey"
#define D_CMND_RFLOW "RfLow"
#define D_CMND_RFSYNC "RfSync"
// Commands xdrv_snfled.ino
// Commands xdrv_light.ino
#define D_CMND_COLOR "Color"
#define D_CMND_COLORTEMPERATURE "CT"
#define D_CMND_DIMMER "Dimmer"
@ -669,7 +661,15 @@
#define D_CMND_WAKEUPDURATION "WakeUpDuration"
#define D_CMND_WIDTH "Width"
// Commands xsns_hlw8012.ino
// Commands xdrv_snfbridge.ino
#define D_CMND_RFCODE "RfCode"
#define D_CMND_RFHIGH "RfHigh"
#define D_CMND_RFHOST "RfHost"
#define D_CMND_RFKEY "RfKey"
#define D_CMND_RFLOW "RfLow"
#define D_CMND_RFSYNC "RfSync"
// Commands xsns_03_hlw8012.ino
#define D_CMND_POWERLOW "PowerLow"
#define D_CMND_POWERHIGH "PowerHigh"
#define D_CMND_VOLTAGELOW "VoltageLow"

View File

@ -384,7 +384,7 @@
#define D_DOMOTICZ_CURRENT "Prad"
#define D_DOMOTICZ_UPDATE_TIMER "Zaktualizuj czasomierz"
// xdrv_ir-send.ino
// xdrv_irremote.ino
#define D_INVALID_JSON "Invalid JSON"
#define D_PROTOCOL_NOT_SUPPORTED "Protokol nie jest obslugiwany"
#define D_IR_PROTOCOL "PROTOCOL"
@ -427,18 +427,7 @@
#define D_HUE_POST_ARGS "Hue POST args"
#define D_3_RESPONSE_PACKETS_SENT "3 pakiety odpowiedzi wysylane"
// xsns_dht.ino
#define D_TIMEOUT_WAITING_FOR "Trwa oczekiwanie"
#define D_START_SIGNAL_LOW "sygnał startowy niski"
#define D_START_SIGNAL_HIGH "sygnał startowy wysoki"
#define D_PULSE "pulse"
#define D_CHECKSUM_FAILURE "Bledna suma kontrolmna"
// xsns_ds18b20.ino
#define D_SENSOR_BUSY "Czujnik DS18x20 zajety"
#define D_SENSOR_CRC_ERROR "Czujnik DS18x20 blad CRC"
// xsns_hlw8012.ino
// xsns_03_hlw8012.ino
#define D_MAXPOWERREACHED "MaksMocOsiagnieta"
#define D_MAXPOWERREACHEDRETRY "MaksMocOsiagnietaPonowienie"
#define D_POWERMONITOR "MonitorMocy"
@ -448,7 +437,18 @@
#define D_ENERGY_YESTERDAY "Energia Wczoraj"
#define D_ENERGY_TOTAL "Energia suma"
// xsns_sht1x.ino
// xsns_05_ds18b20.ino
#define D_SENSOR_BUSY "Czujnik DS18x20 zajety"
#define D_SENSOR_CRC_ERROR "Czujnik DS18x20 blad CRC"
// xsns_06_dht.ino
#define D_TIMEOUT_WAITING_FOR "Trwa oczekiwanie"
#define D_START_SIGNAL_LOW "sygnał startowy niski"
#define D_START_SIGNAL_HIGH "sygnał startowy wysoki"
#define D_PULSE "pulse"
#define D_CHECKSUM_FAILURE "Bledna suma kontrolmna"
// xsns_07_sht1x.ino
#define D_SENSOR_DID_NOT_ACK_COMMAND "Czujnik nie otrzymal komendy ACK"
#define D_SHT1X_FOUND "SHT1X znaleziony"
@ -643,19 +643,11 @@
#define D_CMND_SENSORIDX "SensorIdx"
#define D_CMND_UPDATETIMER "UpdateTimer"
// Commands xdrv_ir_send.ino
// Commands xdrv_irremote.ino
#define D_CMND_IRSEND "IRSend"
#define D_CMND_IRHVAC "IRHVAC"
// Commands xdrv_snfbridge.ino
#define D_CMND_RFCODE "RfCode"
#define D_CMND_RFHIGH "RfHigh"
#define D_CMND_RFHOST "RfHost"
#define D_CMND_RFKEY "RfKey"
#define D_CMND_RFLOW "RfLow"
#define D_CMND_RFSYNC "RfSync"
// Commands xdrv_snfled.ino
// Commands xdrv_light.ino
#define D_CMND_COLOR "Color"
#define D_CMND_COLORTEMPERATURE "CT"
#define D_CMND_DIMMER "Dimmer"
@ -669,7 +661,15 @@
#define D_CMND_WAKEUPDURATION "WakeUpDuration"
#define D_CMND_WIDTH "Width"
// Commands xsns_hlw8012.ino
// Commands xdrv_snfbridge.ino
#define D_CMND_RFCODE "RfCode"
#define D_CMND_RFHIGH "RfHigh"
#define D_CMND_RFHOST "RfHost"
#define D_CMND_RFKEY "RfKey"
#define D_CMND_RFLOW "RfLow"
#define D_CMND_RFSYNC "RfSync"
// Commands xsns_03_hlw8012.ino
#define D_CMND_POWERLOW "PowerLow"
#define D_CMND_POWERHIGH "PowerHigh"
#define D_CMND_VOLTAGELOW "VoltageLow"

View File

@ -92,6 +92,12 @@ typedef unsigned long power_t; // Power (Relay) type
#define XSNS_MAX 20 // Max number of allowed Xsns External Sensors (Update xsns_interface.ino if changed)
/*
// Removed from esp8266 core since 20171105
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
*/
/*********************************************************************************************\
* Enumeration
\*********************************************************************************************/

View File

@ -25,7 +25,7 @@
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
====================================================*/
#define VERSION 0x05090104 // 5.9.1d
#define VERSION 0x05090105 // 5.9.1e
// Location specific includes
#include "sonoff.h" // Enumaration used in user_config.h

View File

@ -45,7 +45,7 @@ void OsWatchTicker()
AddLog(LOG_LEVEL_DEBUG);
#endif // DEBUG_THEO
if (last_run >= (OSWATCH_RESET_TIME * 1000)) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_OSWATCH " " D_BLOCKED_LOOP ". " D_RESTARTING));
// AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_OSWATCH " " D_BLOCKED_LOOP ". " D_RESTARTING)); // Save iram space
RtcSettings.oswatch_blocked_loop = 1;
RtcSettingsSave();
// ESP.restart(); // normal reboot

View File

@ -120,7 +120,7 @@ const char HTTP_SCRIPT_CONSOL[] PROGMEM =
"id=d.getElementsByTagName('i')[0].childNodes[0].nodeValue;"
"if(d.getElementsByTagName('j')[0].childNodes[0].nodeValue==0){t.value='';}"
"z=d.getElementsByTagName('l')[0].childNodes;"
"if(z.length>0){t.value+=z[0].nodeValue;}"
"if(z.length>0){t.value+=decodeURIComponent(z[0].nodeValue);}"
"t.scrollTop=99999;"
"sn=t.scrollTop;"
"}"
@ -1439,7 +1439,11 @@ void HandleAjaxConsoleRefresh()
} else {
cflg = 1;
}
message += web_log[counter];
String nextline = web_log[counter];
nextline.replace(F("<"), F("%3C")); // XML encoding to fix blank console log in concert with javascript decodeURIComponent
nextline.replace(F(">"), F("%3E"));
nextline.replace(F("&"), F("%26"));
message += nextline;
}
counter++;
if (counter > MAX_LOG_LINES -1) {

View File

@ -102,6 +102,8 @@ uint8_t light_wakeup_active = 0;
uint8_t light_wakeup_dimmer = 0;
uint16_t light_wakeup_counter = 0;
uint8_t light_fixed_color_index = 1;
unsigned long strip_timer_counter = 0; // Bars and Gradient
#ifdef USE_ARILUX_RF
@ -116,19 +118,19 @@ unsigned long strip_timer_counter = 0; // Bars and Gradient
#define ARILUX_RF_RECEIVE_TOLERANCE 60 // Percentage
unsigned int arilux_rf_timings[ARILUX_RF_MAX_CHANGES];
unsigned long arilux_rf_received_value = 0;
unsigned long arilux_rf_lasttime = 0;
unsigned int arilux_rf_change_count = 0;
unsigned int arilux_rf_repeat_count = 0;
unsigned long arilux_rf_last_received_value = 0;
unsigned long arilux_rf_last_time = 0;
unsigned long arilux_rf_lasttime = 0;
unsigned int arilux_rf_change_count = 0;
unsigned int arilux_rf_repeat_count = 0;
uint8_t arilux_rf_toggle = 0;
#ifndef USE_WS2812_DMA // Collides with Neopixelbus but solves RF misses
void AriluxRfInterrupt() ICACHE_RAM_ATTR;
//void AriluxRfInterrupt() ICACHE_RAM_ATTR; // As iram is tight and it works this way too
#endif // USE_WS2812_DMA
void AriluxRfInterrupt()
@ -143,20 +145,13 @@ void AriluxRfInterrupt()
unsigned long code = 0;
const unsigned int delay = arilux_rf_timings[0] / 31;
const unsigned int delayTolerance = delay * ARILUX_RF_RECEIVE_TOLERANCE / 100;
for (unsigned int i = 1; i < arilux_rf_change_count -1; i += 2) {
code <<= 1;
if (abs(arilux_rf_timings[i] - delay) < delayTolerance && abs(arilux_rf_timings[i + 1] - (delay * 3)) < delayTolerance) {
// zero
} else if (abs(arilux_rf_timings[i] - (delay * 3)) < delayTolerance && abs(arilux_rf_timings[i + 1] - delay) < delayTolerance) {
// one
if (abs(arilux_rf_timings[i] - (delay *3)) < delayTolerance && abs(arilux_rf_timings[i +1] - delay) < delayTolerance) {
code |= 1;
} else {
// Failed
}
}
if (arilux_rf_change_count > 7) { // ignore very short transmissions: no device sends them, so this must be noise
// if (arilux_rf_change_count > 48) { // ignore very short transmissions: no device sends them, so this must be noise
if (arilux_rf_change_count > 49) { // Need 1 sync bit and 24 data bits
arilux_rf_received_value = code;
}
arilux_rf_repeat_count = 0;
@ -164,22 +159,16 @@ void AriluxRfInterrupt()
}
arilux_rf_change_count = 0;
}
// detect overflow
if (arilux_rf_change_count >= ARILUX_RF_MAX_CHANGES) {
arilux_rf_change_count = 0;
arilux_rf_repeat_count = 0;
}
arilux_rf_timings[arilux_rf_change_count++] = duration;
arilux_rf_lasttime = time;
}
void AriluxRfHandler()
{
char command[16];
char value = '-';
unsigned long now = millis();
if (arilux_rf_received_value && !((arilux_rf_received_value == arilux_rf_last_received_value) && (now - arilux_rf_last_time < ARILUX_RF_TIME_AVOID_DUPLICATE))) {
arilux_rf_last_received_value = arilux_rf_received_value;
@ -191,11 +180,13 @@ void AriluxRfHandler()
Settings.rf_code[1][7] = hostcode & 0xFF;
}
uint16_t stored_hostcode = Settings.rf_code[1][6] << 8 | Settings.rf_code[1][7];
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_RFR D_HOST D_CODE " 0x%04X, " D_RECEIVED " 0x%06X"), stored_hostcode, arilux_rf_received_value);
AddLog(LOG_LEVEL_DEBUG);
if (hostcode == stored_hostcode) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_RFR D_RECEIVED " 0x%06X"), arilux_rf_received_value);
AddLog(LOG_LEVEL_DEBUG);
char command[16];
char value = '-';
command[0] = '\0';
uint8_t keycode = arilux_rf_received_value & 0xFF;
switch (keycode) {
@ -898,12 +889,25 @@ boolean LightColorEntry(char *buffer, uint8_t buffer_length)
char *p;
char *str;
uint8_t entry_type = 0; // Invalid
uint8_t value = light_fixed_color_index;
if (buffer[0] == '#') { // Optional hexadecimal entry
buffer++;
buffer_length--;
}
uint8_t value = atoi(buffer);
if (light_subtype >= LST_RGB) {
char option = (1 == buffer_length) ? buffer[0] : '\0';
if (('+' == option) && (light_fixed_color_index < MAX_FIXED_COLOR)) {
value++;
}
else if (('-' == option) && (light_fixed_color_index > 1)) {
value--;
} else {
value = atoi(buffer);
}
}
memset(&light_entry_color, 0x00, sizeof(light_entry_color));
if (strstr(buffer, ",")) { // Decimal entry
int8_t i = 0;
@ -921,13 +925,20 @@ boolean LightColorEntry(char *buffer, uint8_t buffer_length)
}
entry_type = 1; // Hexadecimal
}
else if ((value > 0) && (value <= MAX_FIXED_COLOR)) {
else if ((light_subtype >= LST_RGB) && (value > 0) && (value <= MAX_FIXED_COLOR)) {
light_fixed_color_index = value;
memcpy_P(&light_entry_color, &kFixedColor[value -1], 3);
entry_type = 1; // Hexadecimal
}
else if ((value > 199) && (value <= 199 + MAX_FIXED_COLD_WARM)) {
memcpy_P(&light_entry_color[3], &kFixedColdWarm[value -200], 2);
entry_type = 1; // Hexadecimal
if (LST_COLDWARM == light_subtype) {
memcpy_P(&light_entry_color, &kFixedColdWarm[value -200], 2);
entry_type = 1; // Hexadecimal
}
else if (LST_RGBWC == light_subtype) {
memcpy_P(&light_entry_color[3], &kFixedColdWarm[value -200], 2);
entry_type = 1; // Hexadecimal
}
}
if (entry_type) {
Settings.flag.decimal_text = entry_type -1;
@ -1036,7 +1047,16 @@ boolean LightCommand(char *type, uint16_t index, char *dataBuf, uint16_t data_le
LightPowerOn();
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_STARTED);
}
else if ((CMND_COLORTEMPERATURE == command_code) && ((2 == light_subtype) || (5 == light_subtype))) { // ColorTemp
else if ((CMND_COLORTEMPERATURE == command_code) && ((LST_COLDWARM == light_subtype) || (LST_RGBWC == light_subtype))) { // ColorTemp
if (option != '\0') {
uint16_t value = LightGetColorTemp();
if ('+' == option) {
payload = (value > 466) ? 500 : value + 34;
}
else if ('-' == option) {
payload = (value < 187) ? 153 : value - 34;
}
}
if ((payload >= 153) && (payload <= 500)) { // https://developers.meethue.com/documentation/core-concepts
LightSetColorTemp(payload);
coldim = true;

View File

@ -34,6 +34,14 @@ uint8_t sonoff_bridge_learn_active = 0;
uint32_t sonoff_bridge_last_received_id = 0;
uint32_t sonoff_bridge_last_send_code = 0;
unsigned long sonoff_bridge_last_time = 0;
unsigned long sonoff_bridge_last_learn_time = 0;
void SonoffBridgeLearnFailed()
{
sonoff_bridge_learn_active = 0;
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_SVALUE, D_CMND_RFKEY, sonoff_bridge_learn_key, D_LEARN_FAILED);
MqttPublishPrefixTopic_P(5, PSTR(D_CMND_RFKEY));
}
void SonoffBridgeReceived()
{
@ -52,9 +60,7 @@ void SonoffBridgeReceived()
AddLog(LOG_LEVEL_DEBUG);
if (0xA2 == serial_in_buffer[0]) { // Learn timeout
sonoff_bridge_learn_active = 0;
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_SVALUE, D_CMND_RFKEY, sonoff_bridge_learn_key, D_LEARN_FAILED);
MqttPublishPrefixTopic_P(5, PSTR(D_CMND_RFKEY));
SonoffBridgeLearnFailed();
}
else if (0xA3 == serial_in_buffer[0]) { // Learned A3 20 F8 01 18 03 3E 2E 1A 22 55
sonoff_bridge_learn_active = 0;
@ -65,37 +71,41 @@ void SonoffBridgeReceived()
Settings.rf_code[sonoff_bridge_learn_key][i] = serial_in_buffer[i +1];
}
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_SVALUE, D_CMND_RFKEY, sonoff_bridge_learn_key, D_LEARNED);
MqttPublishPrefixTopic_P(5, PSTR(D_CMND_RFKEY));
} else {
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_SVALUE, D_CMND_RFKEY, sonoff_bridge_learn_key, D_LEARN_FAILED);
SonoffBridgeLearnFailed();
}
MqttPublishPrefixTopic_P(5, PSTR(D_CMND_RFKEY));
}
else if (0xA4 == serial_in_buffer[0]) { // Received RF data A4 20 EE 01 18 03 3E 2E 1A 22 55
sync_time = serial_in_buffer[1] << 8 | serial_in_buffer[2]; // Sync time in uSec
low_time = serial_in_buffer[3] << 8 | serial_in_buffer[4]; // Low time in uSec
high_time = serial_in_buffer[5] << 8 | serial_in_buffer[6]; // High time in uSec
received_id = serial_in_buffer[7] << 16 | serial_in_buffer[8] << 8 | serial_in_buffer[9];
if (sonoff_bridge_learn_active) {
SonoffBridgeLearnFailed();
} else {
sync_time = serial_in_buffer[1] << 8 | serial_in_buffer[2]; // Sync time in uSec
low_time = serial_in_buffer[3] << 8 | serial_in_buffer[4]; // Low time in uSec
high_time = serial_in_buffer[5] << 8 | serial_in_buffer[6]; // High time in uSec
received_id = serial_in_buffer[7] << 16 | serial_in_buffer[8] << 8 | serial_in_buffer[9];
unsigned long now = millis();
if (!((received_id == sonoff_bridge_last_received_id) && (now - sonoff_bridge_last_time < SFB_TIME_AVOID_DUPLICATE))) {
sonoff_bridge_last_received_id = received_id;
sonoff_bridge_last_time = now;
strncpy_P(rfkey, PSTR("\"" D_NONE "\""), sizeof(rfkey));
for (byte i = 1; i <= 16; i++) {
if (Settings.rf_code[i][0]) {
uint32_t send_id = Settings.rf_code[i][6] << 16 | Settings.rf_code[i][7] << 8 | Settings.rf_code[i][8];
if (send_id == received_id) {
snprintf_P(rfkey, sizeof(rfkey), PSTR("%d"), i);
break;
unsigned long now = millis();
if (!((received_id == sonoff_bridge_last_received_id) && (now - sonoff_bridge_last_time < SFB_TIME_AVOID_DUPLICATE))) {
sonoff_bridge_last_received_id = received_id;
sonoff_bridge_last_time = now;
strncpy_P(rfkey, PSTR("\"" D_NONE "\""), sizeof(rfkey));
for (byte i = 1; i <= 16; i++) {
if (Settings.rf_code[i][0]) {
uint32_t send_id = Settings.rf_code[i][6] << 16 | Settings.rf_code[i][7] << 8 | Settings.rf_code[i][8];
if (send_id == received_id) {
snprintf_P(rfkey, sizeof(rfkey), PSTR("%d"), i);
break;
}
}
}
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_RFRECEIVED "\":{\"" D_SYNC "\":%d,\"" D_LOW "\":%d,\"" D_HIGH "\":%d,\"" D_DATA "\":\"%06X\",\"" D_CMND_RFKEY "\":%s}}"),
sync_time, low_time, high_time, received_id, rfkey);
MqttPublishPrefixTopic_P(6, PSTR(D_RFRECEIVED));
#ifdef USE_DOMOTICZ
DomoticzSensor(DZ_COUNT, received_id); // Send rid as Domoticz Counter value
#endif // USE_DOMOTICZ
}
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_RFRECEIVED "\":{\"" D_SYNC "\":%d,\"" D_LOW "\":%d,\"" D_HIGH "\":%d,\"" D_DATA "\":\"%06X\",\"" D_CMND_RFKEY "\":%s}}"),
sync_time, low_time, high_time, received_id, rfkey);
MqttPublishPrefixTopic_P(6, PSTR(D_RFRECEIVED));
#ifdef USE_DOMOTICZ
DomoticzSensor(DZ_COUNT, received_id); // Send rid as Domoticz Counter value
#endif // USE_DOMOTICZ
}
}
}
@ -170,6 +180,7 @@ void SonoffBridgeLearn(uint8_t key)
{
sonoff_bridge_learn_key = key;
sonoff_bridge_learn_active = 1;
sonoff_bridge_last_learn_time = millis();
Serial.write(0xAA); // Start of Text
Serial.write(0xA1); // Start learning
Serial.write(0x55); // End of Text
@ -231,7 +242,9 @@ boolean SonoffBridgeCommand(char *type, uint16_t index, char *dataBuf, uint16_t
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_XVALUE, command, stemp);
}
else if ((CMND_RFKEY == command_code) && (index > 0) && (index <= 16)) {
if (!sonoff_bridge_learn_active) {
unsigned long now = millis();
if ((!sonoff_bridge_learn_active) || (now - sonoff_bridge_last_learn_time > 60100)) {
sonoff_bridge_learn_active = 0;
if (2 == payload) { // Learn RF data
SonoffBridgeLearn(index);
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_SVALUE, command, index, D_START_LEARNING);