diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 56c3a65b1..0a6e1fbcb 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -52,7 +52,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c ## Changelog -### Version 8.1.0.10 +### Version 8.1.0.11 - Change default my_user_config.h driver and sensor support removing most sensors and adding most drivers - Change DHT driver (#7468, #7717) @@ -116,3 +116,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 Romanian language translations by Augustin Marti +- Add HAss Discovery support for Button and Switch triggers by Federico Leoni (#7901) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 1ab3a02dd..11d730543 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -1,5 +1,9 @@ ## Unreleased (development) +### 8.1.0.11 20200313 + +- Add HAss Discovery support for Button and Switch triggers by Federico Leoni (#7901) + ### 8.1.0.10 20200227 - Change default my_user_config.h driver and sensor support removing most sensors and adding most drivers diff --git a/tasmota/tasmota_version.h b/tasmota/tasmota_version.h index b9b08b46e..636018ddc 100644 --- a/tasmota/tasmota_version.h +++ b/tasmota/tasmota_version.h @@ -20,7 +20,7 @@ #ifndef _TASMOTA_VERSION_H_ #define _TASMOTA_VERSION_H_ -const uint32_t VERSION = 0x0801000A; +const uint32_t VERSION = 0x0801000B; // Lowest compatible version const uint32_t VERSION_COMPATIBLE = 0x07010006; diff --git a/tasmota/xdrv_02_mqtt.ino b/tasmota/xdrv_02_mqtt.ino index 2a15c33df..adda72868 100644 --- a/tasmota/xdrv_02_mqtt.ino +++ b/tasmota/xdrv_02_mqtt.ino @@ -712,13 +712,6 @@ void MqttCheck(void) } } -bool ButtonTopicActive(void) -{ - char key_topic[TOPSZ]; - Format(key_topic, SettingsText(SET_MQTT_BUTTON_TOPIC), sizeof(key_topic)); - return ((strlen(key_topic) != 0) && strcmp(key_topic, "0")); -} - bool KeyTopicActive(uint32_t key) { // key = 0 - Button topic diff --git a/tasmota/xdrv_12_home_assistant.ino b/tasmota/xdrv_12_home_assistant.ino index 30fa0a04c..4e002a220 100644 --- a/tasmota/xdrv_12_home_assistant.ino +++ b/tasmota/xdrv_12_home_assistant.ino @@ -1,7 +1,7 @@ /* xdrv_12_home_assistant.ino - home assistant support for Tasmota - Copyright (C) 2020 Theo Arends + Copyright (C) 2020 Erik Montnemery, Federico Leoni 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 @@ -339,7 +339,7 @@ void HAssAnnounceSwitches(void) uint8_t hold = 0; if (pin[GPIO_SWT1 + switch_index] < 99) { switch_present = 1; } - + if (KeyTopicActive(1) && strcmp(SettingsText(SET_MQTT_SWITCH_TOPIC), mqtt_topic)) // Enable Discovery for Switches only if Switchtopic is set to a custom name { @@ -361,7 +361,7 @@ void HAssAnnounceSwitches(void) // 12 PUSHHOLDMULTI_INV NO TOGGLE (button_short_press) NONE CLEAR (button_long_press) 1,0 // INV (not available) INC_DEC (not available) // 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"; uint8_t swmode = Settings.switchmode[switch_index]; @@ -390,7 +390,7 @@ void HAssAnnounceSwitches(void) hold = 3; break; } - + } else { switch_present = 0;} HAssAnnouncerTriggers(switch_index, switch_present, 1, toggle, hold); @@ -431,7 +431,7 @@ void HAssAnnounceButtons(void) if (Settings.flag.button_restrict) { // [SetOption1] Enable/Disable button multipress if (!Settings.flag.button_single) { - hold = 2; // Default TOGGLE (button_short_press) + HOLD (button_long_press) trigger if [SetOption13] is OFF + hold = 2; // Default TOGGLE (button_short_press) + HOLD (button_long_press) trigger if [SetOption13] is OFF } } @@ -440,19 +440,19 @@ void HAssAnnounceButtons(void) if (!Settings.flag.button_restrict) { hold = 0; // TOGGLE (button_double_press) and remove HOLD (button_long_press) trigger if [SetOption1] is OFF } - toggle = 3; // TOGGLE (button_double_press) + toggle = 3; // TOGGLE (button_double_press) } else {toggle = 0; hold = 0;} // [SetOption13] Immediate action on button press, no TOGGLE or HOLD triggers } - + if (KeyTopicActive(0)) { // Enable Discovery for Buttons only if Buttontopic is set to 1 or a custom name if (!strcmp(SettingsText(SET_MQTT_BUTTON_TOPIC), mqtt_topic)) { - toggle = 0; // When ButtonTopic is set to 1, TOGGLE is not allowed but an HOLD trigger can be generated. - } - + toggle = 0; // When ButtonTopic is set to 1, TOGGLE is not allowed but an HOLD trigger can be generated. + } + } else { button_present = 0; } - - HAssAnnouncerTriggers(button_index, button_present, 0, toggle, hold); + + HAssAnnouncerTriggers(button_index, button_present, 0, toggle, hold); } }