mirror of https://github.com/arendst/Tasmota.git
Added UP/DOWN/STOP command for OpenHAB
shutterposition now also accept UP/DOWN/STOP or the position in % 0 ... 100
This commit is contained in:
parent
06a9b45551
commit
9ffcc424a9
|
@ -426,6 +426,7 @@ void ShutterSetPosition(uint8_t device, uint8_t position)
|
||||||
void CmndShutterOpen(void)
|
void CmndShutterOpen(void)
|
||||||
{
|
{
|
||||||
XdrvMailbox.payload = 100;
|
XdrvMailbox.payload = 100;
|
||||||
|
XdrvMailbox.data_len = 3;
|
||||||
last_source = SRC_WEBGUI;
|
last_source = SRC_WEBGUI;
|
||||||
CmndShutterPosition();
|
CmndShutterPosition();
|
||||||
}
|
}
|
||||||
|
@ -433,6 +434,7 @@ void CmndShutterOpen(void)
|
||||||
void CmndShutterClose(void)
|
void CmndShutterClose(void)
|
||||||
{
|
{
|
||||||
XdrvMailbox.payload = 0;
|
XdrvMailbox.payload = 0;
|
||||||
|
XdrvMailbox.data_len = 1;
|
||||||
last_source = SRC_WEBGUI;
|
last_source = SRC_WEBGUI;
|
||||||
CmndShutterPosition();
|
CmndShutterPosition();
|
||||||
}
|
}
|
||||||
|
@ -461,8 +463,16 @@ void CmndShutterPosition(void)
|
||||||
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= shutters_present)) {
|
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= shutters_present)) {
|
||||||
uint32_t index = XdrvMailbox.index -1;
|
uint32_t index = XdrvMailbox.index -1;
|
||||||
//limit the payload
|
//limit the payload
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SHT: Position in: payload %d, index %d, source %d"), XdrvMailbox.payload , XdrvMailbox.index, last_source );
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SHT: Position in: payload %s (%d), payload %d, index %d, source %d"), XdrvMailbox.data , XdrvMailbox.data_len, XdrvMailbox.payload , XdrvMailbox.index, last_source );
|
||||||
|
|
||||||
|
if (XdrvMailbox.data_len > 1 && XdrvMailbox.payload <=0) {
|
||||||
|
UpperCase(XdrvMailbox.data, XdrvMailbox.data);
|
||||||
|
if (!strcmp(XdrvMailbox.data,"UP")) { CmndShutterOpen(); }
|
||||||
|
if (!strcmp(XdrvMailbox.data,"DOWN")) { CmndShutterClose(); }
|
||||||
|
if (!strcmp(XdrvMailbox.data,"STOP")) { CmndShutterStop(); }
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int8_t target_pos_percent = XdrvMailbox.payload < 0 ? 0 : (XdrvMailbox.payload > 100 ? 100 : XdrvMailbox.payload);
|
int8_t target_pos_percent = XdrvMailbox.payload < 0 ? 0 : (XdrvMailbox.payload > 100 ? 100 : XdrvMailbox.payload);
|
||||||
// webgui still send also on inverted shutter the native position.
|
// webgui still send also on inverted shutter the native position.
|
||||||
target_pos_percent = Settings.shutter_invert[index] && SRC_WEBGUI != last_source ? 100 - target_pos_percent : target_pos_percent;
|
target_pos_percent = Settings.shutter_invert[index] && SRC_WEBGUI != last_source ? 100 - target_pos_percent : target_pos_percent;
|
||||||
|
|
Loading…
Reference in New Issue