diff --git a/CHANGELOG.md b/CHANGELOG.md index a6c34906a..336c85abe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. - Berry support for vararg - Command ``Subscribe2 ...`` to subscribe to a MQTT topic without appended "/#" (#12858) - Support for Hydreon RG-15 Solid State Rain sensor (#12974) +- Support for IKEA VINDRIKTNING particle concentration sensor (#12976) ### Changed - Shelly EM template needs to use GPIO ADE7953_IRQ_2 diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 4af686e81..f87825dd6 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -123,6 +123,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo - Command ``Subscribe2 ...`` to subscribe to a MQTT topic without appended "/#" [#12858](https://github.com/arendst/Tasmota/issues/12858) - Support for IEM3155 Wattmeter [#12940](https://github.com/arendst/Tasmota/issues/12940) - Support for Hydreon RG-15 Solid State Rain sensor [#12974](https://github.com/arendst/Tasmota/issues/12974) +- Support for IKEA VINDRIKTNING particle concentration sensor [#12976](https://github.com/arendst/Tasmota/issues/12976) ### Changed - Move firmware binaries to https://github.com/arendst/Tasmota-firmware/tree/main/release-firmware diff --git a/tasmota/language/af_AF.h b/tasmota/language/af_AF.h index 18d3fd4b8..766f31d6a 100644 --- a/tasmota/language/af_AF.h +++ b/tasmota/language/af_AF.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/bg_BG.h b/tasmota/language/bg_BG.h index 6b256c80c..358390bc9 100644 --- a/tasmota/language/bg_BG.h +++ b/tasmota/language/bg_BG.h @@ -837,6 +837,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/cs_CZ.h b/tasmota/language/cs_CZ.h index c37b21952..be7396a92 100644 --- a/tasmota/language/cs_CZ.h +++ b/tasmota/language/cs_CZ.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/de_DE.h b/tasmota/language/de_DE.h index 29ab0818d..fdee2f6c3 100644 --- a/tasmota/language/de_DE.h +++ b/tasmota/language/de_DE.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/el_GR.h b/tasmota/language/el_GR.h index e49a964ea..d18aa9bce 100644 --- a/tasmota/language/el_GR.h +++ b/tasmota/language/el_GR.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/en_GB.h b/tasmota/language/en_GB.h index ba6b11cd0..2caab6abc 100644 --- a/tasmota/language/en_GB.h +++ b/tasmota/language/en_GB.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/es_ES.h b/tasmota/language/es_ES.h index d41a70ac1..c5d98d79e 100644 --- a/tasmota/language/es_ES.h +++ b/tasmota/language/es_ES.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/fr_FR.h b/tasmota/language/fr_FR.h index ec04ab26b..bd63fc53f 100644 --- a/tasmota/language/fr_FR.h +++ b/tasmota/language/fr_FR.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/fy_NL.h b/tasmota/language/fy_NL.h index 7b2e0b366..86e0fb7d2 100644 --- a/tasmota/language/fy_NL.h +++ b/tasmota/language/fy_NL.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/he_HE.h b/tasmota/language/he_HE.h index 68f324a8c..efd02b2f4 100644 --- a/tasmota/language/he_HE.h +++ b/tasmota/language/he_HE.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/hu_HU.h b/tasmota/language/hu_HU.h index 7455ee7f6..3da61ccc6 100644 --- a/tasmota/language/hu_HU.h +++ b/tasmota/language/hu_HU.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/it_IT.h b/tasmota/language/it_IT.h index 7fe20f02d..2d80dea18 100644 --- a/tasmota/language/it_IT.h +++ b/tasmota/language/it_IT.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 - CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/ko_KO.h b/tasmota/language/ko_KO.h index 86f9c0ea3..d427966cd 100644 --- a/tasmota/language/ko_KO.h +++ b/tasmota/language/ko_KO.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/nl_NL.h b/tasmota/language/nl_NL.h index 46243e5e7..56015b023 100644 --- a/tasmota/language/nl_NL.h +++ b/tasmota/language/nl_NL.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/pl_PL.h b/tasmota/language/pl_PL.h index 7d2ccf154..7f9b79727 100644 --- a/tasmota/language/pl_PL.h +++ b/tasmota/language/pl_PL.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/pt_BR.h b/tasmota/language/pt_BR.h index ed2812cc8..83a9d88c3 100644 --- a/tasmota/language/pt_BR.h +++ b/tasmota/language/pt_BR.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/pt_PT.h b/tasmota/language/pt_PT.h index 4853fdd0a..831563664 100644 --- a/tasmota/language/pt_PT.h +++ b/tasmota/language/pt_PT.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/ro_RO.h b/tasmota/language/ro_RO.h index 88f9a99f9..b1058e60d 100644 --- a/tasmota/language/ro_RO.h +++ b/tasmota/language/ro_RO.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/ru_RU.h b/tasmota/language/ru_RU.h index 6642506b1..b6fb1bc35 100644 --- a/tasmota/language/ru_RU.h +++ b/tasmota/language/ru_RU.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "А" diff --git a/tasmota/language/sk_SK.h b/tasmota/language/sk_SK.h index 7cbb51d2f..3ac233b00 100644 --- a/tasmota/language/sk_SK.h +++ b/tasmota/language/sk_SK.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/sv_SE.h b/tasmota/language/sv_SE.h index 9de80ed08..c026d53b6 100644 --- a/tasmota/language/sv_SE.h +++ b/tasmota/language/sv_SE.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/tr_TR.h b/tasmota/language/tr_TR.h index 6f236ed7f..5d2d969b4 100644 --- a/tasmota/language/tr_TR.h +++ b/tasmota/language/tr_TR.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/uk_UA.h b/tasmota/language/uk_UA.h index 68181966b..3be6240c2 100644 --- a/tasmota/language/uk_UA.h +++ b/tasmota/language/uk_UA.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "А" diff --git a/tasmota/language/vi_VN.h b/tasmota/language/vi_VN.h index 11a35daea..d1e855bec 100644 --- a/tasmota/language/vi_VN.h +++ b/tasmota/language/vi_VN.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/zh_CN.h b/tasmota/language/zh_CN.h index 3d6475d37..c9a64adac 100644 --- a/tasmota/language/zh_CN.h +++ b/tasmota/language/zh_CN.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/zh_TW.h b/tasmota/language/zh_TW.h index 08ac66206..2074f04f7 100644 --- a/tasmota/language/zh_TW.h +++ b/tasmota/language/zh_TW.h @@ -838,6 +838,7 @@ #define D_SENSOR_MCP2515_CS "MCP2515 CS" #define D_SENSOR_HRG15_RX "HRG15 Rx" #define D_SENSOR_HRG15_TX "HRG15 Tx" +#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING" // Units #define D_UNIT_AMPERE "安培" diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index bb6a5a45d..9c85c7549 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -744,6 +744,7 @@ // #define USE_AS608_MESSAGES // Add verbose error messages (+0k4 code) //#define USE_TFMINIPLUS // Add support for TFmini Plus (TFmini, TFmini-S) LiDAR modules via UART interface (+0k8) //#define USE_HRG15 // Add support for Hydreon RG-15 Solid State Rain sensor (+1k5 code) +//#define USE_VINDRIKTNING // Add support for IKEA VINDRIKTNING particle concentration sensor (+1k code) // -- Power monitoring sensors -------------------- #define USE_ENERGY_SENSOR // Add support for Energy Monitors (+14k code) diff --git a/tasmota/support_features.ino b/tasmota/support_features.ino index 68008637c..114809a00 100644 --- a/tasmota/support_features.ino +++ b/tasmota/support_features.ino @@ -765,7 +765,9 @@ void ResponseAppendFeatures(void) #ifdef USE_HRG15 feature8 |= 0x00001000; // xsns_90_hrg15.ino #endif -// feature8 |= 0x00002000; +#ifdef USE_VINDRIKTNING + feature8 |= 0x00002000; // xsns_91_vindriktning.ino +#endif // feature8 |= 0x00004000; // feature8 |= 0x00008000; diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index acede8653..cb8b664af 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -171,6 +171,7 @@ enum UserSelectablePins { GPIO_INTERRUPT, GPIO_MCP2515_CS, // MCP2515 Chip Select GPIO_HRG15_TX, GPIO_HRG15_RX, // Hydreon RG-15 rain sensor serial interface + GPIO_VINDRIKTNING_RX, // IKEA VINDRIKTNING Serial interface GPIO_SENSOR_END }; enum ProgramSelectablePins { @@ -361,7 +362,8 @@ const char kSensorNames[] PROGMEM = D_SENSOR_I2S_IN_DATA "|" D_SENSOR_I2S_IN_CLK "|" D_SENSOR_I2S_IN_SLCT "|" D_SENSOR_INTERRUPT "|" D_SENSOR_MCP2515_CS "|" - D_SENSOR_HRG15_TX "|" D_SENSOR_HRG15_RX + D_SENSOR_HRG15_TX "|" D_SENSOR_HRG15_RX "|" + D_SENSOR_VINDRIKTNING_RX ; const char kSensorNamesFixed[] PROGMEM = @@ -797,6 +799,9 @@ const uint16_t kGpioNiceList[] PROGMEM = { AGPIO(GPIO_HRG15_TX), AGPIO(GPIO_HRG15_RX), #endif +#ifdef USE_VINDRIKTNING + AGPIO(GPIO_VINDRIKTNING_RX), +#endif /*-------------------------------------------------------------------------------------------*\ * Other sensors diff --git a/tasmota/xsns_91_vindriktning.ino b/tasmota/xsns_91_vindriktning.ino new file mode 100644 index 000000000..640eeede9 --- /dev/null +++ b/tasmota/xsns_91_vindriktning.ino @@ -0,0 +1,170 @@ +/* + xsns_91_vindriktning.ino - IKEA vindriktning particle concentration sensor support for Tasmota + + Copyright (C) 2021 Marcel Ritter 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 + 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_VINDRIKTNING +/*********************************************************************************************\ + * IKEA VINDRIKTNING particle concentration sensor +\*********************************************************************************************/ + +#define XSNS_91 91 + +#include + +#ifndef MIN_INTERVAL_PERIOD +#define MIN_INTERVAL_PERIOD 60 // minimum interval period in seconds required for passive mode +#endif + +#define VINDRIKTNING_DATASET_SIZE 20 + +TasmotaSerial *VindriktningSerial; + +struct VINDRIKTNING { + uint16_t pm2_5 = 0; + uint16_t pm1_0 = 0; + uint16_t pm10 = 0; + uint8_t type = 1; + uint8_t valid = 0; + bool discovery_triggered = false; +} Vindriktning; + +bool VindriktningReadData(void) { + if (!VindriktningSerial->available()) { + return false; + } + + int serial_in_byte_counter = 0; + uint8_t buffer[VINDRIKTNING_DATASET_SIZE]; + uint8_t crc = 0; + + while (VindriktningSerial->available()) { + uint8_t serial_in_byte = VindriktningSerial->read(); + if (serial_in_byte_counter <= VINDRIKTNING_DATASET_SIZE -1) { + buffer[serial_in_byte_counter++] = serial_in_byte; + crc += serial_in_byte; + } + } + VindriktningSerial->flush(); // Make room for another burst + + AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, VINDRIKTNING_DATASET_SIZE); + + if (serial_in_byte_counter < VINDRIKTNING_DATASET_SIZE) { + AddLog(LOG_LEVEL_DEBUG, PSTR("VDN: Not enough data (%d < 20)"), serial_in_byte_counter); + return false; + } + + if (crc != 0) { + AddLog(LOG_LEVEL_DEBUG, PSTR("VDN: " D_CHECKSUM_FAILURE)); + return false; + } + + // sample data: + // 16 11 0b 00 00 00 0c 00 00 03 cb 00 00 00 0c 01 00 00 00 e7 + // |pm2_5| |pm1_0| |pm10 | | CRC | + Vindriktning.pm2_5 = (buffer[5] << 8) | buffer[6]; + Vindriktning.pm1_0 = (buffer[9] << 8) | buffer[10]; + Vindriktning.pm10 = (buffer[13] << 8) | buffer[14]; + + if (!Vindriktning.discovery_triggered) { + TasmotaGlobal.discovery_counter = 1; // force TasDiscovery() + Vindriktning.discovery_triggered = true; + } + return true; +} + +/*********************************************************************************************/ + +void VindriktningSecond(void) { // Every second + if (VindriktningReadData()) { + Vindriktning.valid = MIN_INTERVAL_PERIOD; + } else { + if (Vindriktning.valid) { + Vindriktning.valid--; + } + } +} + +/*********************************************************************************************/ + +void VindriktningInit(void) { + Vindriktning.type = 0; + if (PinUsed(GPIO_VINDRIKTNING_RX)) { + VindriktningSerial = new TasmotaSerial(Pin(GPIO_VINDRIKTNING_RX), -1, 1); + if (VindriktningSerial->begin(9600)) { + if (VindriktningSerial->hardwareSerial()) { ClaimSerial(); } + Vindriktning.type = 1; + } + } +} + +#ifdef USE_WEBSERVER +const char HTTP_VINDRIKTNING_SNS[] PROGMEM = + "{s}VINDRIKTNING " D_ENVIRONMENTAL_CONCENTRATION " 1.0 " D_UNIT_MICROMETER "{m}%d " D_UNIT_MICROGRAM_PER_CUBIC_METER "{e}" + "{s}VINDRIKTNING " D_ENVIRONMENTAL_CONCENTRATION " 2.5 " D_UNIT_MICROMETER "{m}%d " D_UNIT_MICROGRAM_PER_CUBIC_METER "{e}" + "{s}VINDRIKTNING " D_ENVIRONMENTAL_CONCENTRATION " 10 " D_UNIT_MICROMETER "{m}%d " D_UNIT_MICROGRAM_PER_CUBIC_METER "{e}"; // {s} = , {m} = , {e} = +#endif // USE_WEBSERVER + +void VindriktningShow(bool json) { + if (Vindriktning.valid) { + if (json) { + ResponseAppend_P(PSTR(",\"VINDRIKTNING\":{\"PM1\":%d,\"PM2.5\":%d,\"PM10\":%d}"), + Vindriktning.pm1_0, Vindriktning.pm2_5, Vindriktning.pm10); +#ifdef USE_DOMOTICZ + if (0 == TasmotaGlobal.tele_period) { + DomoticzSensor(DZ_COUNT, Vindriktning.pm1_0); // PM1.0 + DomoticzSensor(DZ_VOLTAGE, Vindriktning.pm2_5); // PM2.5 + DomoticzSensor(DZ_CURRENT, Vindriktning.pm10); // PM10 + } +#endif // USE_DOMOTICZ +#ifdef USE_WEBSERVER + } else { + WSContentSend_PD(HTTP_VINDRIKTNING_SNS, Vindriktning.pm1_0, Vindriktning.pm2_5, Vindriktning.pm10); +#endif // USE_WEBSERVER + } + } +} + +/*********************************************************************************************\ + * Interface +\*********************************************************************************************/ + +bool Xsns91(uint8_t function) { + bool result = false; + + if (Vindriktning.type) { + switch (function) { + case FUNC_EVERY_SECOND: + VindriktningSecond(); + break; + case FUNC_JSON_APPEND: + VindriktningShow(1); + break; +#ifdef USE_WEBSERVER + case FUNC_WEB_SENSOR: + VindriktningShow(0); + break; +#endif // USE_WEBSERVER + case FUNC_INIT: + VindriktningInit(); + break; + } + } + return result; +} + +#endif // USE_VINDRIKTNING \ No newline at end of file diff --git a/tools/decode-status.py b/tools/decode-status.py index a7c900ed9..ffbbca5b0 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -256,7 +256,7 @@ a_features = [[ "USE_MPU_ACCEL","USE_TFMINIPLUS","USE_CSE7761","USE_BERRY", "USE_BM8563","USE_ENERGY_DUMMY","USE_AM2320","USE_T67XX", "USE_MCP2515","USE_TASMESH","USE_WIFI_RANGE_EXTENDER","USE_INFLUXDB", - "USE_HRG15","","","", + "USE_HRG15","USE_VINDRIKTNING","","", "","","","", "","","","", "","","","", @@ -288,7 +288,7 @@ else: obj = json.load(fp) def StartDecode(): - print ("\n*** decode-status.py v20210825 by Theo Arends and Jacek Ziolkowski ***") + print ("\n*** decode-status.py v20210826 by Theo Arends and Jacek Ziolkowski ***") # print("Decoding\n{}".format(obj))