From cabfc4f6993399c71996403ece13ce00510a72e5 Mon Sep 17 00:00:00 2001 From: Simon Hailes Date: Fri, 19 Feb 2021 13:35:39 +0000 Subject: [PATCH 1/2] Fix HASS discovery for MI sensors - workaround is to use 'mi32option6 1' --- tasmota/xsns_62_esp32_mi_ble.ino | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tasmota/xsns_62_esp32_mi_ble.ino b/tasmota/xsns_62_esp32_mi_ble.ino index 44a475942..ad9771f76 100644 --- a/tasmota/xsns_62_esp32_mi_ble.ino +++ b/tasmota/xsns_62_esp32_mi_ble.ino @@ -1937,13 +1937,24 @@ void MI32Every50mSecond(){ void MI32EverySecond(bool restart){ +#ifdef USE_HOME_ASSISTANT + if(Settings.flag.hass_discovery){ + // fixes bug introduced - just by forcing this mode. + MI32.option.MQTTType = 1; + } +#endif + // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("M32: onesec")); MI32TimeoutSensors(); if (MI32.option.MQTTType == 0){ + // show tas style sensor MQTT MI32ShowSomeSensors(); } else { + // these two share a counter + // discovery only sent if hass_discovery MI32DiscoveryOneMISensor(); + // show independent style sensor MQTT MI32ShowOneMISensor(); } From ec25cfb08c89d7dd1d4bfdea202f636e081b97c9 Mon Sep 17 00:00:00 2001 From: Simon Hailes Date: Fri, 19 Feb 2021 13:46:35 +0000 Subject: [PATCH 2/2] better bugfix for MI32Option6 bug --- tasmota/xsns_62_esp32_mi_ble.ino | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tasmota/xsns_62_esp32_mi_ble.ino b/tasmota/xsns_62_esp32_mi_ble.ino index ad9771f76..8b7b760ba 100644 --- a/tasmota/xsns_62_esp32_mi_ble.ino +++ b/tasmota/xsns_62_esp32_mi_ble.ino @@ -1937,24 +1937,25 @@ void MI32Every50mSecond(){ void MI32EverySecond(bool restart){ -#ifdef USE_HOME_ASSISTANT - if(Settings.flag.hass_discovery){ - // fixes bug introduced - just by forcing this mode. - MI32.option.MQTTType = 1; - } -#endif - // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("M32: onesec")); MI32TimeoutSensors(); if (MI32.option.MQTTType == 0){ // show tas style sensor MQTT MI32ShowSomeSensors(); - } else { + } + + if (MI32.option.MQTTType == 1 +#ifdef USE_HOME_ASSISTANT + || + Settings.flag.hass_discovery +#endif + ) { // these two share a counter // discovery only sent if hass_discovery MI32DiscoveryOneMISensor(); // show independent style sensor MQTT + // note - if !MQTTType, then this is IN ADDITION to 'normal' MI32ShowOneMISensor(); }