From 057ff372638b4d9723ec0e7ccda1bfa6d52ce989 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 12 Mar 2020 12:11:33 +0100 Subject: [PATCH] Add function KeyTopicActive(key) Add function KeyTopicActive(key) --- tasmota/xdrv_02_mqtt.ino | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tasmota/xdrv_02_mqtt.ino b/tasmota/xdrv_02_mqtt.ino index c766ab247..2a15c33df 100644 --- a/tasmota/xdrv_02_mqtt.ino +++ b/tasmota/xdrv_02_mqtt.ino @@ -719,6 +719,16 @@ bool ButtonTopicActive(void) return ((strlen(key_topic) != 0) && strcmp(key_topic, "0")); } +bool KeyTopicActive(uint32_t key) +{ + // key = 0 - Button topic + // key = 1 - Switch topic + key &= 1; + char key_topic[TOPSZ]; + Format(key_topic, SettingsText(SET_MQTT_BUTTON_TOPIC + key), sizeof(key_topic)); + return ((strlen(key_topic) != 0) && strcmp(key_topic, "0")); +} + /*********************************************************************************************\ * Commands \*********************************************************************************************/