From fe9103eb684dd28cf8c16a88a51c0dc2c8e6e599 Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 7 Dec 2018 17:19:14 +0100 Subject: [PATCH] Fix HASS discovery of switches --- sonoff/xdrv_12_home_assistant.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sonoff/xdrv_12_home_assistant.ino b/sonoff/xdrv_12_home_assistant.ino index b5d0c076c..2972d39ea 100644 --- a/sonoff/xdrv_12_home_assistant.ino +++ b/sonoff/xdrv_12_home_assistant.ino @@ -302,7 +302,8 @@ void HAssAnnounceButtonSwitch(byte device, char* topic, byte present, byte key, } else { snprintf_P(name, sizeof(name), PSTR("%s %s"), Settings.friendlyname[device], key?"BTN":"SW"); } - GetPowerDevice(value_template, device+1, sizeof(value_template), Settings.flag.device_index_enable); + GetPowerDevice(value_template, device+1, sizeof(value_template), + key + Settings.flag.device_index_enable); // Force index for Switch 1, Index on Button1 is controlled by Settings.flag.device_index_enable GetTopic_P(state_topic, CMND, topic, value_template); // State of button is sent as CMND TOGGLE, state of switch is sent as ON/OFF GetTopic_P(availability_topic, TELE, mqtt_topic, S_LWT); FindPrefix(state_topic, availability_topic, prefix);