mirror of https://github.com/arendst/Tasmota.git
fix issue on inverted shutters with commands comming with shutterposition (#20752)
* fix INVERTED bug fix shutterposition xxx commands do not work on inverted shutter * fix INVERTED bug * fix INVERTED bug shutterposition UP/DOWN/... commands did not work as expected on inverted shutter
This commit is contained in:
parent
30f650ebb2
commit
c7894181b7
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
xdrv_27_esp32_shutter.ino - Shutter/Blind support for Tasmota
|
xdrv_27_esp32_shutter.ino - Shutter/Blind support for Tasmota
|
||||||
|
|
||||||
Copyright (C) 2023 Stefan Bode
|
Copyright (C) 2024 Stefan Bode
|
||||||
|
|
||||||
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
|
||||||
|
@ -1824,13 +1824,15 @@ void CmndShutterPosition(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// special handling fo UP,DOWN,TOGGLE,STOP and similar commands command
|
||||||
|
//
|
||||||
|
if ( XdrvMailbox.data_len > 0 ) {
|
||||||
|
// set len to 0 to avoid loop
|
||||||
|
uint32_t data_len_save = XdrvMailbox.data_len;
|
||||||
|
int32_t payload_save = XdrvMailbox.payload;
|
||||||
|
XdrvMailbox.data_len = 0;
|
||||||
|
XdrvMailbox.payload = -99;
|
||||||
|
|
||||||
// value 0 with data_len > 0 can mean Open
|
|
||||||
// special handling fo UP,DOWN,TOGGLE,STOP command comming with payload -99
|
|
||||||
// STOP will come with payload 0 because predefined value in TASMOTA
|
|
||||||
if ((XdrvMailbox.data_len > 3) && (XdrvMailbox.payload <= 0)) {
|
|
||||||
// set len to 0 to avoid loop on close where payload is 0
|
|
||||||
XdrvMailbox.data_len = 0;
|
|
||||||
if (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_UP) || !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_OPEN) || ((Shutter[index].direction==0) && !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_STOPOPEN))) {
|
if (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_UP) || !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_OPEN) || ((Shutter[index].direction==0) && !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_STOPOPEN))) {
|
||||||
CmndShutterOpen();
|
CmndShutterOpen();
|
||||||
return;
|
return;
|
||||||
|
@ -1848,12 +1850,12 @@ void CmndShutterPosition(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_STOP) || ((Shutter[index].direction) && (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_STOPOPEN) || !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_STOPCLOSE)))) {
|
if (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_STOP) || ((Shutter[index].direction) && (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_STOPOPEN) || !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_STOPCLOSE)))) {
|
||||||
// Back to normal: all -99 if not a clear position
|
|
||||||
XdrvMailbox.payload = -99;
|
|
||||||
CmndShutterStop();
|
CmndShutterStop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// restore values
|
||||||
|
XdrvMailbox.payload = payload_save;
|
||||||
|
XdrvMailbox.data_len = data_len_save;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t target_pos_percent = (XdrvMailbox.payload < 0) ? (XdrvMailbox.payload == -99 ? ShutterRealToPercentPosition(Shutter[index].real_position, index) : 0) : ((XdrvMailbox.payload > 100) ? 100 : XdrvMailbox.payload);
|
int8_t target_pos_percent = (XdrvMailbox.payload < 0) ? (XdrvMailbox.payload == -99 ? ShutterRealToPercentPosition(Shutter[index].real_position, index) : 0) : ((XdrvMailbox.payload > 100) ? 100 : XdrvMailbox.payload);
|
||||||
|
|
|
@ -1297,11 +1297,15 @@ void CmndShutterPosition(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// value 0 with data_len > 0 can mean Open
|
// value 0 with data_len > 0 can mean Open
|
||||||
// special handling fo UP,DOWN,TOGGLE,STOP command comming with payload -99
|
// special handling fo UP,DOWN,TOGGLE,STOP and similar commands command
|
||||||
// STOP will come with payload 0 because predefined value in TASMOTA
|
//
|
||||||
if ((XdrvMailbox.data_len > 3) && (XdrvMailbox.payload <= 0)) {
|
if ( XdrvMailbox.data_len > 0 ) {
|
||||||
// set len to 0 to avoid loop on close where payload is 0
|
// set len to 0 to avoid loop
|
||||||
XdrvMailbox.data_len = 0;
|
uint32_t data_len_save = XdrvMailbox.data_len;
|
||||||
|
int32_t payload_save = XdrvMailbox.payload;
|
||||||
|
XdrvMailbox.data_len = 0;
|
||||||
|
XdrvMailbox.payload = -99;
|
||||||
|
|
||||||
if (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_UP) || !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_OPEN) || ((Shutter[index].direction==0) && !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_STOPOPEN))) {
|
if (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_UP) || !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_OPEN) || ((Shutter[index].direction==0) && !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_STOPOPEN))) {
|
||||||
CmndShutterOpen();
|
CmndShutterOpen();
|
||||||
return;
|
return;
|
||||||
|
@ -1319,11 +1323,12 @@ void CmndShutterPosition(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_STOP) || ((Shutter[index].direction) && (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_STOPOPEN) || !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_STOPCLOSE)))) {
|
if (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_STOP) || ((Shutter[index].direction) && (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_STOPOPEN) || !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_STOPCLOSE)))) {
|
||||||
// Back to normal: all -99 if not a clear position
|
|
||||||
XdrvMailbox.payload = -99;
|
|
||||||
CmndShutterStop();
|
CmndShutterStop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// restore values
|
||||||
|
XdrvMailbox.payload = payload_save;
|
||||||
|
XdrvMailbox.data_len = data_len_save;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t target_pos_percent = (XdrvMailbox.payload < 0) ? (XdrvMailbox.payload == -99 ? ShutterRealToPercentPosition(Shutter[index].real_position, index) : 0) : ((XdrvMailbox.payload > 100) ? 100 : XdrvMailbox.payload);
|
int8_t target_pos_percent = (XdrvMailbox.payload < 0) ? (XdrvMailbox.payload == -99 ? ShutterRealToPercentPosition(Shutter[index].real_position, index) : 0) : ((XdrvMailbox.payload > 100) ? 100 : XdrvMailbox.payload);
|
||||||
|
|
Loading…
Reference in New Issue