From d59d631e40a3223c64f69ed733f7e63c8a399d17 Mon Sep 17 00:00:00 2001
From: thirug010 <30732819+thirug010@users.noreply.github.com>
Date: Fri, 17 May 2019 22:03:53 -0500
Subject: [PATCH 01/11] New Tuya Serial Based Devices support
Updated the Code to support most of the new Tuya Serial devices like 4Gang Serail switch, 1 Dimmer + 1 relay, 3 Gang ...
---
platformio.ini | 38 ++++++++++++---------------------
sonoff/my_user_config.h | 14 ++++++------
sonoff/settings.h | 2 +-
sonoff/sonoff.ino | 2 ++
sonoff/xdrv_01_webserver.ino | 5 ++++-
sonoff/xdrv_16_tuyadimmer.ino | 40 ++++++++++++++++++++++++-----------
tools/decode-config.py | 7 ++++++
7 files changed, 63 insertions(+), 45 deletions(-)
diff --git a/platformio.ini b/platformio.ini
index f721a496a..6efc00e30 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -11,7 +11,7 @@
src_dir = sonoff
; *** Uncomment one of the lines below to build/upload only one environment
-;env_default = sonoff
+env_default = sonoff
;env_default = sonoff-minimal
;env_default = sonoff-basic
;env_default = sonoff-classic
@@ -57,7 +57,7 @@ platform = espressif8266@1.8.0
build_flags = ${esp82xx_defaults.build_flags}
-Wl,-Teagle.flash.1m0.ld
-lstdc++ -lsupc++
-; lwIP 1.4
+; lwIP 1.4 (Default)
; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
; lwIP 2 - Low Memory
; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
@@ -65,19 +65,12 @@ build_flags = ${esp82xx_defaults.build_flags}
-DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
-DVTABLES_IN_FLASH
-[core_2_5_1]
-; *** Esp8266 core for Arduino version 2.5.1
-platform = espressif8266@~2.1.1
+[core_2_5_0]
+; *** Esp8266 core for Arduino version 2.5.0
+platform = espressif8266@2.0.1
build_flags = ${esp82xx_defaults.build_flags}
-Wl,-Teagle.flash.1m.ld
-; Code optimization see https://github.com/esp8266/Arduino/issues/5790#issuecomment-475672473
- -O2
- -DBEARSSL_SSL_BASIC
-; nonos-sdk 22x
- -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x
-; nonos-sdk-pre-v3
-; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3
-; lwIP 1.4
+; lwIP 1.4 (Default)
; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
; lwIP 2 - Low Memory
; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
@@ -96,14 +89,11 @@ build_flags = ${esp82xx_defaults.build_flags}
platform = https://github.com/platformio/platform-espressif8266.git#feature/stage
build_flags = ${esp82xx_defaults.build_flags}
-Wl,-Teagle.flash.1m.ld
-; Code optimization see https://github.com/esp8266/Arduino/issues/5790#issuecomment-475672473
- -O2
- -DBEARSSL_SSL_BASIC
; nonos-sdk 22x
-DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x
; nonos-sdk-pre-v3
-; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3
-; lwIP 1.4
+; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3
+; lwIP 1.4 (Default)
; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
; lwIP 2 - Low Memory
; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
@@ -129,12 +119,12 @@ build_flags = ${esp82xx_defaults.build_flags}
[core_active]
; Select one core set for platform and build_flags
-;platform = ${core_2_3_0.platform}
-;build_flags = ${core_2_3_0.build_flags}
+platform = ${core_2_3_0.platform}
+build_flags = ${core_2_3_0.build_flags}
;platform = ${core_2_4_2.platform}
;build_flags = ${core_2_4_2.build_flags}
-platform = ${core_2_5_1.platform}
-build_flags = ${core_2_5_1.build_flags}
+;platform = ${core_2_5_0.platform}
+;build_flags = ${core_2_5_0.build_flags}
;platform = ${core_stage.platform}
;build_flags = ${core_stage.build_flags}
@@ -165,7 +155,7 @@ upload_speed = 115200
upload_resetmethod = nodemcu
; *** Upload Serial reset method for Wemos and NodeMCU
-upload_port = COM5
+upload_port = COM4
extra_scripts = pio/strip-floats.py
; *** Upload file to OTA server using SCP
@@ -353,7 +343,7 @@ board = ${common.board}
board_build.flash_mode = ${common.board_build.flash_mode}
board_build.f_cpu = ${common.board_build.f_cpu}
build_unflags = ${common.build_unflags}
-build_flags = ${common.build_flags} -DMY_LANGUAGE=es-ES
+build_flags = ${common.build_flags} -DMY_LANGUAGE=es-AR
monitor_speed = ${common.monitor_speed}
upload_port = ${common.upload_port}
upload_resetmethod = ${common.upload_resetmethod}
diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h
index 945261e1c..f9081e881 100644
--- a/sonoff/my_user_config.h
+++ b/sonoff/my_user_config.h
@@ -62,10 +62,10 @@
#define WIFI_SUBNETMASK "255.255.255.0" // [IpAddress3] If not using DHCP set Network mask
#define WIFI_DNS "192.168.1.1" // [IpAddress4] If not using DHCP set DNS IP address (might be equal to WIFI_GATEWAY)
-#define STA_SSID1 "" // [Ssid1] Wifi SSID
-#define STA_PASS1 "" // [Password1] Wifi password
-#define STA_SSID2 "" // [Ssid2] Optional alternate AP Wifi SSID
-#define STA_PASS2 "" // [Password2] Optional alternate AP Wifi password
+#define STA_SSID1 "H-Net-2G_SHD" // [Ssid1] Wifi SSID
+#define STA_PASS1 "abcd1234" // [Password1] Wifi password
+#define STA_SSID2 "H-Net-2G" // [Ssid2] Optional alternate AP Wifi SSID
+#define STA_PASS2 "abcd1234" // [Password2] Optional alternate AP Wifi password
#define WIFI_CONFIG_TOOL WIFI_RETRY // [WifiConfig] Default tool if wifi fails to connect
// (WIFI_RESTART, WIFI_SMARTCONFIG, WIFI_MANAGER, WIFI_WPSCONFIG, WIFI_RETRY, WIFI_WAIT, WIFI_SERIAL)
#define WIFI_CONFIG_NO_SSID WIFI_WPSCONFIG // Default tool if wifi fails to connect and no SSID is configured
@@ -87,12 +87,12 @@
// -- MQTT ----------------------------------------
#define MQTT_USE 1 // [SetOption3] Select default MQTT use (0 = Off, 1 = On)
-#define MQTT_HOST "" // [MqttHost]
+#define MQTT_HOST "192.168.1.10" // [MqttHost]
#define MQTT_FINGERPRINT1 "A5 02 FF 13 99 9F 8B 39 8E F1 83 4F 11 23 65 0B 32 36 FC 07" // [MqttFingerprint1]
#define MQTT_FINGERPRINT2 "A5 02 FF 13 99 9F 8B 39 8E F1 83 4F 11 23 65 0B 32 36 FC 07" // [MqttFingerprint2]
#define MQTT_PORT 1883 // [MqttPort] MQTT port (10123 on CloudMQTT)
-#define MQTT_USER "DVES_USER" // [MqttUser] MQTT user
-#define MQTT_PASS "DVES_PASS" // [MqttPassword] MQTT password
+#define MQTT_USER "shd_mqtt_user" // [MqttUser] MQTT user
+#define MQTT_PASS "abcd1234" // [MqttPassword] MQTT password
#define MQTT_BUTTON_RETAIN 0 // [ButtonRetain] Button may send retain flag (0 = off, 1 = on)
#define MQTT_POWER_RETAIN 0 // [PowerRetain] Power status message may send retain flag (0 = off, 1 = on)
diff --git a/sonoff/settings.h b/sonoff/settings.h
index c08c3e041..185880a00 100644
--- a/sonoff/settings.h
+++ b/sonoff/settings.h
@@ -78,7 +78,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t no_hold_retain : 1; // bit 12 (v6.4.1.19) - SetOption62 - Don't use retain flag on HOLD messages
uint32_t no_power_feedback : 1; // bit 13 (v6.5.0.9) - SetOption63 - Don't scan relay power state at restart
uint32_t use_underscore : 1; // bit 14 (v6.5.0.12) - SetOption64 - Enable "_" instead of "-" as sensor index separator
- uint32_t spare15 : 1;
+ uint32_t tuya_show_dimmer : 1; // bit 15 (v6.5.0.12) - SetOption65 - Enable or Disable Dimmer slider control
uint32_t spare16 : 1;
uint32_t spare17 : 1;
uint32_t spare18 : 1;
diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino
index 6e1260c78..d58955234 100755
--- a/sonoff/sonoff.ino
+++ b/sonoff/sonoff.ino
@@ -1535,6 +1535,8 @@ void ExecuteCommandPower(uint8_t device, uint8_t state, int source)
// ShowSource(source);
+ XdrvMailbox.notused = device;
+
if (SONOFF_IFAN02 == my_module_type) {
blink_mask &= 1; // No blinking on the fan relays
Settings.flag.interlock = 0; // No interlock mode as it is already done by the microcontroller
diff --git a/sonoff/xdrv_01_webserver.ino b/sonoff/xdrv_01_webserver.ino
index dfbce53ba..0b33152a6 100644
--- a/sonoff/xdrv_01_webserver.ino
+++ b/sonoff/xdrv_01_webserver.ino
@@ -890,7 +890,10 @@ void HandleRoot(void)
if ((LST_COLDWARM == (light_type &7)) || (LST_RGBWC == (light_type &7))) {
WSContentSend_P(HTTP_MSG_SLIDER1, LightGetColorTemp());
}
- WSContentSend_P(HTTP_MSG_SLIDER2, Settings.light_dimmer);
+ if(Settings.flag3.tuya_show_dimmer == 1)
+ {
+ WSContentSend_P(HTTP_MSG_SLIDER2, Settings.light_dimmer);
+ }
}
WSContentSend_P(HTTP_TABLE100);
WSContentSend_P(PSTR("
"));
diff --git a/sonoff/xdrv_16_tuyadimmer.ino b/sonoff/xdrv_16_tuyadimmer.ino
index ffb44adab..5e883b12c 100644
--- a/sonoff/xdrv_16_tuyadimmer.ino
+++ b/sonoff/xdrv_16_tuyadimmer.ino
@@ -123,16 +123,26 @@ bool TuyaSetPower(void)
int16_t source = XdrvMailbox.payload;
if (source != SRC_SWITCH && TuyaSerial) { // ignore to prevent loop from pushing state from faceplate interaction
-
- AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: SetDevicePower.rpower=%d"), rpower);
-
- TuyaSendBool(TUYA_POWER_ID, rpower);
+ boolean Bin[] = {0,0,0,0};
+ convertDecToBin(rpower, Bin);
+ TuyaSendBool(XdrvMailbox.notused, Bin[XdrvMailbox.notused-1]);
status = true;
}
return status;
}
+void convertDecToBin(int Dec, boolean Bin[]) {
+ for(int i = 3 ; i >= 0 ; i--) {
+ if(pow(2, i)<=Dec) {
+ Dec = Dec - pow(2, i);
+ Bin[(i)] = 1;
+ } else {
+ }
+ }
+}
+
+
bool TuyaSetChannels(void)
{
LightSerialDuty(((uint8_t*)XdrvMailbox.data)[0]);
@@ -146,14 +156,19 @@ void LightSerialDuty(uint8_t duty)
duty = 25; // dimming acts odd below 25(10%) - this mirrors the threshold set on the faceplate itself
}
- AddLog_P2(LOG_LEVEL_DEBUG, PSTR( "TYA: Send Serial Packet Dim Value=%d (id=%d)"), duty, Settings.param[P_TUYA_DIMMER_ID]);
-
- TuyaSendValue(Settings.param[P_TUYA_DIMMER_ID], duty);
+
+ if(Settings.flag3.tuya_show_dimmer == 1) // no Dimmer for 4 relay
+ {
+ AddLog_P2(LOG_LEVEL_DEBUG, PSTR( "TYA: Send Serial Packet Dim Value=%d (id=%d)"), duty, Settings.param[P_TUYA_DIMMER_ID]);
+ TuyaSendValue(Settings.param[P_TUYA_DIMMER_ID], duty);
+ }
} else {
tuya_ignore_dim = false; // reset flag
-
+ if(Settings.flag3.tuya_show_dimmer == 1) // no Dimmer for 4 relay
+ {
AddLog_P2(LOG_LEVEL_DEBUG, PSTR( "TYA: Send Dim Level skipped due to 0 or already set. Value=%d"), duty);
+ }
}
}
@@ -194,11 +209,11 @@ void TuyaPacketProcess(void)
case TUYA_CMD_STATE:
if (tuya_buffer[5] == 5) { // on/off packet
- AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: RX - %s State"),tuya_buffer[10]?"On":"Off");
-
- if((power || Settings.light_dimmer > 0) && (power != tuya_buffer[10])) {
+ AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: RX Device -%d --> %s State"),tuya_buffer[6],tuya_buffer[10]?"On":"Off");
+ ExecuteCommandPower(tuya_buffer[6], tuya_buffer[10], SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction
+ /*if((power || Settings.light_dimmer > 0) && (power != tuya_buffer[10])) {
ExecuteCommandPower(1, tuya_buffer[10], SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction
- }
+ }*/
}
else if (tuya_buffer[5] == 8) { // dim packet
@@ -281,6 +296,7 @@ bool TuyaModuleSelected(void)
void TuyaInit(void)
{
+ devices_present = Settings.param[6] == 0 ? 1 : Settings.param[6];
if (!Settings.param[P_TUYA_DIMMER_ID]) {
Settings.param[P_TUYA_DIMMER_ID] = TUYA_DIMMER_ID;
}
diff --git a/tools/decode-config.py b/tools/decode-config.py
index d05b8ff49..b2ea6f5d9 100755
--- a/tools/decode-config.py
+++ b/tools/decode-config.py
@@ -903,7 +903,14 @@ Setting_6_5_0_9['flag3'][0].update ({
'no_power_feedback': ('
Date: Fri, 17 May 2019 22:13:04 -0500
Subject: [PATCH 02/11] Update _changelog.ino
---
sonoff/_changelog.ino | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino
index 0071e38d1..08bf234da 100644
--- a/sonoff/_changelog.ino
+++ b/sonoff/_changelog.ino
@@ -1,4 +1,9 @@
-/* 6.5.0.11 20190517
+/* 6.5.0.12 20190517
+ * Add command SetOption65 (tuya_show_dimmer) to enable or disable dimmer Slider ( for 4 Gang Tuya switch)
+ * Added Seeting.pram9 to define no of Tuya MCU devices
+ * Updated xdrv_01_webserver.ino to check for the tuya_show_dimmer option to display slider2
+ * Updated xdrv_16_tuyadimmer.ino create bool serial packet based on the Device Id and set the power status based on the Device id from MCU packet
+ * 6.5.0.11 20190517
* Add command SetOption64 0/1 to switch between "-" or "_" as sensor index separator impacting DS18X20, DHT, BMP and SHT3X sensor names (#5689)
*
* 6.5.0.10 20190513
From fce9ae676287aab6026aab9002234564baeb46b7 Mon Sep 17 00:00:00 2001
From: thirug010 <30732819+thirug010@users.noreply.github.com>
Date: Fri, 17 May 2019 23:50:41 -0500
Subject: [PATCH 03/11] Revert Platformio.ini and user config for PR merge
Revert Platformio.ini and user config for PR merge
---
platformio.ini | 40 +++++++++++++++++++++++++---------------
sonoff/my_user_config.h | 16 ++++++++--------
2 files changed, 33 insertions(+), 23 deletions(-)
diff --git a/platformio.ini b/platformio.ini
index 6efc00e30..57dbddc59 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -11,7 +11,7 @@
src_dir = sonoff
; *** Uncomment one of the lines below to build/upload only one environment
-env_default = sonoff
+;env_default = sonoff
;env_default = sonoff-minimal
;env_default = sonoff-basic
;env_default = sonoff-classic
@@ -57,7 +57,7 @@ platform = espressif8266@1.8.0
build_flags = ${esp82xx_defaults.build_flags}
-Wl,-Teagle.flash.1m0.ld
-lstdc++ -lsupc++
-; lwIP 1.4 (Default)
+; lwIP 1.4
; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
; lwIP 2 - Low Memory
; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
@@ -65,12 +65,19 @@ build_flags = ${esp82xx_defaults.build_flags}
-DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
-DVTABLES_IN_FLASH
-[core_2_5_0]
-; *** Esp8266 core for Arduino version 2.5.0
-platform = espressif8266@2.0.1
+[core_2_5_1]
+; *** Esp8266 core for Arduino version 2.5.1
+platform = espressif8266@~2.1.1
build_flags = ${esp82xx_defaults.build_flags}
-Wl,-Teagle.flash.1m.ld
-; lwIP 1.4 (Default)
+; Code optimization see https://github.com/esp8266/Arduino/issues/5790#issuecomment-475672473
+ -O2
+ -DBEARSSL_SSL_BASIC
+; nonos-sdk 22x
+ -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x
+; nonos-sdk-pre-v3
+; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3
+; lwIP 1.4
; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
; lwIP 2 - Low Memory
; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
@@ -89,11 +96,14 @@ build_flags = ${esp82xx_defaults.build_flags}
platform = https://github.com/platformio/platform-espressif8266.git#feature/stage
build_flags = ${esp82xx_defaults.build_flags}
-Wl,-Teagle.flash.1m.ld
+; Code optimization see https://github.com/esp8266/Arduino/issues/5790#issuecomment-475672473
+ -O2
+ -DBEARSSL_SSL_BASIC
; nonos-sdk 22x
-DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x
; nonos-sdk-pre-v3
-; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3
-; lwIP 1.4 (Default)
+; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3
+; lwIP 1.4
; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
; lwIP 2 - Low Memory
; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
@@ -119,12 +129,12 @@ build_flags = ${esp82xx_defaults.build_flags}
[core_active]
; Select one core set for platform and build_flags
-platform = ${core_2_3_0.platform}
-build_flags = ${core_2_3_0.build_flags}
+;platform = ${core_2_3_0.platform}
+;build_flags = ${core_2_3_0.build_flags}
;platform = ${core_2_4_2.platform}
;build_flags = ${core_2_4_2.build_flags}
-;platform = ${core_2_5_0.platform}
-;build_flags = ${core_2_5_0.build_flags}
+platform = ${core_2_5_1.platform}
+build_flags = ${core_2_5_1.build_flags}
;platform = ${core_stage.platform}
;build_flags = ${core_stage.build_flags}
@@ -155,7 +165,7 @@ upload_speed = 115200
upload_resetmethod = nodemcu
; *** Upload Serial reset method for Wemos and NodeMCU
-upload_port = COM4
+upload_port = COM5
extra_scripts = pio/strip-floats.py
; *** Upload file to OTA server using SCP
@@ -343,7 +353,7 @@ board = ${common.board}
board_build.flash_mode = ${common.board_build.flash_mode}
board_build.f_cpu = ${common.board_build.f_cpu}
build_unflags = ${common.build_unflags}
-build_flags = ${common.build_flags} -DMY_LANGUAGE=es-AR
+build_flags = ${common.build_flags} -DMY_LANGUAGE=es-ES
monitor_speed = ${common.monitor_speed}
upload_port = ${common.upload_port}
upload_resetmethod = ${common.upload_resetmethod}
@@ -558,4 +568,4 @@ monitor_speed = ${common.monitor_speed}
upload_port = ${common.upload_port}
upload_resetmethod = ${common.upload_resetmethod}
upload_speed = ${common.upload_speed}
-extra_scripts = ${common.extra_scripts}
+extra_scripts = ${common.extra_scripts}
\ No newline at end of file
diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h
index f9081e881..16be53cac 100644
--- a/sonoff/my_user_config.h
+++ b/sonoff/my_user_config.h
@@ -62,10 +62,10 @@
#define WIFI_SUBNETMASK "255.255.255.0" // [IpAddress3] If not using DHCP set Network mask
#define WIFI_DNS "192.168.1.1" // [IpAddress4] If not using DHCP set DNS IP address (might be equal to WIFI_GATEWAY)
-#define STA_SSID1 "H-Net-2G_SHD" // [Ssid1] Wifi SSID
-#define STA_PASS1 "abcd1234" // [Password1] Wifi password
-#define STA_SSID2 "H-Net-2G" // [Ssid2] Optional alternate AP Wifi SSID
-#define STA_PASS2 "abcd1234" // [Password2] Optional alternate AP Wifi password
+#define STA_SSID1 "" // [Ssid1] Wifi SSID
+#define STA_PASS1 "" // [Password1] Wifi password
+#define STA_SSID2 "" // [Ssid2] Optional alternate AP Wifi SSID
+#define STA_PASS2 "" // [Password2] Optional alternate AP Wifi password
#define WIFI_CONFIG_TOOL WIFI_RETRY // [WifiConfig] Default tool if wifi fails to connect
// (WIFI_RESTART, WIFI_SMARTCONFIG, WIFI_MANAGER, WIFI_WPSCONFIG, WIFI_RETRY, WIFI_WAIT, WIFI_SERIAL)
#define WIFI_CONFIG_NO_SSID WIFI_WPSCONFIG // Default tool if wifi fails to connect and no SSID is configured
@@ -87,12 +87,12 @@
// -- MQTT ----------------------------------------
#define MQTT_USE 1 // [SetOption3] Select default MQTT use (0 = Off, 1 = On)
-#define MQTT_HOST "192.168.1.10" // [MqttHost]
+#define MQTT_HOST "" // [MqttHost]
#define MQTT_FINGERPRINT1 "A5 02 FF 13 99 9F 8B 39 8E F1 83 4F 11 23 65 0B 32 36 FC 07" // [MqttFingerprint1]
#define MQTT_FINGERPRINT2 "A5 02 FF 13 99 9F 8B 39 8E F1 83 4F 11 23 65 0B 32 36 FC 07" // [MqttFingerprint2]
#define MQTT_PORT 1883 // [MqttPort] MQTT port (10123 on CloudMQTT)
-#define MQTT_USER "shd_mqtt_user" // [MqttUser] MQTT user
-#define MQTT_PASS "abcd1234" // [MqttPassword] MQTT password
+#define MQTT_USER "DVES_USER" // [MqttUser] MQTT user
+#define MQTT_PASS "DVES_PASS" // [MqttPassword] MQTT password
#define MQTT_BUTTON_RETAIN 0 // [ButtonRetain] Button may send retain flag (0 = off, 1 = on)
#define MQTT_POWER_RETAIN 0 // [PowerRetain] Power status message may send retain flag (0 = off, 1 = on)
@@ -466,4 +466,4 @@
#error "Select either USE_MQTT_TLS or USE_WEBSERVER as there is just not enough memory to play with"
#endif
-#endif // _MY_USER_CONFIG_H_
+#endif // _MY_USER_CONFIG_H_
\ No newline at end of file
From 6b013144ab4a3ec939667015947da130d38fd4e4 Mon Sep 17 00:00:00 2001
From: thirug010 <30732819+thirug010@users.noreply.github.com>
Date: Sat, 18 May 2019 18:13:57 -0500
Subject: [PATCH 04/11] Updated the code based on the feedback
* Updated xdrv_01_webserver.ino to show dimmer slider2 by default for Tuya Dimmer Module
* Updated xdrv_16_tuyadimmer.ino remove the use of XdrvMailbox and removed the pow functions now the size for 6.5.0 build is 510kb
* updated sonoff.ino to hold current device id
---
sonoff/_changelog.ino | 11 +++++++++--
sonoff/sonoff.ino | 3 ++-
sonoff/xdrv_01_webserver.ino | 2 +-
sonoff/xdrv_16_tuyadimmer.ino | 29 +++++++++++++----------------
4 files changed, 25 insertions(+), 20 deletions(-)
diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino
index 08bf234da..7e2852ff8 100644
--- a/sonoff/_changelog.ino
+++ b/sonoff/_changelog.ino
@@ -1,8 +1,15 @@
-/* 6.5.0.12 20190517
+/*
+ * 6.5.0.13 20190518
+ * Updated xdrv_01_webserver.ino to show dimmer slider2 by default for Tuya Dimmer Module optionally disabled for non dimmers
+ * Updated xdrv_16_tuyadimmer.ino remove the use of XdrvMailbox and removed the pow functions
+ * updated sonoff.ino to hold current device id
+ *
+ * 6.5.0.12 20190517
* Add command SetOption65 (tuya_show_dimmer) to enable or disable dimmer Slider ( for 4 Gang Tuya switch)
* Added Seeting.pram9 to define no of Tuya MCU devices
- * Updated xdrv_01_webserver.ino to check for the tuya_show_dimmer option to display slider2
+ * Updated xdrv_01_webserver.ino to check for the tuya_show_dimmer option to display slider2
* Updated xdrv_16_tuyadimmer.ino create bool serial packet based on the Device Id and set the power status based on the Device id from MCU packet
+ *
* 6.5.0.11 20190517
* Add command SetOption64 0/1 to switch between "-" or "_" as sensor index separator impacting DS18X20, DHT, BMP and SHT3X sensor names (#5689)
*
diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino
index d58955234..d90c8ef68 100755
--- a/sonoff/sonoff.ino
+++ b/sonoff/sonoff.ino
@@ -109,6 +109,7 @@ unsigned long pulse_timer[MAX_PULSETIMERS] = { 0 }; // Power off timer
unsigned long blink_timer = 0; // Power cycle timer
unsigned long backlog_delay = 0; // Command backlog delay
power_t power = 0; // Current copy of Settings.power
+power_t deviceid = 1; // hold current deviceid
power_t blink_power; // Blink power state
power_t blink_mask = 0; // Blink relay active mask
power_t blink_powersave; // Blink start power save state
@@ -1535,7 +1536,7 @@ void ExecuteCommandPower(uint8_t device, uint8_t state, int source)
// ShowSource(source);
- XdrvMailbox.notused = device;
+ deviceid = device;
if (SONOFF_IFAN02 == my_module_type) {
blink_mask &= 1; // No blinking on the fan relays
diff --git a/sonoff/xdrv_01_webserver.ino b/sonoff/xdrv_01_webserver.ino
index 0b33152a6..f714169ab 100644
--- a/sonoff/xdrv_01_webserver.ino
+++ b/sonoff/xdrv_01_webserver.ino
@@ -890,7 +890,7 @@ void HandleRoot(void)
if ((LST_COLDWARM == (light_type &7)) || (LST_RGBWC == (light_type &7))) {
WSContentSend_P(HTTP_MSG_SLIDER1, LightGetColorTemp());
}
- if(Settings.flag3.tuya_show_dimmer == 1)
+ if(Settings.flag3.tuya_show_dimmer == 0)
{
WSContentSend_P(HTTP_MSG_SLIDER2, Settings.light_dimmer);
}
diff --git a/sonoff/xdrv_16_tuyadimmer.ino b/sonoff/xdrv_16_tuyadimmer.ino
index 5e883b12c..4b0ebfcd8 100644
--- a/sonoff/xdrv_16_tuyadimmer.ino
+++ b/sonoff/xdrv_16_tuyadimmer.ino
@@ -123,26 +123,23 @@ bool TuyaSetPower(void)
int16_t source = XdrvMailbox.payload;
if (source != SRC_SWITCH && TuyaSerial) { // ignore to prevent loop from pushing state from faceplate interaction
- boolean Bin[] = {0,0,0,0};
- convertDecToBin(rpower, Bin);
- TuyaSendBool(XdrvMailbox.notused, Bin[XdrvMailbox.notused-1]);
-
+ TuyaSendBool(deviceid, TuyaGetPower(rpower, deviceid));
status = true;
}
return status;
}
-void convertDecToBin(int Dec, boolean Bin[]) {
- for(int i = 3 ; i >= 0 ; i--) {
- if(pow(2, i)<=Dec) {
- Dec = Dec - pow(2, i);
- Bin[(i)] = 1;
- } else {
+uint8_t TuyaGetPower(uint8_t p, uint8_t d) {
+ uint8_t g = 0;
+ for(int i = 7 ; i >= 0 ; i--) {
+ g = p >> i;
+ //AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: --SetDevicePower3-- for Device = %d, Power=%d"),i, k&1);
+ if (i== d-1)
+ {
+ return g&1;
}
}
}
-
-
bool TuyaSetChannels(void)
{
LightSerialDuty(((uint8_t*)XdrvMailbox.data)[0]);
@@ -156,8 +153,8 @@ void LightSerialDuty(uint8_t duty)
duty = 25; // dimming acts odd below 25(10%) - this mirrors the threshold set on the faceplate itself
}
-
- if(Settings.flag3.tuya_show_dimmer == 1) // no Dimmer for 4 relay
+
+ if(Settings.flag3.tuya_show_dimmer == 0)
{
AddLog_P2(LOG_LEVEL_DEBUG, PSTR( "TYA: Send Serial Packet Dim Value=%d (id=%d)"), duty, Settings.param[P_TUYA_DIMMER_ID]);
TuyaSendValue(Settings.param[P_TUYA_DIMMER_ID], duty);
@@ -165,7 +162,7 @@ void LightSerialDuty(uint8_t duty)
} else {
tuya_ignore_dim = false; // reset flag
- if(Settings.flag3.tuya_show_dimmer == 1) // no Dimmer for 4 relay
+ if(Settings.flag3.tuya_show_dimmer == 0)
{
AddLog_P2(LOG_LEVEL_DEBUG, PSTR( "TYA: Send Dim Level skipped due to 0 or already set. Value=%d"), duty);
}
@@ -432,7 +429,7 @@ bool Xdrv16(uint8_t function)
if (tuya_heartbeat_timer > 10) {
tuya_heartbeat_timer = 0;
TuyaSendCmd(TUYA_CMD_HEARTBEAT);
- }
+ }
break;
case FUNC_SET_CHANNELS:
result = TuyaSetChannels();
From 7b71331cf67ccbf7092f88491dc1f998841d274c Mon Sep 17 00:00:00 2001
From: thirug010 <30732819+thirug010@users.noreply.github.com>
Date: Sun, 19 May 2019 09:44:34 -0500
Subject: [PATCH 05/11] Update xdrv_16_tuyadimmer.ino
Repalced TuyaGetPower() BitRead().
---
sonoff/xdrv_16_tuyadimmer.ino | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/sonoff/xdrv_16_tuyadimmer.ino b/sonoff/xdrv_16_tuyadimmer.ino
index 4b0ebfcd8..202674ac5 100644
--- a/sonoff/xdrv_16_tuyadimmer.ino
+++ b/sonoff/xdrv_16_tuyadimmer.ino
@@ -123,23 +123,12 @@ bool TuyaSetPower(void)
int16_t source = XdrvMailbox.payload;
if (source != SRC_SWITCH && TuyaSerial) { // ignore to prevent loop from pushing state from faceplate interaction
- TuyaSendBool(deviceid, TuyaGetPower(rpower, deviceid));
+ TuyaSendBool(deviceid, bitRead(rpower, deviceid-1));
status = true;
}
return status;
}
-uint8_t TuyaGetPower(uint8_t p, uint8_t d) {
- uint8_t g = 0;
- for(int i = 7 ; i >= 0 ; i--) {
- g = p >> i;
- //AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: --SetDevicePower3-- for Device = %d, Power=%d"),i, k&1);
- if (i== d-1)
- {
- return g&1;
- }
- }
-}
bool TuyaSetChannels(void)
{
LightSerialDuty(((uint8_t*)XdrvMailbox.data)[0]);
From 27dd98c539f8603acc9a3102918ece348f32d642 Mon Sep 17 00:00:00 2001
From: thirug010 <30732819+thirug010@users.noreply.github.com>
Date: Sun, 19 May 2019 09:46:44 -0500
Subject: [PATCH 06/11] Revert "Update xdrv_16_tuyadimmer.ino"
This reverts commit 7b71331cf67ccbf7092f88491dc1f998841d274c.
---
sonoff/xdrv_16_tuyadimmer.ino | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/sonoff/xdrv_16_tuyadimmer.ino b/sonoff/xdrv_16_tuyadimmer.ino
index 202674ac5..4b0ebfcd8 100644
--- a/sonoff/xdrv_16_tuyadimmer.ino
+++ b/sonoff/xdrv_16_tuyadimmer.ino
@@ -123,12 +123,23 @@ bool TuyaSetPower(void)
int16_t source = XdrvMailbox.payload;
if (source != SRC_SWITCH && TuyaSerial) { // ignore to prevent loop from pushing state from faceplate interaction
- TuyaSendBool(deviceid, bitRead(rpower, deviceid-1));
+ TuyaSendBool(deviceid, TuyaGetPower(rpower, deviceid));
status = true;
}
return status;
}
+uint8_t TuyaGetPower(uint8_t p, uint8_t d) {
+ uint8_t g = 0;
+ for(int i = 7 ; i >= 0 ; i--) {
+ g = p >> i;
+ //AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: --SetDevicePower3-- for Device = %d, Power=%d"),i, k&1);
+ if (i== d-1)
+ {
+ return g&1;
+ }
+ }
+}
bool TuyaSetChannels(void)
{
LightSerialDuty(((uint8_t*)XdrvMailbox.data)[0]);
From ffbd1af0d18aef2bfa50f1fe34c4a480d8638802 Mon Sep 17 00:00:00 2001
From: thirug010 <30732819+thirug010@users.noreply.github.com>
Date: Sun, 19 May 2019 09:47:51 -0500
Subject: [PATCH 07/11] Revert "Revert "Update xdrv_16_tuyadimmer.ino""
This reverts commit 27dd98c539f8603acc9a3102918ece348f32d642.
---
sonoff/xdrv_16_tuyadimmer.ino | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/sonoff/xdrv_16_tuyadimmer.ino b/sonoff/xdrv_16_tuyadimmer.ino
index 4b0ebfcd8..202674ac5 100644
--- a/sonoff/xdrv_16_tuyadimmer.ino
+++ b/sonoff/xdrv_16_tuyadimmer.ino
@@ -123,23 +123,12 @@ bool TuyaSetPower(void)
int16_t source = XdrvMailbox.payload;
if (source != SRC_SWITCH && TuyaSerial) { // ignore to prevent loop from pushing state from faceplate interaction
- TuyaSendBool(deviceid, TuyaGetPower(rpower, deviceid));
+ TuyaSendBool(deviceid, bitRead(rpower, deviceid-1));
status = true;
}
return status;
}
-uint8_t TuyaGetPower(uint8_t p, uint8_t d) {
- uint8_t g = 0;
- for(int i = 7 ; i >= 0 ; i--) {
- g = p >> i;
- //AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: --SetDevicePower3-- for Device = %d, Power=%d"),i, k&1);
- if (i== d-1)
- {
- return g&1;
- }
- }
-}
bool TuyaSetChannels(void)
{
LightSerialDuty(((uint8_t*)XdrvMailbox.data)[0]);
From a802d7671329c76c28cef8b9d894b4db19caa461 Mon Sep 17 00:00:00 2001
From: thirug010 <30732819+thirug010@users.noreply.github.com>
Date: Sun, 19 May 2019 09:50:57 -0500
Subject: [PATCH 08/11] update the changelog.ino
---
sonoff/_changelog.ino | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino
index 7e2852ff8..de056c030 100644
--- a/sonoff/_changelog.ino
+++ b/sonoff/_changelog.ino
@@ -1,8 +1,6 @@
/*
- * 6.5.0.13 20190518
- * Updated xdrv_01_webserver.ino to show dimmer slider2 by default for Tuya Dimmer Module optionally disabled for non dimmers
- * Updated xdrv_16_tuyadimmer.ino remove the use of XdrvMailbox and removed the pow functions
- * updated sonoff.ino to hold current device id
+ * 6.5.0.14 20190520
+ * Updated xdrv_16_tuyadimmer.ino repalced TuyGetPower with bitRead()
*
* 6.5.0.12 20190517
* Add command SetOption65 (tuya_show_dimmer) to enable or disable dimmer Slider ( for 4 Gang Tuya switch)
From 86af0df7123bab646a08e75b2d92d7db2420f785 Mon Sep 17 00:00:00 2001
From: thirug010 <30732819+thirug010@users.noreply.github.com>
Date: Mon, 20 May 2019 16:37:23 -0500
Subject: [PATCH 09/11] update the Code to prevent the multiple power mqtt
update the xdrv_16_tuyadimmer.ino to prevent the multiple mqtt msg for power status.
---
sonoff/xdrv_16_tuyadimmer.ino | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/sonoff/xdrv_16_tuyadimmer.ino b/sonoff/xdrv_16_tuyadimmer.ino
index 202674ac5..6e16efc51 100644
--- a/sonoff/xdrv_16_tuyadimmer.ino
+++ b/sonoff/xdrv_16_tuyadimmer.ino
@@ -195,11 +195,14 @@ void TuyaPacketProcess(void)
case TUYA_CMD_STATE:
if (tuya_buffer[5] == 5) { // on/off packet
- AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: RX Device -%d --> %s State"),tuya_buffer[6],tuya_buffer[10]?"On":"Off");
- ExecuteCommandPower(tuya_buffer[6], tuya_buffer[10], SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction
/*if((power || Settings.light_dimmer > 0) && (power != tuya_buffer[10])) {
ExecuteCommandPower(1, tuya_buffer[10], SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction
}*/
+ AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: RX Device-%d --> MCU State: %s Current State:%s"),tuya_buffer[6],tuya_buffer[10]?"On":"Off",bitRead(power, tuya_buffer[6]-1)?"On":"Off");
+ if((power || Settings.light_dimmer > 0) && (tuya_buffer[10] != bitRead(power, tuya_buffer[6]-1)))
+ {
+ ExecuteCommandPower(tuya_buffer[6], tuya_buffer[10], SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction
+ }
}
else if (tuya_buffer[5] == 8) { // dim packet
From ab9baf2ac074280ea3fb3b008d8878cae66b547d Mon Sep 17 00:00:00 2001
From: thirug010 <30732819+thirug010@users.noreply.github.com>
Date: Wed, 22 May 2019 01:28:38 -0500
Subject: [PATCH 10/11] Resolved conflit and Updated the code Skop dimmer
packets for non-dimmer configuration
1. Rsolved the build conflict on sonoff/_changelog.ino
tools/decode-config.py
2. Updated the code Skop dimmer packets for non-dimmer configuration
---
sonoff/_changelog.ino | 18 ++++++--
sonoff/xdrv_16_tuyadimmer.ino | 24 +++++-----
tools/decode-config.py | 82 +++++++++++++++++++----------------
3 files changed, 71 insertions(+), 53 deletions(-)
diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino
index de056c030..530805bf7 100644
--- a/sonoff/_changelog.ino
+++ b/sonoff/_changelog.ino
@@ -1,15 +1,25 @@
/*
- * 6.5.0.14 20190520
- * Updated xdrv_16_tuyadimmer.ino repalced TuyGetPower with bitRead()
- *
- * 6.5.0.12 20190517
+ * 6.5.0.13 20190517
* Add command SetOption65 (tuya_show_dimmer) to enable or disable dimmer Slider ( for 4 Gang Tuya switch)
* Added Seeting.pram9 to define no of Tuya MCU devices
* Updated xdrv_01_webserver.ino to check for the tuya_show_dimmer option to display slider2
* Updated xdrv_16_tuyadimmer.ino create bool serial packet based on the Device Id and set the power status based on the Device id from MCU packet
+ * Updated xdrv_16_tuyadimmer.ino skip dimmer packets for device configured as non - dimmer
+ *
+ * 6.5.0.12 20190521
+ * Add AriLux RF control GPIO option "ALux IrSel" (159) replacing "Led4i" (59) for full LED control (#5709)
+ * Add LED GPIO option "LedLink" (157) and "LedLinki" (158) to select dedicated link status LED (#5709)
+ * Add support for up to four LEDs related to four power outputs. Enabled when "LedLink(i)" is configured too (#5709)
+ * Add extended LED power control using command LedPowerX where X is 1 to 4. Enabled when "LedLink(i)" is configured too (#5709)
*
* 6.5.0.11 20190517
* Add command SetOption64 0/1 to switch between "-" or "_" as sensor index separator impacting DS18X20, DHT, BMP and SHT3X sensor names (#5689)
+ * Add initial support for Scripts as replacement for Rules. Default disabled but can be enabled in my_user_config.h (#5689)
+ * Add rule System#Save executed just before a planned restart
+ * Add HX711 weight restore after controlled restart or after power restore just before executing command Sensor34 7 (#5367, #5786)
+ * Remove define USE_EMULATION from my_user_config.h (#5826)
+ * Add defines USE_EMULATION_WEMO and USE_EMULATION_HUE to my_user_config.h to control emulation features at compile time (#5826)
+ * Add support for SPS30 Particle sensor thanks to Gerhard Mutz (#5830)
*
* 6.5.0.10 20190513
* Enable ADC0 by default in my_user_config.h (#5671)
diff --git a/sonoff/xdrv_16_tuyadimmer.ino b/sonoff/xdrv_16_tuyadimmer.ino
index 6e16efc51..667d0d458 100644
--- a/sonoff/xdrv_16_tuyadimmer.ino
+++ b/sonoff/xdrv_16_tuyadimmer.ino
@@ -207,21 +207,23 @@ void TuyaPacketProcess(void)
else if (tuya_buffer[5] == 8) { // dim packet
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: RX Dim State=%d"), tuya_buffer[13]);
+ if(Settings.flag3.tuya_show_dimmer == 0) //
+ {
+ if (!Settings.param[P_TUYA_DIMMER_ID]) {
+ AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: Autoconfiguring Dimmer ID %d"), tuya_buffer[6]);
+ Settings.param[P_TUYA_DIMMER_ID] = tuya_buffer[6];
+ }
- if (!Settings.param[P_TUYA_DIMMER_ID]) {
- AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: Autoconfiguring Dimmer ID %d"), tuya_buffer[6]);
- Settings.param[P_TUYA_DIMMER_ID] = tuya_buffer[6];
- }
+ tuya_new_dim = round(tuya_buffer[13] * (100. / 255.));
+ if((power || Settings.flag3.tuya_apply_o20) && (tuya_new_dim > 0) && (abs(tuya_new_dim - Settings.light_dimmer) > 1)) {
- tuya_new_dim = round(tuya_buffer[13] * (100. / 255.));
- if((power || Settings.flag3.tuya_apply_o20) && (tuya_new_dim > 0) && (abs(tuya_new_dim - Settings.light_dimmer) > 1)) {
+ snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_DIMMER " %d"), tuya_new_dim );
- snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_DIMMER " %d"), tuya_new_dim );
+ AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: Send CMND_DIMMER_STR=%s"), scmnd );
- AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: Send CMND_DIMMER_STR=%s"), scmnd );
-
- tuya_ignore_dim = true;
- ExecuteCommand(scmnd, SRC_SWITCH);
+ tuya_ignore_dim = true;
+ ExecuteCommand(scmnd, SRC_SWITCH);
+ }
}
}
break;
diff --git a/tools/decode-config.py b/tools/decode-config.py
index b2ea6f5d9..6482edcbd 100755
--- a/tools/decode-config.py
+++ b/tools/decode-config.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-VER = '2.2.0025'
+VER = '2.2.0026'
"""
decode-config.py - Backup/Restore Sonoff-Tasmota configuration data
@@ -29,7 +29,7 @@ Requirements:
Instructions:
Execute command with option -d to retrieve config data from a host
or use -f to read a configuration file saved using Tasmota Web-UI
-
+
For further information read 'decode-config.md'
For help execute command with argument -h (or -H for advanced help)
@@ -263,7 +263,7 @@ exitcode = 0
Settings dictionary describes the config file fields definition:
= { : }
-
+
: "string"
a python valid dictionary key (string)
@@ -333,12 +333,12 @@ Settings dictionary describes the config file fields definition:
to convert value from JSON back to binary object
Common definitions
-
+
: | | None
function to be called or string to evaluate:
:
A function name will be called with one or two parameter:
- The value to be processed
+ The value to be processed
(optional) the current array index (1,n)
A string will be evaluate as is. The following
@@ -358,7 +358,7 @@ Settings dictionary describes the config file fields definition:
numbers in the range -2147483648 through 2147483647
: unsigned integer
numbers in the range 0 through 4294967295
-
+
"""
# ----------------------------------------------------------------------
# Settings helper
@@ -370,16 +370,16 @@ def passwordwrite(value):
def bitsRead(x, n=0, c=1):
"""
Reads bit(s) of a number
-
+
@param x:
the number from which to read
-
+
@param n:
which bit position to read
-
+
@param c:
how many bits to read (1 if omitted)
-
+
@return:
the bit value(s)
"""
@@ -396,14 +396,14 @@ def bitsRead(x, n=0, c=1):
x &= (1< 0:
- groups.add(group)
+ groups.add(group.title())
if isinstance(format_, dict):
subgroups = GetGroupList(format_)
if subgroups is not None and len(subgroups) > 0:
for group in subgroups:
- groups.add(group)
+ groups.add(group.title())
groups=list(groups)
groups.sort()
return groups
-
+
class FileType:
FILE_NOT_FOUND = None
@@ -1347,7 +1353,7 @@ def MakeUrl(host, port=80, location=''):
def LoadTasmotaConfig(filename):
"""
Load config from Tasmota file
-
+
@param filename:
filename to load
@@ -1420,7 +1426,7 @@ def TasmotaGet(cmnd, host, port, username=DEFAULTS['source']['username'], passwo
body = buffer.getvalue()
except:
pass
-
+
return responsecode, body
@@ -1605,7 +1611,7 @@ def GetSettingsCrc(dobj):
def GetFieldDef(fielddef, fields="format_, addrdef, baseaddr, bits, bitshift, datadef, arraydef, validate, cmd, group, tasmotacmnd, converter, readconverter, writeconverter"):
-
+
"""
Get field definition items
@@ -1723,7 +1729,7 @@ def GetFieldDef(fielddef, fields="format_, addrdef, baseaddr, bits, bitshift, da
else:
print >> sys.stderr, 'wrong {} length ({}) in {}'.format(converter, len(converter), fielddef)
raise SyntaxError(' error')
-
+
return eval(fields)
@@ -1798,13 +1804,13 @@ def CmndConverter(valuemapping, value, idx, fielddef):
else:
evalstr = tasmotacmnd.replace('$','value').replace('@','valuemapping')
result = eval(evalstr)
-
+
elif callable(tasmotacmnd): # use as format function
if idx is not None:
result = tasmotacmnd(value, idx)
else:
result = tasmotacmnd(value)
-
+
return result
@@ -1821,7 +1827,7 @@ def ValidateValue(value, fielddef):
True if value is valid, False if invalid
"""
validate = GetFieldDef(fielddef, fields='validate')
-
+
if value == 0:
# can not complete all validate condition
# some Tasmota values are not allowed to be 0 on input
@@ -1918,7 +1924,7 @@ def GetFieldMinMax(fielddef):
max_ = GetFormatCount(format_)
return min_,max_
-
+
def GetFieldLength(fielddef):
"""
@@ -2039,7 +2045,7 @@ def GetFieldValue(fielddef, dobj, addr):
"""
format_, bits, bitshift = GetFieldDef(fielddef, fields='format_, bits, bitshift')
-
+
value_ = 0
unpackedvalue = struct.unpack_from(format_, dobj, addr)
singletype, bitsize = GetFormatType(format_)
@@ -2076,7 +2082,7 @@ def SetFieldValue(fielddef, dobj, addr, value):
format_, bits, bitshift = GetFieldDef(fielddef, fields='format_, bits, bitshift')
formatcnt = GetFormatCount(format_)
- singletype, bitsize = GetFormatType(format_)
+ singletype, bitsize = GetFormatType(format_)
if args.debug >= 2:
print >> sys.stderr, "SetFieldValue(): fielddef {}, addr 0x{:04x} value {} formatcnt {} singletype {} bitsize {} ".format(fielddef,addr,value,formatcnt,singletype,bitsize)
if not format_[-1:].lower() in ['s','p']:
@@ -2138,7 +2144,7 @@ def GetField(dobj, fieldname, fielddef, raw=False, addroffset=0):
value = GetField(dobj, fieldname, subfielddef, raw=raw, addroffset=addroffset+offset)
valuemapping.append(value)
offset += length
-
+
# contains a dict
elif isinstance(format_, dict):
mapping_value = {}
@@ -2333,7 +2339,7 @@ def SetField(dobj, fieldname, fielddef, restore, addroffset=0, filename=""):
curvalue = GetFieldValue(fielddef, dobj, baseaddr+addroffset)
if prevvalue != curvalue and args.verbose:
message("Value for '{}' changed from {} to {}".format(fieldname, prevvalue, curvalue), typ=LogType.INFO)
- else:
+ else:
if args.debug >= 2:
print >> sys.stderr, "SetField(): Special field '{}' using '{}'/{}{} @{} skipped".format(fieldname, format_, arraydef, bits, hex(baseaddr+addroffset))
else:
@@ -2502,14 +2508,14 @@ def Mapping2Bin(decode_cfg, jsonconfig, filename=""):
restore data mapping
@param filename:
name of the restore file (for error output only)
-
+
@return:
changed binary config data (decrypted) or None on error
"""
if isinstance(decode_cfg, str):
decode_cfg = bytearray(decode_cfg)
-
+
# get binary header data to use the correct version template from device
version, size, setting = GetTemplateSetting(decode_cfg)
@@ -2549,13 +2555,13 @@ def Mapping2Cmnd(decode_cfg, valuemapping, filename=""):
data mapping
@param filename:
name of the restore file (for error output only)
-
+
@return:
Tasmota command mapping {group: [cmnd <,cmnd <,...>>]}
"""
if isinstance(decode_cfg, str):
decode_cfg = bytearray(decode_cfg)
-
+
# get binary header data to use the correct version template from device
version, size, setting = GetTemplateSetting(decode_cfg)
@@ -2782,7 +2788,7 @@ def OutputTasmotaCmnds(tasmotacmnds):
print
print "# {}:".format(group)
OutputTasmotaSubCmnds(cmnds)
-
+
else:
cmnds = []
for group in groups:
@@ -2793,7 +2799,7 @@ def OutputTasmotaCmnds(tasmotacmnds):
def ParseArgs():
"""
Program argument parser
-
+
@return:
configargparse.parse_args() result
"""
@@ -3056,5 +3062,5 @@ if __name__ == "__main__":
if args.outputformat == 'cmnd' or args.outputformat == 'command':
tasmotacmnds = Mapping2Cmnd(decode_cfg, configmapping)
OutputTasmotaCmnds(tasmotacmnds)
-
+
sys.exit(exitcode)
From c8c3c3452ebfb7fd7c14d1a524f00663e7f76865 Mon Sep 17 00:00:00 2001
From: andrethomas
Date: Fri, 7 Jun 2019 21:32:34 +0200
Subject: [PATCH 11/11] Reverting some files to
763118b6265b25d317eabfd60234fb558fded1b2
---
platformio.ini | 2 +-
sonoff/_changelog.ino | 10 +-----
sonoff/my_user_config.h | 2 +-
tools/decode-config.py | 75 +++++++++++++++++++----------------------
4 files changed, 38 insertions(+), 51 deletions(-)
diff --git a/platformio.ini b/platformio.ini
index c2d09ace8..351d1ba02 100755
--- a/platformio.ini
+++ b/platformio.ini
@@ -568,4 +568,4 @@ monitor_speed = ${common.monitor_speed}
upload_port = ${common.upload_port}
upload_resetmethod = ${common.upload_resetmethod}
upload_speed = ${common.upload_speed}
-extra_scripts = ${common.extra_scripts}
\ No newline at end of file
+extra_scripts = ${common.extra_scripts}
diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino
index 530805bf7..5b2497eb5 100644
--- a/sonoff/_changelog.ino
+++ b/sonoff/_changelog.ino
@@ -1,12 +1,4 @@
-/*
- * 6.5.0.13 20190517
- * Add command SetOption65 (tuya_show_dimmer) to enable or disable dimmer Slider ( for 4 Gang Tuya switch)
- * Added Seeting.pram9 to define no of Tuya MCU devices
- * Updated xdrv_01_webserver.ino to check for the tuya_show_dimmer option to display slider2
- * Updated xdrv_16_tuyadimmer.ino create bool serial packet based on the Device Id and set the power status based on the Device id from MCU packet
- * Updated xdrv_16_tuyadimmer.ino skip dimmer packets for device configured as non - dimmer
- *
- * 6.5.0.12 20190521
+/* 6.5.0.12 20190521
* Add AriLux RF control GPIO option "ALux IrSel" (159) replacing "Led4i" (59) for full LED control (#5709)
* Add LED GPIO option "LedLink" (157) and "LedLinki" (158) to select dedicated link status LED (#5709)
* Add support for up to four LEDs related to four power outputs. Enabled when "LedLink(i)" is configured too (#5709)
diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h
index b18949005..6786f755b 100644
--- a/sonoff/my_user_config.h
+++ b/sonoff/my_user_config.h
@@ -471,4 +471,4 @@
#error "Select either USE_MQTT_TLS or USE_WEBSERVER as there is just not enough memory to play with"
#endif
-#endif // _MY_USER_CONFIG_H_
\ No newline at end of file
+#endif // _MY_USER_CONFIG_H_
diff --git a/tools/decode-config.py b/tools/decode-config.py
index c50caa126..f3e2b526b 100755
--- a/tools/decode-config.py
+++ b/tools/decode-config.py
@@ -29,7 +29,7 @@ Requirements:
Instructions:
Execute command with option -d to retrieve config data from a host
or use -f to read a configuration file saved using Tasmota Web-UI
-
+
For further information read 'decode-config.md'
For help execute command with argument -h (or -H for advanced help)
@@ -263,7 +263,7 @@ exitcode = 0
Settings dictionary describes the config file fields definition:
= { : }
-
+
: "string"
a python valid dictionary key (string)
@@ -333,12 +333,12 @@ Settings dictionary describes the config file fields definition:
to convert value from JSON back to binary object
Common definitions
-
+
: | | None
function to be called or string to evaluate:
:
A function name will be called with one or two parameter:
- The value to be processed
+ The value to be processed
(optional) the current array index (1,n)
A string will be evaluate as is. The following
@@ -358,7 +358,7 @@ Settings dictionary describes the config file fields definition:
numbers in the range -2147483648 through 2147483647
: unsigned integer
numbers in the range 0 through 4294967295
-
+
"""
# ----------------------------------------------------------------------
# Settings helper
@@ -370,16 +370,16 @@ def passwordwrite(value):
def bitsRead(x, n=0, c=1):
"""
Reads bit(s) of a number
-
+
@param x:
the number from which to read
-
+
@param n:
which bit position to read
-
+
@param c:
how many bits to read (1 if omitted)
-
+
@return:
the bit value(s)
"""
@@ -396,14 +396,14 @@ def bitsRead(x, n=0, c=1):
x &= (1<= 2:
print >> sys.stderr, "SetFieldValue(): fielddef {}, addr 0x{:04x} value {} formatcnt {} singletype {} bitsize {} ".format(fielddef,addr,value,formatcnt,singletype,bitsize)
if not format_[-1:].lower() in ['s','p']:
@@ -2142,7 +2137,7 @@ def GetField(dobj, fieldname, fielddef, raw=False, addroffset=0):
value = GetField(dobj, fieldname, subfielddef, raw=raw, addroffset=addroffset+offset)
valuemapping.append(value)
offset += length
-
+
# contains a dict
elif isinstance(format_, dict):
mapping_value = {}
@@ -2337,7 +2332,7 @@ def SetField(dobj, fieldname, fielddef, restore, addroffset=0, filename=""):
curvalue = GetFieldValue(fielddef, dobj, baseaddr+addroffset)
if prevvalue != curvalue and args.verbose:
message("Value for '{}' changed from {} to {}".format(fieldname, prevvalue, curvalue), typ=LogType.INFO)
- else:
+ else:
if args.debug >= 2:
print >> sys.stderr, "SetField(): Special field '{}' using '{}'/{}{} @{} skipped".format(fieldname, format_, arraydef, bits, hex(baseaddr+addroffset))
else:
@@ -2506,14 +2501,14 @@ def Mapping2Bin(decode_cfg, jsonconfig, filename=""):
restore data mapping
@param filename:
name of the restore file (for error output only)
-
+
@return:
changed binary config data (decrypted) or None on error
"""
if isinstance(decode_cfg, str):
decode_cfg = bytearray(decode_cfg)
-
+
# get binary header data to use the correct version template from device
version, size, setting = GetTemplateSetting(decode_cfg)
@@ -2553,13 +2548,13 @@ def Mapping2Cmnd(decode_cfg, valuemapping, filename=""):
data mapping
@param filename:
name of the restore file (for error output only)
-
+
@return:
Tasmota command mapping {group: [cmnd <,cmnd <,...>>]}
"""
if isinstance(decode_cfg, str):
decode_cfg = bytearray(decode_cfg)
-
+
# get binary header data to use the correct version template from device
version, size, setting = GetTemplateSetting(decode_cfg)
@@ -2786,7 +2781,7 @@ def OutputTasmotaCmnds(tasmotacmnds):
print
print "# {}:".format(group)
OutputTasmotaSubCmnds(cmnds)
-
+
else:
cmnds = []
for group in groups:
@@ -2797,7 +2792,7 @@ def OutputTasmotaCmnds(tasmotacmnds):
def ParseArgs():
"""
Program argument parser
-
+
@return:
configargparse.parse_args() result
"""
@@ -3060,5 +3055,5 @@ if __name__ == "__main__":
if args.outputformat == 'cmnd' or args.outputformat == 'command':
tasmotacmnds = Mapping2Cmnd(decode_cfg, configmapping)
OutputTasmotaCmnds(tasmotacmnds)
-
+
sys.exit(exitcode)