From e749df75ad9f0862d171fb54342b3bb4ad793138 Mon Sep 17 00:00:00 2001 From: Ian King Date: Tue, 17 Mar 2020 18:27:17 +0000 Subject: [PATCH 01/11] Add support for ElectriQ iQ-wifiMOODL RGBW LED contoller --- BUILDS.md | 1 + platformio.ini | 2 +- tasmota/language/bg-BG.h | 1 + tasmota/language/cs-CZ.h | 1 + tasmota/language/de-DE.h | 1 + tasmota/language/el-GR.h | 1 + tasmota/language/en-GB.h | 1 + tasmota/language/es-ES.h | 1 + tasmota/language/fr-FR.h | 1 + tasmota/language/he-HE.h | 1 + tasmota/language/hu-HU.h | 1 + tasmota/language/it-IT.h | 1 + tasmota/language/ko-KO.h | 1 + tasmota/language/nl-NL.h | 1 + tasmota/language/pl-PL.h | 1 + tasmota/language/pt-BR.h | 1 + tasmota/language/pt-PT.h | 1 + tasmota/language/ro-RO.h | 1 + tasmota/language/ru-RU.h | 1 + tasmota/language/sk-SK.h | 1 + tasmota/language/sv-SE.h | 1 + tasmota/language/tr-TR.h | 1 + tasmota/language/uk-UA.h | 1 + tasmota/language/zh-CN.h | 1 + tasmota/language/zh-TW.h | 1 + tasmota/my_user_config.h | 1 + tasmota/tasmota_post.h | 4 ++ tasmota/tasmota_template.h | 7 +- tasmota/xlgt_06_electriq_moodl.ino | 102 +++++++++++++++++++++++++++++ 29 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 tasmota/xlgt_06_electriq_moodl.ino diff --git a/BUILDS.md b/BUILDS.md index 18f25042b..f63d29bb8 100644 --- a/BUILDS.md +++ b/BUILDS.md @@ -53,6 +53,7 @@ | USE_SM16716 | - | - | x | x | x | - | x | | USE_SM2135 | - | - | x | x | x | - | x | | USE_SONOFF_L1 | - | - | x | x | x | - | x | +| USE_ELECTRIQ_MOODL | - | - | x | x | x | - | x | | | | | | | | | | | USE_ENERGY_SENSOR | - | x | x | x | x | - | - | | USE_PZEM004T | - | - | x | x | x | - | - | diff --git a/platformio.ini b/platformio.ini index 6b9459388..bb9038a9c 100755 --- a/platformio.ini +++ b/platformio.ini @@ -17,7 +17,7 @@ extra_configs = platformio_tasmota_env.ini ; *** Build/upload environment default_envs = ; *** Uncomment by deleting ";" in the line(s) below to select version(s) -; tasmota + tasmota ; tasmota-ircustom ; alternative to 'tasmota' with full IR protocols activated, you will need to disable some features to keep code not too big ; tasmota-minimal ; tasmota-lite diff --git a/tasmota/language/bg-BG.h b/tasmota/language/bg-BG.h index 37e1468ab..0abed5232 100644 --- a/tasmota/language/bg-BG.h +++ b/tasmota/language/bg-BG.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/cs-CZ.h b/tasmota/language/cs-CZ.h index 6ea1707a7..6d7ac1978 100644 --- a/tasmota/language/cs-CZ.h +++ b/tasmota/language/cs-CZ.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/de-DE.h b/tasmota/language/de-DE.h index 6bcd615f0..0d2a189db 100644 --- a/tasmota/language/de-DE.h +++ b/tasmota/language/de-DE.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/el-GR.h b/tasmota/language/el-GR.h index 5b13e6342..097d1ecaa 100644 --- a/tasmota/language/el-GR.h +++ b/tasmota/language/el-GR.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/en-GB.h b/tasmota/language/en-GB.h index c394c706d..fcb4618c5 100644 --- a/tasmota/language/en-GB.h +++ b/tasmota/language/en-GB.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/es-ES.h b/tasmota/language/es-ES.h index 1f7e33914..b40dd9d18 100644 --- a/tasmota/language/es-ES.h +++ b/tasmota/language/es-ES.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/fr-FR.h b/tasmota/language/fr-FR.h index 9aa4efba8..a2627d45e 100644 --- a/tasmota/language/fr-FR.h +++ b/tasmota/language/fr-FR.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/he-HE.h b/tasmota/language/he-HE.h index 64d1b38b2..451aaf588 100644 --- a/tasmota/language/he-HE.h +++ b/tasmota/language/he-HE.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/hu-HU.h b/tasmota/language/hu-HU.h index d4797a90a..6ed3a8b49 100644 --- a/tasmota/language/hu-HU.h +++ b/tasmota/language/hu-HU.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/it-IT.h b/tasmota/language/it-IT.h index 7f41ad7fa..f63b5f5ca 100644 --- a/tasmota/language/it-IT.h +++ b/tasmota/language/it-IT.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/ko-KO.h b/tasmota/language/ko-KO.h index fe1ca5b3b..8cbf27a4f 100644 --- a/tasmota/language/ko-KO.h +++ b/tasmota/language/ko-KO.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/nl-NL.h b/tasmota/language/nl-NL.h index 474cc7150..9b79a5c98 100644 --- a/tasmota/language/nl-NL.h +++ b/tasmota/language/nl-NL.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/pl-PL.h b/tasmota/language/pl-PL.h index 5652de045..dede4bd00 100644 --- a/tasmota/language/pl-PL.h +++ b/tasmota/language/pl-PL.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/pt-BR.h b/tasmota/language/pt-BR.h index 858be76f0..351f85cce 100644 --- a/tasmota/language/pt-BR.h +++ b/tasmota/language/pt-BR.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/pt-PT.h b/tasmota/language/pt-PT.h index 6bbfc0fa6..13144cfeb 100644 --- a/tasmota/language/pt-PT.h +++ b/tasmota/language/pt-PT.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/ro-RO.h b/tasmota/language/ro-RO.h index 53c08426a..68fa70a26 100644 --- a/tasmota/language/ro-RO.h +++ b/tasmota/language/ro-RO.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/ru-RU.h b/tasmota/language/ru-RU.h index 990c3d9d1..590fecd2e 100644 --- a/tasmota/language/ru-RU.h +++ b/tasmota/language/ru-RU.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "А" diff --git a/tasmota/language/sk-SK.h b/tasmota/language/sk-SK.h index d9eae653d..62d8d4786 100644 --- a/tasmota/language/sk-SK.h +++ b/tasmota/language/sk-SK.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/sv-SE.h b/tasmota/language/sv-SE.h index 302dac80c..e48fe9c64 100644 --- a/tasmota/language/sv-SE.h +++ b/tasmota/language/sv-SE.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/tr-TR.h b/tasmota/language/tr-TR.h index bb48f6d0e..4d37f99f1 100644 --- a/tasmota/language/tr-TR.h +++ b/tasmota/language/tr-TR.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/uk-UA.h b/tasmota/language/uk-UA.h index 895269639..f447d4775 100644 --- a/tasmota/language/uk-UA.h +++ b/tasmota/language/uk-UA.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "А" diff --git a/tasmota/language/zh-CN.h b/tasmota/language/zh-CN.h index e1517e21e..68fdafbca 100644 --- a/tasmota/language/zh-CN.h +++ b/tasmota/language/zh-CN.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "安" diff --git a/tasmota/language/zh-TW.h b/tasmota/language/zh-TW.h index f3c31c0b6..bc3a537fc 100644 --- a/tasmota/language/zh-TW.h +++ b/tasmota/language/zh-TW.h @@ -663,6 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" +#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" // Units #define D_UNIT_AMPERE "安" diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index dbc60bac3..49b2a5c16 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -431,6 +431,7 @@ #define USE_SM16716 // Add support for SM16716 RGB LED controller (+0k7 code) #define USE_SM2135 // Add support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #define USE_SONOFF_L1 // Add support for Sonoff L1 led control +#define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED contoller // -- Counter input ------------------------------- #define USE_COUNTER // Enable inputs as counter (+0k8 code) diff --git a/tasmota/tasmota_post.h b/tasmota/tasmota_post.h index 1abd371ff..ed1091fbe 100644 --- a/tasmota/tasmota_post.h +++ b/tasmota/tasmota_post.h @@ -134,6 +134,7 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack #define USE_SM16716 // Add support for SM16716 RGB LED controller (+0k7 code) #define USE_SM2135 // Add support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #define USE_SONOFF_L1 // Add support for Sonoff L1 led control +#define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED contoller #define USE_COUNTER // Enable counters #undef USE_ADC_VCC // Add Analog input on selected devices @@ -399,6 +400,7 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack #undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code) #undef USE_SM2135 // Disable support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control +#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED contoller #undef USE_ENERGY_SENSOR // Disable energy sensors (-14k code) #undef USE_PZEM004T // Disable PZEM004T energy sensor @@ -512,6 +514,7 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack #undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code) #undef USE_SM2135 // Disable support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control +#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED contoller #undef USE_COUNTER // Disable counters #define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices @@ -632,6 +635,7 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack #undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code) #undef USE_SM2135 // Disable support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control +#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED contoller #undef USE_COUNTER // Disable counters #define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index a45c456f8..15c1c1503 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -225,6 +225,7 @@ enum UserSelectablePins { GPIO_CC1101_GDO0, // CC1101 pin for RX GPIO_CC1101_GDO2, // CC1101 pin for RX GPIO_HRXL_RX, // Data from MaxBotix HRXL sonar range sensor + GPIO_ELECTRIC_MOODL_TX, // ElectriQ iQ-wifiMOODL Serial TX GPIO_SENSOR_END }; // Programmer selectable GPIO functionality @@ -310,7 +311,8 @@ const char kSensorNames[] PROGMEM = D_SENSOR_HM10_RX "|" D_SENSOR_HM10_TX "|" D_SENSOR_LE01MR_RX "|" D_SENSOR_LE01MR_TX "|" D_SENSOR_CC1101_GDO0 "|" D_SENSOR_CC1101_GDO2 "|" - D_SENSOR_HRXL_RX + D_SENSOR_HRXL_RX "|" + D_SENSOR_ELECTRIQ_MOODL ; const char kSensorNamesFixed[] PROGMEM = @@ -611,6 +613,9 @@ const uint8_t kGpioNiceList[] PROGMEM = { #ifdef USE_EXS_DIMMER GPIO_EXS_ENABLE, // EXS MCU Enable #endif +#ifdef USE_ELECTRIQ_MOODL + GPIO_ELECTRIC_MOODL_TX, +#endif #endif // USE_LIGHT #if defined(USE_IR_REMOTE) || defined(USE_IR_REMOTE_FULL) diff --git a/tasmota/xlgt_06_electriq_moodl.ino b/tasmota/xlgt_06_electriq_moodl.ino new file mode 100644 index 000000000..ed5c5e498 --- /dev/null +++ b/tasmota/xlgt_06_electriq_moodl.ino @@ -0,0 +1,102 @@ +/* + xlgt_06_moodlamp.ino - ElectriQ iQ-wifiMOODL LED support for Tasmota + + Copyright (C) 2019 Theo Arends + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifdef USE_LIGHT +#ifdef USE_ELECTRIQ_MOODL + +/*********************************************************************************************\ + * ElectriQ iQ-wifiMOODL + * This RGBW mood lamp uses the TYWE3S module to transmit via UART to an unmarked MCU which + * drives 8 MOSFETs. The MCU does not transmit; it ony receives commands from the TYWE3S. + * The MCU appears to use a modified/undocumented version of the TuyaMCU protocol. + * The main PCB has 2 daughter boards which hold the RGBW LEDs - an upper deck and a lower deck. + * The same RGBW data is transmitted to the upper and lower decks. + * *********************************************************************************************/ + +#define XLGT_06 6 + +/********************************************************************************************/ + +bool ElectriqMoodLSetChannels(void) +{ + uint8_t *col = (uint8_t*)XdrvMailbox.data; + uint8_t checksum = (uint8_t)(0x65 + 0xAA + 0x01 + 0x0A); + + Serial.write(0x65); // Fixed header + Serial.write(0xAA); + Serial.write(0x00); // Version + Serial.write(0x01); // Command + Serial.write(0x0A); // Payload length + + uint8_t payload[5]; + payload[0] = col[0]; + payload[1] = col[1]; + payload[2] = col[2]; + payload[3] = col[3]; + payload[4] = 0x0; // Unused + + // Send payload for the upper LED deck + for (uint32_t i = 0; i < 5; i++) { + Serial.write(payload[i]); + checksum += payload[i]; + } + + // Send payload for the lower LED deck + for (uint32_t i = 0; i < 5; i++) { + Serial.write(payload[i]); + checksum += payload[i]; + } + + Serial.write(checksum); + Serial.flush(); + + return true; +} + +void ElectriqMoodLModuleSelected(void) +{ + if (pin[GPIO_ELECTRIC_MOODL_TX] < 99) { + SetSerial(9600, TS_SERIAL_8N1); + light_type = LT_RGBW; + light_flg = XLGT_06; + AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DBG: ElectriQ Mood Lamp Found")); + } +} + +/*********************************************************************************************\ + * Interface +\*********************************************************************************************/ + +bool Xlgt06(uint8_t function) +{ + bool result = false; + + switch (function) { + case FUNC_SET_CHANNELS: + result = ElectriqMoodLSetChannels(); + break; + case FUNC_MODULE_INIT: + ElectriqMoodLModuleSelected(); + break; + } + return result; +} + +#endif // USE_ELECTRIQ_MOODL +#endif // USE_LIGHT \ No newline at end of file From 20cc9777f72c7283767af824e736696619007b5f Mon Sep 17 00:00:00 2001 From: Ian King Date: Tue, 17 Mar 2020 18:33:43 +0000 Subject: [PATCH 02/11] Revert platformio.ini --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index bb9038a9c..6b9459388 100755 --- a/platformio.ini +++ b/platformio.ini @@ -17,7 +17,7 @@ extra_configs = platformio_tasmota_env.ini ; *** Build/upload environment default_envs = ; *** Uncomment by deleting ";" in the line(s) below to select version(s) - tasmota +; tasmota ; tasmota-ircustom ; alternative to 'tasmota' with full IR protocols activated, you will need to disable some features to keep code not too big ; tasmota-minimal ; tasmota-lite From d7fc4442817bf41d1ba56db2f4ee80d2649352d6 Mon Sep 17 00:00:00 2001 From: Ian King Date: Tue, 17 Mar 2020 18:34:25 +0000 Subject: [PATCH 03/11] Correct copyright date to 2020 --- tasmota/xlgt_06_electriq_moodl.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/xlgt_06_electriq_moodl.ino b/tasmota/xlgt_06_electriq_moodl.ino index ed5c5e498..9de133e11 100644 --- a/tasmota/xlgt_06_electriq_moodl.ino +++ b/tasmota/xlgt_06_electriq_moodl.ino @@ -1,7 +1,7 @@ /* xlgt_06_moodlamp.ino - ElectriQ iQ-wifiMOODL LED support for Tasmota - Copyright (C) 2019 Theo Arends + Copyright (C) 2020 Theo Arends This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by From 4317f048aa053fe993f16a53b7d4f576496edc97 Mon Sep 17 00:00:00 2001 From: Ian King Date: Tue, 17 Mar 2020 21:28:40 +0000 Subject: [PATCH 04/11] Fix comment alignment --- tasmota/tasmota_post.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasmota/tasmota_post.h b/tasmota/tasmota_post.h index ed1091fbe..2059d63b9 100644 --- a/tasmota/tasmota_post.h +++ b/tasmota/tasmota_post.h @@ -400,7 +400,7 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack #undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code) #undef USE_SM2135 // Disable support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control -#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED contoller +#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED contoller #undef USE_ENERGY_SENSOR // Disable energy sensors (-14k code) #undef USE_PZEM004T // Disable PZEM004T energy sensor @@ -514,7 +514,7 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack #undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code) #undef USE_SM2135 // Disable support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control -#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED contoller +#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED contoller #undef USE_COUNTER // Disable counters #define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices @@ -635,7 +635,7 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack #undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code) #undef USE_SM2135 // Disable support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control -#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED contoller +#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED contoller #undef USE_COUNTER // Disable counters #define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices From 740e91dd273140a0c2bd0848d335cf185a43b3f3 Mon Sep 17 00:00:00 2001 From: Ian King Date: Tue, 17 Mar 2020 21:35:44 +0000 Subject: [PATCH 05/11] Fix typos --- tasmota/my_user_config.h | 2 +- tasmota/tasmota_post.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 49b2a5c16..568ece036 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -431,7 +431,7 @@ #define USE_SM16716 // Add support for SM16716 RGB LED controller (+0k7 code) #define USE_SM2135 // Add support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #define USE_SONOFF_L1 // Add support for Sonoff L1 led control -#define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED contoller +#define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller // -- Counter input ------------------------------- #define USE_COUNTER // Enable inputs as counter (+0k8 code) diff --git a/tasmota/tasmota_post.h b/tasmota/tasmota_post.h index 2059d63b9..aaa3e8a89 100644 --- a/tasmota/tasmota_post.h +++ b/tasmota/tasmota_post.h @@ -134,7 +134,7 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack #define USE_SM16716 // Add support for SM16716 RGB LED controller (+0k7 code) #define USE_SM2135 // Add support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #define USE_SONOFF_L1 // Add support for Sonoff L1 led control -#define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED contoller +#define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller #define USE_COUNTER // Enable counters #undef USE_ADC_VCC // Add Analog input on selected devices @@ -400,7 +400,7 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack #undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code) #undef USE_SM2135 // Disable support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control -#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED contoller +#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller #undef USE_ENERGY_SENSOR // Disable energy sensors (-14k code) #undef USE_PZEM004T // Disable PZEM004T energy sensor @@ -514,7 +514,7 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack #undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code) #undef USE_SM2135 // Disable support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control -#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED contoller +#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller #undef USE_COUNTER // Disable counters #define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices @@ -635,7 +635,7 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack #undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code) #undef USE_SM2135 // Disable support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control -#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED contoller +#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller #undef USE_COUNTER // Disable counters #define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices From 0609858b399b8704df8576c73d32f971ebb8deb8 Mon Sep 17 00:00:00 2001 From: Ian King Date: Tue, 17 Mar 2020 21:45:42 +0000 Subject: [PATCH 06/11] Fix typo --- tasmota/xlgt_06_electriq_moodl.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/xlgt_06_electriq_moodl.ino b/tasmota/xlgt_06_electriq_moodl.ino index 9de133e11..f90d3eefb 100644 --- a/tasmota/xlgt_06_electriq_moodl.ino +++ b/tasmota/xlgt_06_electriq_moodl.ino @@ -23,7 +23,7 @@ /*********************************************************************************************\ * ElectriQ iQ-wifiMOODL * This RGBW mood lamp uses the TYWE3S module to transmit via UART to an unmarked MCU which - * drives 8 MOSFETs. The MCU does not transmit; it ony receives commands from the TYWE3S. + * drives 8 MOSFETs. The MCU does not transmit; it only receives commands from the TYWE3S. * The MCU appears to use a modified/undocumented version of the TuyaMCU protocol. * The main PCB has 2 daughter boards which hold the RGBW LEDs - an upper deck and a lower deck. * The same RGBW data is transmitted to the upper and lower decks. From b250c599319e0938e77c1970ed9739a637c14372 Mon Sep 17 00:00:00 2001 From: Ian King Date: Wed, 18 Mar 2020 10:24:56 +0000 Subject: [PATCH 07/11] Keep sensor name short --- tasmota/language/bg-BG.h | 2 +- tasmota/language/cs-CZ.h | 2 +- tasmota/language/de-DE.h | 2 +- tasmota/language/el-GR.h | 2 +- tasmota/language/en-GB.h | 2 +- tasmota/language/es-ES.h | 2 +- tasmota/language/fr-FR.h | 2 +- tasmota/language/he-HE.h | 2 +- tasmota/language/hu-HU.h | 2 +- tasmota/language/it-IT.h | 2 +- tasmota/language/ko-KO.h | 2 +- tasmota/language/nl-NL.h | 2 +- tasmota/language/pl-PL.h | 2 +- tasmota/language/pt-BR.h | 2 +- tasmota/language/pt-PT.h | 2 +- tasmota/language/ro-RO.h | 2 +- tasmota/language/ru-RU.h | 2 +- tasmota/language/sk-SK.h | 2 +- tasmota/language/sv-SE.h | 2 +- tasmota/language/tr-TR.h | 2 +- tasmota/language/uk-UA.h | 2 +- tasmota/language/zh-CN.h | 2 +- tasmota/language/zh-TW.h | 2 +- 23 files changed, 23 insertions(+), 23 deletions(-) diff --git a/tasmota/language/bg-BG.h b/tasmota/language/bg-BG.h index 0abed5232..f7760f302 100644 --- a/tasmota/language/bg-BG.h +++ b/tasmota/language/bg-BG.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/cs-CZ.h b/tasmota/language/cs-CZ.h index 6d7ac1978..72bb6c275 100644 --- a/tasmota/language/cs-CZ.h +++ b/tasmota/language/cs-CZ.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/de-DE.h b/tasmota/language/de-DE.h index 0d2a189db..12cb30769 100644 --- a/tasmota/language/de-DE.h +++ b/tasmota/language/de-DE.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/el-GR.h b/tasmota/language/el-GR.h index 097d1ecaa..8a8160956 100644 --- a/tasmota/language/el-GR.h +++ b/tasmota/language/el-GR.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/en-GB.h b/tasmota/language/en-GB.h index fcb4618c5..09b43c1be 100644 --- a/tasmota/language/en-GB.h +++ b/tasmota/language/en-GB.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/es-ES.h b/tasmota/language/es-ES.h index b40dd9d18..f70940a38 100644 --- a/tasmota/language/es-ES.h +++ b/tasmota/language/es-ES.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/fr-FR.h b/tasmota/language/fr-FR.h index a2627d45e..488386aea 100644 --- a/tasmota/language/fr-FR.h +++ b/tasmota/language/fr-FR.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/he-HE.h b/tasmota/language/he-HE.h index 451aaf588..70d474e8f 100644 --- a/tasmota/language/he-HE.h +++ b/tasmota/language/he-HE.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/hu-HU.h b/tasmota/language/hu-HU.h index 6ed3a8b49..cc47f6a5d 100644 --- a/tasmota/language/hu-HU.h +++ b/tasmota/language/hu-HU.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/it-IT.h b/tasmota/language/it-IT.h index f63b5f5ca..d9a4b9a6b 100644 --- a/tasmota/language/it-IT.h +++ b/tasmota/language/it-IT.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/ko-KO.h b/tasmota/language/ko-KO.h index 8cbf27a4f..1767366db 100644 --- a/tasmota/language/ko-KO.h +++ b/tasmota/language/ko-KO.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/nl-NL.h b/tasmota/language/nl-NL.h index 9b79a5c98..246066035 100644 --- a/tasmota/language/nl-NL.h +++ b/tasmota/language/nl-NL.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/pl-PL.h b/tasmota/language/pl-PL.h index dede4bd00..6f945183a 100644 --- a/tasmota/language/pl-PL.h +++ b/tasmota/language/pl-PL.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/pt-BR.h b/tasmota/language/pt-BR.h index 351f85cce..236652de2 100644 --- a/tasmota/language/pt-BR.h +++ b/tasmota/language/pt-BR.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/pt-PT.h b/tasmota/language/pt-PT.h index 13144cfeb..507e7fe8b 100644 --- a/tasmota/language/pt-PT.h +++ b/tasmota/language/pt-PT.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/ro-RO.h b/tasmota/language/ro-RO.h index 68fa70a26..c3efc5758 100644 --- a/tasmota/language/ro-RO.h +++ b/tasmota/language/ro-RO.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/ru-RU.h b/tasmota/language/ru-RU.h index 590fecd2e..a104dca55 100644 --- a/tasmota/language/ru-RU.h +++ b/tasmota/language/ru-RU.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "А" diff --git a/tasmota/language/sk-SK.h b/tasmota/language/sk-SK.h index 62d8d4786..706432e5b 100644 --- a/tasmota/language/sk-SK.h +++ b/tasmota/language/sk-SK.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/sv-SE.h b/tasmota/language/sv-SE.h index e48fe9c64..df64cf2e3 100644 --- a/tasmota/language/sv-SE.h +++ b/tasmota/language/sv-SE.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/tr-TR.h b/tasmota/language/tr-TR.h index 4d37f99f1..1366b9996 100644 --- a/tasmota/language/tr-TR.h +++ b/tasmota/language/tr-TR.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/uk-UA.h b/tasmota/language/uk-UA.h index f447d4775..2e3c4c077 100644 --- a/tasmota/language/uk-UA.h +++ b/tasmota/language/uk-UA.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "А" diff --git a/tasmota/language/zh-CN.h b/tasmota/language/zh-CN.h index 68fdafbca..c59cb7a57 100644 --- a/tasmota/language/zh-CN.h +++ b/tasmota/language/zh-CN.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "安" diff --git a/tasmota/language/zh-TW.h b/tasmota/language/zh-TW.h index bc3a537fc..6ef104bec 100644 --- a/tasmota/language/zh-TW.h +++ b/tasmota/language/zh-TW.h @@ -663,7 +663,7 @@ #define D_SENSOR_CC1101_GDO0 "CC1101 GDO0" #define D_SENSOR_CC1101_GDO2 "CC1101 GDO2" #define D_SENSOR_HRXL_RX "HRXL Rx" -#define D_SENSOR_ELECTRIQ_MOODL "ElectriQ MOODL Tx" +#define D_SENSOR_ELECTRIQ_MOODL "MOODL Tx" // Units #define D_UNIT_AMPERE "安" From a9372fae06b775729943595e110e9311022a186c Mon Sep 17 00:00:00 2001 From: Ian King Date: Wed, 18 Mar 2020 10:30:52 +0000 Subject: [PATCH 08/11] Fix typo in GPIO define name --- tasmota/tasmota_template.h | 4 ++-- tasmota/xlgt_06_electriq_moodl.ino | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index 15c1c1503..4715f682f 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -225,7 +225,7 @@ enum UserSelectablePins { GPIO_CC1101_GDO0, // CC1101 pin for RX GPIO_CC1101_GDO2, // CC1101 pin for RX GPIO_HRXL_RX, // Data from MaxBotix HRXL sonar range sensor - GPIO_ELECTRIC_MOODL_TX, // ElectriQ iQ-wifiMOODL Serial TX + GPIO_ELECTRIQ_MOODL_TX, // ElectriQ iQ-wifiMOODL Serial TX GPIO_SENSOR_END }; // Programmer selectable GPIO functionality @@ -614,7 +614,7 @@ const uint8_t kGpioNiceList[] PROGMEM = { GPIO_EXS_ENABLE, // EXS MCU Enable #endif #ifdef USE_ELECTRIQ_MOODL - GPIO_ELECTRIC_MOODL_TX, + GPIO_ELECTRIQ_MOODL_TX, #endif #endif // USE_LIGHT diff --git a/tasmota/xlgt_06_electriq_moodl.ino b/tasmota/xlgt_06_electriq_moodl.ino index f90d3eefb..0ece53dd6 100644 --- a/tasmota/xlgt_06_electriq_moodl.ino +++ b/tasmota/xlgt_06_electriq_moodl.ino @@ -71,7 +71,7 @@ bool ElectriqMoodLSetChannels(void) void ElectriqMoodLModuleSelected(void) { - if (pin[GPIO_ELECTRIC_MOODL_TX] < 99) { + if (pin[GPIO_ELECTRIQ_MOODL_TX] < 99) { SetSerial(9600, TS_SERIAL_8N1); light_type = LT_RGBW; light_flg = XLGT_06; From 7049c33b40a9dd3b3c7b71130056d1bc9a9b9afd Mon Sep 17 00:00:00 2001 From: Ian King Date: Wed, 18 Mar 2020 10:58:19 +0000 Subject: [PATCH 09/11] Disable ELECTRIQ_MOODL by default as it's a niche product --- BUILDS.md | 2 +- tasmota/tasmota_post.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILDS.md b/BUILDS.md index f63d29bb8..d1ac73db9 100644 --- a/BUILDS.md +++ b/BUILDS.md @@ -53,7 +53,7 @@ | USE_SM16716 | - | - | x | x | x | - | x | | USE_SM2135 | - | - | x | x | x | - | x | | USE_SONOFF_L1 | - | - | x | x | x | - | x | -| USE_ELECTRIQ_MOODL | - | - | x | x | x | - | x | +| USE_ELECTRIQ_MOODL | - | - | - | - | - | - | - | | | | | | | | | | | USE_ENERGY_SENSOR | - | x | x | x | x | - | - | | USE_PZEM004T | - | - | x | x | x | - | - | diff --git a/tasmota/tasmota_post.h b/tasmota/tasmota_post.h index aaa3e8a89..dfdf6f3f8 100644 --- a/tasmota/tasmota_post.h +++ b/tasmota/tasmota_post.h @@ -134,7 +134,7 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack #define USE_SM16716 // Add support for SM16716 RGB LED controller (+0k7 code) #define USE_SM2135 // Add support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #define USE_SONOFF_L1 // Add support for Sonoff L1 led control -#define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller +//#define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller #define USE_COUNTER // Enable counters #undef USE_ADC_VCC // Add Analog input on selected devices From 18729bcc41292ad10b6b1870e0465b1bfbe85aad Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 18 Mar 2020 12:32:13 +0100 Subject: [PATCH 10/11] Add support for ElectriQ iQ-wifiMOODL Add support for ElectriQ iQ-wifiMOODL RGBW light by ianbyte (#7947) --- BUILDS.md | 2 +- RELEASENOTES.md | 1 + tasmota/CHANGELOG.md | 3 ++- tasmota/my_user_config.h | 2 +- tasmota/tasmota_post.h | 2 +- tasmota/xlgt_06_electriq_moodl.ino | 9 ++++----- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/BUILDS.md b/BUILDS.md index d1ac73db9..f63d29bb8 100644 --- a/BUILDS.md +++ b/BUILDS.md @@ -53,7 +53,7 @@ | USE_SM16716 | - | - | x | x | x | - | x | | USE_SM2135 | - | - | x | x | x | - | x | | USE_SONOFF_L1 | - | - | x | x | x | - | x | -| USE_ELECTRIQ_MOODL | - | - | - | - | - | - | - | +| USE_ELECTRIQ_MOODL | - | - | x | x | x | - | x | | | | | | | | | | | USE_ENERGY_SENSOR | - | x | x | x | x | - | - | | USE_PZEM004T | - | - | x | x | x | - | - | diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 711bb69c1..7f462dd04 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -124,3 +124,4 @@ The following binary downloads have been compiled with ESP8266/Arduino library c - Add support for Jarolift rollers by Keeloq algorithm - Add support for MaxBotix HRXL-MaxSonar ultrasonic range finders by Jon Little (#7814) - Add support for HDC1080 Temperature and Humidity sensor by Luis Teixeira (#7888) +- Add support for ElectriQ iQ-wifiMOODL RGBW light by ianbyte (#7947) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 9c8d258de..d32269e10 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -2,13 +2,14 @@ ### 8.1.0.11 20200313 +- Change Zigbee simplification of devices probing, saving Flash and memory - Add HAss Discovery support for Button and Switch triggers by Federico Leoni (#7901) - Add support for HDC1080 Temperature and Humidity sensor by Luis Teixeira (#7888) - Add commands ``SwitchMode 13`` PushOn and ``SwitchMode 14`` PushOnInverted (#7912) - Add command ``HumOffset -10.0 .. 10.0`` to set global humidity sensor offset (#7934) - Add Zigbee support for Hue emulation by Stefan Hadinger - Add Dew Point to Temperature and Humidity sensors -- Change Zigbee simplification of devices probing, saving Flash and memory +- Add support for ElectriQ iQ-wifiMOODL RGBW light by ianbyte (#7947) ### 8.1.0.10 20200227 diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 568ece036..ab80c4cf6 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -431,7 +431,7 @@ #define USE_SM16716 // Add support for SM16716 RGB LED controller (+0k7 code) #define USE_SM2135 // Add support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #define USE_SONOFF_L1 // Add support for Sonoff L1 led control -#define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller +#define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller (+0k3 code) // -- Counter input ------------------------------- #define USE_COUNTER // Enable inputs as counter (+0k8 code) diff --git a/tasmota/tasmota_post.h b/tasmota/tasmota_post.h index 07a986e0b..a6dac7fdb 100644 --- a/tasmota/tasmota_post.h +++ b/tasmota/tasmota_post.h @@ -135,7 +135,7 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack #define USE_SM16716 // Add support for SM16716 RGB LED controller (+0k7 code) #define USE_SM2135 // Add support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) #define USE_SONOFF_L1 // Add support for Sonoff L1 led control -//#define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller +#define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller #define USE_COUNTER // Enable counters #undef USE_ADC_VCC // Add Analog input on selected devices diff --git a/tasmota/xlgt_06_electriq_moodl.ino b/tasmota/xlgt_06_electriq_moodl.ino index 0ece53dd6..7e972f968 100644 --- a/tasmota/xlgt_06_electriq_moodl.ino +++ b/tasmota/xlgt_06_electriq_moodl.ino @@ -1,7 +1,7 @@ /* xlgt_06_moodlamp.ino - ElectriQ iQ-wifiMOODL LED support for Tasmota - Copyright (C) 2020 Theo Arends + Copyright (C) 2020 ianbyte and Theo Arends This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,7 +19,6 @@ #ifdef USE_LIGHT #ifdef USE_ELECTRIQ_MOODL - /*********************************************************************************************\ * ElectriQ iQ-wifiMOODL * This RGBW mood lamp uses the TYWE3S module to transmit via UART to an unmarked MCU which @@ -27,11 +26,11 @@ * The MCU appears to use a modified/undocumented version of the TuyaMCU protocol. * The main PCB has 2 daughter boards which hold the RGBW LEDs - an upper deck and a lower deck. * The same RGBW data is transmitted to the upper and lower decks. - * *********************************************************************************************/ +\*********************************************************************************************/ #define XLGT_06 6 -/********************************************************************************************/ +/*********************************************************************************************/ bool ElectriqMoodLSetChannels(void) { @@ -75,7 +74,7 @@ void ElectriqMoodLModuleSelected(void) SetSerial(9600, TS_SERIAL_8N1); light_type = LT_RGBW; light_flg = XLGT_06; - AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DBG: ElectriQ Mood Lamp Found")); + AddLog_P2(LOG_LEVEL_DEBUG, PSTR("LGT: ElectriQ Mood Lamp Found")); } } From d646bcdc7acea72b0deed282e2bf7b3f67d1b8f4 Mon Sep 17 00:00:00 2001 From: Federico Leoni Date: Wed, 18 Mar 2020 11:02:20 -0300 Subject: [PATCH 11/11] Update xdrv_12_home_assistant.ino --- tasmota/xdrv_12_home_assistant.ino | 85 ++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 27 deletions(-) diff --git a/tasmota/xdrv_12_home_assistant.ino b/tasmota/xdrv_12_home_assistant.ino index 8e7c229b9..e3ba4670d 100644 --- a/tasmota/xdrv_12_home_assistant.ino +++ b/tasmota/xdrv_12_home_assistant.ino @@ -23,30 +23,31 @@ // List of sensors ready for discovery const char kHAssJsonSensorTypes[] PROGMEM = - D_JSON_TEMPERATURE "|" D_JSON_PRESSURE "|" D_JSON_PRESSUREATSEALEVEL "|" + D_JSON_TEMPERATURE "|" D_JSON_DEWPOINT "|" D_JSON_PRESSURE "|" D_JSON_PRESSUREATSEALEVEL "|" D_JSON_APPARENT_POWERUSAGE "|Battery|" D_JSON_CURRENT "|" D_JSON_DISTANCE "|" D_JSON_FREQUENCY "|" D_JSON_HUMIDITY "|" D_JSON_ILLUMINANCE "|" D_JSON_MOISTURE "|PB0.3|PB0.5|PB1|PB2.5|PB5|PB10|PM1|PM2.5|PM10|" D_JSON_POWERFACTOR "|" D_JSON_POWERUSAGE "|" - D_JSON_REACTIVE_POWERUSAGE "|" D_JSON_TODAY "|" D_JSON_TOTAL "|" D_JSON_VOLTAGE "|" D_JSON_WEIGHT "|" D_JSON_YESTERDAY - D_JSON_CO2 "|" D_JSON_ECO2 "|" D_JSON_TVOC; + D_JSON_REACTIVE_POWERUSAGE "|" D_JSON_TODAY "|" D_JSON_TOTAL "|" D_JSON_VOLTAGE "|" D_JSON_WEIGHT "|" D_JSON_YESTERDAY "|" + D_JSON_CO2 "|" D_JSON_ECO2 "|" D_JSON_TVOC "|"; const char kHAssJsonSensorUnits[] PROGMEM = - "|||" + "||||" "VA|%|A|Cm|Hz|%|LX|" "%|ppd|ppd|ppd|ppd|ppd|ppd|µg/m³|µg/m³|µg/m³|Cos φ|W|" "VAr|kWh|kWh|V|Kg|kWh|" "ppm|ppm|ppb|"; const char kHAssJsonSensorDevCla[] PROGMEM = - "dev_cla\":\"temperature|dev_cla\":\"pressure|dev_cla\":\"pressure|" + "dev_cla\":\"temperature|ic\":\"mdi:weather-rainy|dev_cla\":\"pressure|dev_cla\":\"pressure|" "dev_cla\":\"power|dev_cla\":\"battery|ic\":\"mdi:alpha-a-circle-outline|ic\":\"mdi:leak|ic\":\"mdi:current-ac|dev_cla\":\"humidity|dev_cla\":\"illuminance|" "ic\":\"mdi:cup-water|ic\":\"mdi:flask|ic\":\"mdi:flask|ic\":\"mdi:flask|ic\":\"mdi:flask|ic\":\"mdi:flask|ic\":\"mdi:flask|" "ic\":\"mdi:air-filter|ic\":\"mdi:air-filter|ic\":\"mdi:air-filter|ic\":\"mdi:alpha-f-circle-outline|dev_cla\":\"power|" - "dev_cla\":\"power|dev_cla\":\"power|dev_cla\":\"power|ic\":\"mdi:alpha-v-circle-outline|ic\":\"mdi:scale|dev_cla\":\"power" - "ic\":\"mdi:periodic-table-co2|ic\":\"mdi:air-filter|ic\":\"mdi:periodic-table-co2"; + "dev_cla\":\"power|dev_cla\":\"power|dev_cla\":\"power|ic\":\"mdi:alpha-v-circle-outline|ic\":\"mdi:scale|dev_cla\":\"power|" + "ic\":\"mdi:periodic-table-co2|ic\":\"mdi:air-filter|ic\":\"mdi:periodic-table-co2|"; + //"ic\":\"mdi:weather-windy|ic\":\"mdi:weather-windy|ic\":\"mdi:weather-windy|ic\":\"mdi:weather-windy|" // List of sensors ready for discovery const char HASS_DISCOVER_SENSOR[] PROGMEM = ",\"unit_of_meas\":\"%s\",\"%s\"," // unit of measure and class (or icon) "\"frc_upd\":true," // force update for better graph representation - "\"val_tpl\":\"{{value_json['%s']['%s']"; // "COUNTER":{"C1":0} -> {{ value_json['COUNTER'].['C1'] + "\"val_tpl\":\"{{value_json['%s']['%s']"; // "COUNTER":{"C1":0} -> {{ value_json['COUNTER']['C1'] const char HASS_DISCOVER_BASE[] PROGMEM = "{\"name\":\"%s\"," // dualr2 1 @@ -369,6 +370,8 @@ void HAssAnnounceSwitches(void) // INV (not available) CLEAR (not available) // 12 PUSHHOLDMULTI_INV NO TOGGLE (button_short_press) NONE CLEAR (button_long_press) 1,0 // INV (not available) INC_DEC (not available) + // 13 PUSHON YES NONE NONE NONE 0,0 + // 14 PUSHON_INV YES NONE NONE NONE 0,0 // Please note: SwitchMode11 and 12 will register just TOGGLE (button_short_press) // Trigger types: "0 = none | 1 = button_short_press | 2 = button_long_press | 3 = button_double_press"; @@ -469,17 +472,20 @@ void HAssAnnounceButtons(void) } } -void HAssAnnounceSensor(const char *sensorname, const char *subsensortype, const char *MultiSubName, uint8_t subqty, uint8_t subidx) +void HAssAnnounceSensor(const char *sensorname, const char *subsensortype, const char *MultiSubName, uint8_t subqty, uint8_t subidx, uint8_t nested, const char* SubKey) { char stopic[TOPSZ]; char stemp1[TOPSZ]; char stemp2[TOPSZ]; char unique_id[30]; + char subname[20]; mqtt_data[0] = '\0'; // Clear retained message - // Clear or Set topic - snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%s"), ESP.getChipId(), sensorname, MultiSubName); - snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/sensor/%s/config"), unique_id);; + + // Clear or Set topic + NoAlNumToUnderscore(subname, MultiSubName); //Replace all non alphaumeric characters to '_' to avoid topic name issues + snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%s"), ESP.getChipId(), sensorname, subname); + snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/sensor/%s/config"), unique_id); if (Settings.flag.hass_discovery) { // SetOption19 - Control Home Assistantautomatic discovery (See SetOption59) @@ -497,28 +503,44 @@ void HAssAnnounceSensor(const char *sensorname, const char *subsensortype, const char jname[32]; - int sensor_index = GetCommandCode(jname, sizeof(jname), subsensortype, kHAssJsonSensorTypes); + int sensor_index = GetCommandCode(jname, sizeof(jname), SubKey, kHAssJsonSensorTypes); if (sensor_index > -1) { + char param1[20]; GetTextIndexed(param1, sizeof(param1), sensor_index, kHAssJsonSensorUnits); switch (sensor_index) { - case 0: // Temperature + case 0: // Temperature and DewPoint + case 1: snprintf_P(param1, sizeof(param1), PSTR("°%c"),TempUnit()); // C or F break; - case 1: // Pressure - case 2: + case 2: // Pressure and Sea Level Pressure + case 3: snprintf_P(param1, sizeof(param1), PSTR("%s"), PressureUnit().c_str()); break; - } + // case 4: // Speed. Default to km/h if not set to have a graph representation under HAss + // case 5: + // case 6: + // case 7: + // if (Settings.flag2.speed_conversion == 0) { + // snprintf_P(param1, sizeof(param1), PSTR("km/h")); + // } else { + // snprintf_P(param1, sizeof(param1), PSTR("%s"), SpeedUnit().c_str()); + // } + // break; + } char param2[50]; GetTextIndexed(param2, sizeof(param2), sensor_index, kHAssJsonSensorDevCla); TryResponseAppend_P(HASS_DISCOVER_SENSOR, param1, param2, sensorname, subsensortype); + if (subidx) { TryResponseAppend_P(PSTR("[%d]"), subqty -1); } } else { TryResponseAppend_P(HASS_DISCOVER_SENSOR, " ", "ic\":\"mdi:eye", sensorname, subsensortype); } + if (nested) { + TryResponseAppend_P(PSTR("['%s']"), SubKey); + } TryResponseAppend_P(PSTR("}}\"}")); } MqttPublish(stopic, true); @@ -527,8 +549,6 @@ void HAssAnnounceSensor(const char *sensorname, const char *subsensortype, const void HAssAnnounceSensors(void) { uint8_t hass_xsns_index = 0; - bool is_sensor = true; - uint8_t subqty = 0; do { mqtt_data[0] = '\0'; @@ -545,7 +565,8 @@ void HAssAnnounceSensors(void) sensordata[0] = '{'; snprintf_P(sensordata, sizeof(sensordata), PSTR("%s}"), sensordata); // {"INA219":{"Voltage":4.494,"Current":0.020,"Power":0.089}} // USE THE FOLLOWING LINE TO TEST JSON - //snprintf_P(sensordata, sizeof(sensordata), PSTR("{\"HX711\":{\"Weight\":[22,34,1023.4], \"Battery\":25}}")); + //snprintf_P(sensordata, sizeof(sensordata), PSTR("{\"HX711\":{\"Weight\":[22,34,1023.4]}}")); + //snprintf_P(sensordata, sizeof(sensordata), PSTR("{\"TX23\":{\"Speed\":{\"Act\":8.6,\"Avg\":8.2,\"Min\":0,\"Max\":15.8},\"Dir\":{\"Card\":\"SSO\",\"Deg\":157.5,\"Avg\":145.5,\"AvgCard\":\"SO\",\"Min\":112.5,\"Max\":292.5,\"Range\":180}}}")); StaticJsonBuffer<500> jsonBuffer; JsonObject &root = jsonBuffer.parseObject(sensordata); @@ -563,19 +584,29 @@ void HAssAnnounceSensors(void) AddLog_P2(LOG_LEVEL_ERROR, PSTR("HASS: JsonObject failed to parse '%s'"), sensordata); continue; } + for (auto subsensor : sensors) { - // If there is more than a value on sensor data, 'n' entitites will be created - if (subsensor.value.is()) { + if (subsensor.value.is()) { + // If there is a nested json on sensor data, second level entitites will be created + char NestedName[20]; + char NewSensorName[20]; + snprintf_P(NestedName, sizeof(NestedName), PSTR("%s"), subsensor.key); + JsonObject& subsensors = subsensor.value.as(); + for (auto subsensor : subsensors) { + snprintf_P(NewSensorName, sizeof(NewSensorName), PSTR("%s %s"), NestedName, subsensor.key); + HAssAnnounceSensor(sensorname, NestedName, NewSensorName, 0, 0, 1, subsensor.key); + } + } else if (subsensor.value.is()) { + // If there is more than a value on sensor data, 'n' entitites will be created JsonArray& subsensors = subsensor.value.as(); - subqty = subsensors.size(); + uint8_t subqty = subsensors.size(); char MultiSubName[20]; for (int i = 1; i <= subqty; i++) { - snprintf_P(MultiSubName, sizeof(MultiSubName), PSTR("%s_%d"), subsensor.key, i); - HAssAnnounceSensor(sensorname, subsensor.key, MultiSubName, i, 1); - + snprintf_P(MultiSubName, sizeof(MultiSubName), PSTR("%s %d"), subsensor.key, i); + HAssAnnounceSensor(sensorname, subsensor.key, MultiSubName, i, 1, 0, subsensor.key); } - } else { HAssAnnounceSensor(sensorname, subsensor.key, subsensor.key, 0, 0);} + } else { HAssAnnounceSensor(sensorname, subsensor.key, subsensor.key, 0, 0, 0, subsensor.key);} } } }