mirror of https://github.com/arendst/Tasmota.git
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 ...
This commit is contained in:
parent
48f45a5e2b
commit
d59d631e40
|
@ -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}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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("<tr>"));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -903,7 +903,14 @@ Setting_6_5_0_9['flag3'][0].update ({
|
|||
'no_power_feedback': ('<L', (0x3A0,1,13), (None, None, ('SetOption', '"SetOption63 {}".format($)')) ),
|
||||
})
|
||||
# ======================================================================
|
||||
# ======================================================================
|
||||
Setting_6_5_0_10 = copy.deepcopy(Setting_6_5_0_9)
|
||||
Setting_6_5_0_10['flag3'][0].update ({
|
||||
'tuya_show_dimmer': ('<L', (0x3A0,1,15), (None, None, ('SetOption', '"SetOption65 {}".format($)')) ),
|
||||
})
|
||||
# ======================================================================
|
||||
Settings = [
|
||||
(0x6050010, 0xe00, Setting_6_5_0_10),
|
||||
(0x6050009, 0xe00, Setting_6_5_0_9),
|
||||
(0x6050007, 0xe00, Setting_6_5_0_7),
|
||||
(0x6050006, 0xe00, Setting_6_5_0_6),
|
||||
|
|
Loading…
Reference in New Issue