From 1fe183969014af3485d42d2ddd1d0c62916cca79 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 22 Jan 2019 16:07:16 +0100 Subject: [PATCH] Force Hass fulltopic change Force Hass fulltopic change (#4988) --- sonoff/xdrv_12_home_assistant.ino | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/sonoff/xdrv_12_home_assistant.ino b/sonoff/xdrv_12_home_assistant.ino index 1309f9e07..cbab0d2c5 100644 --- a/sonoff/xdrv_12_home_assistant.ino +++ b/sonoff/xdrv_12_home_assistant.ino @@ -469,14 +469,6 @@ void HAssAnnounceSensors(void) } while (hass_xsns_index != 0); } -static int string_ends_with(const char * str, const char * suffix) -{ - int str_len = strlen(str); - int suffix_len = strlen(suffix); - - return (str_len >= suffix_len) && (0 == strcmp(str + (str_len-suffix_len), suffix)); -} - void HAssDiscovery(void) { // Configure Tasmota for default Home Assistant parameters to keep discovery message as short as possible @@ -485,7 +477,7 @@ void HAssDiscovery(void) Settings.flag.decimal_text = 1; // Respond with decimal color values Settings.flag3.hass_tele_on_power = 1; // send tele/STATE message as stat/RESULT // Settings.light_scheme = 0; // To just control color it needs to be Scheme 0 - if (!string_ends_with(Settings.mqtt_fulltopic, "%prefix%/")) { + if (strcmp_P(Settings.mqtt_fulltopic, PSTR("%topic%/%prefix%/"))) { strncpy_P(Settings.mqtt_fulltopic, PSTR("%topic%/%prefix%/"), sizeof(Settings.mqtt_fulltopic)); restart_flag = 2; return; // As full topic has changed do restart first before sending discovery data