mirror of https://github.com/arendst/Tasmota.git
Update xdrv_12_home_assistant.ino
Fix problem on ESP32 and enhanced i2c GPIO boards with more than 8 relays and shutter defined on relay 9++
This commit is contained in:
parent
15990f2aa5
commit
540f6178da
|
@ -1,18 +1,14 @@
|
||||||
/*
|
/*
|
||||||
xdrv_12_home_assistant.ino - home assistant support for Tasmota
|
xdrv_12_home_assistant.ino - home assistant support for Tasmota
|
||||||
|
|
||||||
Copyright (C) 2021 Erik Montnemery, Federico Leoni and Theo Arends
|
Copyright (C) 2021 Erik Montnemery, Federico Leoni and Theo Arends
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
@ -259,12 +255,11 @@ void HassDiscoverMessage(void) {
|
||||||
#ifdef USE_SHUTTER
|
#ifdef USE_SHUTTER
|
||||||
if (Settings->flag3.shutter_mode) {
|
if (Settings->flag3.shutter_mode) {
|
||||||
for (uint32_t k = 0; k < MAX_SHUTTERS; k++) {
|
for (uint32_t k = 0; k < MAX_SHUTTERS; k++) {
|
||||||
if (0 == Settings->shutter_startrelay[k]) {
|
if (Settings->shutter_startrelay[k] > 0) {
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
if (Settings->shutter_startrelay[k] > 0 && Settings->shutter_startrelay[k] <= MAX_SHUTTER_RELAYS) {
|
|
||||||
Shutter[Settings->shutter_startrelay[k]-1] = Shutter[Settings->shutter_startrelay[k]] = 1;
|
Shutter[Settings->shutter_startrelay[k]-1] = Shutter[Settings->shutter_startrelay[k]] = 1;
|
||||||
}
|
} else {
|
||||||
|
// terminate loop at first INVALID Settings->shutter_startrelay[i].
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -441,7 +436,7 @@ void HAssAnnounceRelayLight(void)
|
||||||
uint8_t TuyaRel = 0;
|
uint8_t TuyaRel = 0;
|
||||||
uint8_t TuyaRelInv = 0;
|
uint8_t TuyaRelInv = 0;
|
||||||
uint8_t TuyaDim = 0;
|
uint8_t TuyaDim = 0;
|
||||||
uint8_t shutter_mask = 0;
|
power_t shutter_mask = 0;
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
if (PWM_DIMMER == TasmotaGlobal.module_type ) { PwmMod = true; } //
|
if (PWM_DIMMER == TasmotaGlobal.module_type ) { PwmMod = true; } //
|
||||||
|
@ -463,9 +458,12 @@ void HAssAnnounceRelayLight(void)
|
||||||
#ifdef USE_SHUTTER
|
#ifdef USE_SHUTTER
|
||||||
if (Settings->flag3.shutter_mode) {
|
if (Settings->flag3.shutter_mode) {
|
||||||
for (uint32_t i = 0; i < MAX_SHUTTERS; i++) {
|
for (uint32_t i = 0; i < MAX_SHUTTERS; i++) {
|
||||||
if (Settings->shutter_startrelay[i] > 0 && Settings->shutter_startrelay[i] <= MAX_SHUTTER_RELAYS) {
|
if (Settings->shutter_startrelay[i] > 0 ) {
|
||||||
bitSet(shutter_mask, Settings->shutter_startrelay[i] -1);
|
bitSet(shutter_mask, Settings->shutter_startrelay[i] -1);
|
||||||
bitSet(shutter_mask, Settings->shutter_startrelay[i]);
|
bitSet(shutter_mask, Settings->shutter_startrelay[i]);
|
||||||
|
} else {
|
||||||
|
// terminate loop at first INVALID Settings->shutter_startrelay[i].
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1003,7 +1001,7 @@ void HAssAnnounceShutters(void)
|
||||||
snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_SHT_%d"), ESP_getChipId(), i + 1);
|
snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_SHT_%d"), ESP_getChipId(), i + 1);
|
||||||
snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/cover/%s/config"), unique_id);
|
snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/cover/%s/config"), unique_id);
|
||||||
|
|
||||||
if (Settings->flag.hass_discovery && Settings->flag3.shutter_mode && Settings->shutter_startrelay[i] > 0 && Settings->shutter_startrelay[i] <= MAX_SHUTTER_RELAYS) {
|
if (Settings->flag.hass_discovery && Settings->flag3.shutter_mode && Settings->shutter_startrelay[i] > 0) {
|
||||||
ShowTopic = 0; // Show the new generated topic
|
ShowTopic = 0; // Show the new generated topic
|
||||||
if (i > MAX_FRIENDLYNAMES) {
|
if (i > MAX_FRIENDLYNAMES) {
|
||||||
snprintf_P(stemp1, sizeof(stemp1), PSTR("%s Shutter %d"), SettingsText(SET_DEVICENAME), i + 1);
|
snprintf_P(stemp1, sizeof(stemp1), PSTR("%s Shutter %d"), SettingsText(SET_DEVICENAME), i + 1);
|
||||||
|
@ -1025,6 +1023,9 @@ void HAssAnnounceShutters(void)
|
||||||
|
|
||||||
TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP_getChipId());
|
TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP_getChipId());
|
||||||
TryResponseAppend_P(PSTR("}"));
|
TryResponseAppend_P(PSTR("}"));
|
||||||
|
} else {
|
||||||
|
// terminate loop at first INVALID Settings->shutter_startrelay[i].
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
TasmotaGlobal.masterlog_level = ShowTopic;
|
TasmotaGlobal.masterlog_level = ShowTopic;
|
||||||
|
|
Loading…
Reference in New Issue