From 6ddb14bc6a0cf8c947cab44c58e358ae35841509 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 1 Sep 2021 09:42:10 +0200 Subject: [PATCH] Add Command ``SetOption2 1`` Add Command ``SetOption2 1`` to enable display of global temperature/humidity/pressure info to JSON sensor message --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + tasmota/settings.h | 2 +- tasmota/support_tasmota.ino | 2 +- tools/decode-status.py | 4 ++-- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e86acef39..0a6e3102d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file. - Support for Hydreon RG-15 Solid State Rain sensor (#12974) - Support for IKEA VINDRIKTNING particle concentration sensor (#12976) - Berry support for Curve 25519 EC crypto +- Command ``SetOption2 1`` to enable display of global temperature/humidity/pressure info to JSON sensor message ### Changed - Shelly EM template needs to use GPIO ADE7953_IRQ_2 diff --git a/RELEASENOTES.md b/RELEASENOTES.md index ea38f6d5c..efd6c2d38 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -101,6 +101,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo ## Changelog v9.5.0.7 ### Added - Release of [Tasmota WebInstaller](https://arendst.github.io/Tasmota-firmware/) +- Command ``SetOption2 1`` to enable display of global temperature/humidity/pressure info to JSON sensor message - Command ``SetOption127 1`` to force Wi-Fi in no-sleep mode even if ``Sleep 0`` is not enabled - Command ``SetOption128 0|1`` web referer check disabling HTTP API commands if set to 0. Default set to 1 for backward compatibility [#12828](https://github.com/arendst/Tasmota/issues/12828) - Command ``SetSensor1..127 0|1`` to globally disable individual sensor driver diff --git a/tasmota/settings.h b/tasmota/settings.h index 9fb21e886..2ceb536b4 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -28,7 +28,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu struct { // SetOption0 .. SetOption31 uint32_t save_state : 1; // bit 0 - SetOption0 - (Settings) Save power state (1) and use after restart uint32_t button_restrict : 1; // bit 1 - SetOption1 - (Button) Control button single press (1) or multipress (0) - uint32_t ex_value_units : 1; // bit 2 - SetOption2 - (not used) Add units to JSON status messages - removed 6.6.0.21 + uint32_t mqtt_add_global_info : 1; // bit 2 - SetOption2 - (MQTT) Add global temperature/humidity/pressure info to JSON sensor message uint32_t mqtt_enabled : 1; // bit 3 - SetOption3 - (MQTT) Enable (1) uint32_t mqtt_response : 1; // bit 4 - SetOption4 - (MQTT) Switch between RESULT (0) or COMMAND (1) uint32_t mqtt_power_retain : 1; // bit 5 - CMND_POWERRETAIN diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index af5a9075e..31b4e0e17 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -844,7 +844,7 @@ bool MqttShowSensor(void) XsnsCall(FUNC_JSON_APPEND); XdrvCall(FUNC_JSON_APPEND); - if (TasmotaGlobal.global_update) { + if (TasmotaGlobal.global_update && Settings->flag.mqtt_add_global_info) { if ((TasmotaGlobal.humidity > 0) || !isnan(TasmotaGlobal.temperature_celsius) || (TasmotaGlobal.pressure_hpa != 0)) { uint32_t add_comma = 0; ResponseAppend_P(PSTR(",\"Global\":{")); diff --git a/tools/decode-status.py b/tools/decode-status.py index ffbbca5b0..e406bd6e0 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -52,7 +52,7 @@ a_on_off = ["OFF","ON "] a_setoption = [[ "(Settings) Save power state (1) and use after restart", "(Button) Control button single press (1) or multipress (0)", - "(Not used) Add units to JSON status messages", + "(MQTT) Add global temperature/humidity/pressure info to JSON sensor message", "(MQTT) Enable (1)", "(MQTT) Switch between RESULT (0) or COMMAND (1)", "(MQTT) Retain on Power", @@ -288,7 +288,7 @@ else: obj = json.load(fp) def StartDecode(): - print ("\n*** decode-status.py v20210826 by Theo Arends and Jacek Ziolkowski ***") + print ("\n*** decode-status.py v20210901 by Theo Arends and Jacek Ziolkowski ***") # print("Decoding\n{}".format(obj))