fix #18331 (Wrong discovery on ESP32_shutter (#18334)

* fix ESP32_shutter wrong discovery

* fix wrong discovers on ESP32 shutter

* fix wrong discovers on ESP32_shutter

* Update xdrv_12_discovery.ino
This commit is contained in:
stefanbode 2023-04-05 13:47:12 +02:00 committed by GitHub
parent b287d05098
commit afd22b5b42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 9 deletions

View File

@ -114,11 +114,11 @@ void TasDiscoverMessage(void) {
#ifdef USE_SHUTTER
if (Settings->flag3.shutter_mode) {
for (uint32_t k = 0; k < MAX_SHUTTERS; k++) {
if (Settings->shutter_startrelay[k] > 0) {
Shutter[Settings->shutter_startrelay[k]-1] = Shutter[Settings->shutter_startrelay[k]] = 1;
for (uint32_t k = 0; k < TasmotaGlobal.shutters_present; k++) {
if (ShutterGetStartRelay(k) > 0) {
Shutter[ShutterGetStartRelay(k)-1] = Shutter[ShutterGetStartRelay(k)] = 1;
} else {
// terminate loop at first INVALID Settings->shutter_startrelay[i].
// terminate loop at first INVALID ShutterGetStartRelay(k).
break;
}
}
@ -199,7 +199,7 @@ void TasDiscoverMessage(void) {
light_controller_isCTRGBLinked,
light_subtype);
for (uint32_t i = 0; i < MAX_SHUTTERS; i++) {
for (uint32_t i = 0; i < tmax(TasmotaGlobal.shutters_present,MAX_SHUTTERS); i++) {
#ifdef USE_SHUTTER
ResponseAppend_P(PSTR("%s%d"), (i > 0 ? "," : ""), Settings->shutter_options[i]);
#else
@ -209,12 +209,12 @@ void TasDiscoverMessage(void) {
ResponseAppend_P(PSTR("]," // Shutter Options (end)
"\"sht\":[")); // Shutter Tilt (start)
for (uint32_t i = 0; i < MAX_SHUTTERS; i++) {
for (uint32_t i = 0; i < tmax(TasmotaGlobal.shutters_present,MAX_SHUTTERS); i++) {
#ifdef USE_SHUTTER
ResponseAppend_P(PSTR("%s[%d,%d,%d]"), (i > 0 ? "," : ""),
Settings->shutter_tilt_config[0][i],
Settings->shutter_tilt_config[1][i],
Settings->shutter_tilt_config[2][i]);
ShutterGetTiltConfig(0,i),
ShutterGetTiltConfig(1,i),
ShutterGetTiltConfig(2,i));
#else
ResponseAppend_P(PSTR("%s[0,0,0]"), (i > 0 ? "," : ""));
#endif // USE_SHUTTER

View File

@ -351,6 +351,10 @@ uint8_t ShutterGetStartRelay(uint8_t index) {
return ShutterSettings.shutter_startrelay[index];
}
int8_t ShutterGetTiltConfig(uint8_t config_idx,uint8_t index) {
return Shutter[index].tilt_config[config_idx];
}
void ExecuteCommandPowerShutter(uint32_t device, uint32_t state, uint32_t source)
{
// first implementation for virtual relays. Avoid switching relay numbers that do not exist.

View File

@ -189,6 +189,10 @@ uint8_t ShutterGetStartRelay(uint8_t index) {
return Settings->shutter_startrelay[index];
}
int8_t ShutterGetTiltConfig(uint8_t config_idx,uint8_t index) {
return Shutter[index].tilt_config[config_idx];
}
void ExecuteCommandPowerShutter(uint32_t device, uint32_t state, uint32_t source)
{
// first implementation for virtual relays. Avoid switching relay numbers that do not exist.