From bec24baa7544fd0e02947634575a3acbabc28e7d Mon Sep 17 00:00:00 2001 From: stefanbode Date: Wed, 26 Apr 2023 08:39:49 +0200 Subject: [PATCH] Changes JSON message to actual position and not outdated (#18502) * Report actual position in JSON * Update xdrv_27_shutter.ino * Update xdrv_27_esp32_shutter.ino * copy&paste error --- .../xdrv_27_esp32_shutter.ino | 19 +++++-------------- .../tasmota_xdrv_driver/xdrv_27_shutter.ino | 7 +++++++ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino b/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino index 6b3499f4d..6f1c9b853 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino @@ -1595,11 +1595,6 @@ void CmndShutterCloseTime(void) ShutterSettings.shutter_closetime[XdrvMailbox.index -1] = (uint16_t)(10 * CharToFloat(XdrvMailbox.data)); ShutterInit(); } -/* - char time_chr[10]; - dtostrfd((float)(ShutterSettings.shutter_closetime[XdrvMailbox.index -1]) / 10, 1, time_chr); - ResponseCmndIdxChar(time_chr); -*/ ResponseCmndIdxFloat((float)(ShutterSettings.shutter_closetime[XdrvMailbox.index -1]) / 10, 1); } } @@ -1612,11 +1607,6 @@ void CmndShutterMotorDelay(void) ShutterInit(); //AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr Init1. realdelay %d"),Shutter[XdrvMailbox.index -1].motordelay); } -/* - char time_chr[10]; - dtostrfd((float)(Shutter[XdrvMailbox.index -1].motordelay) / STEPS_PER_SECOND, 2, time_chr); - ResponseCmndIdxChar(time_chr); -*/ ResponseCmndIdxFloat((float)(Shutter[XdrvMailbox.index -1].motordelay) / STEPS_PER_SECOND, 2); } } @@ -2192,11 +2182,12 @@ bool Xdrv27(uint32_t function) break; case FUNC_JSON_APPEND: for (uint8_t i = 0; i < TasmotaGlobal.shutters_present; i++) { - uint8_t position = (ShutterSettings.shutter_options[i] & 1) ? 100 - ShutterSettings.shutter_position[i] : ShutterSettings.shutter_position[i]; - uint8_t target = (ShutterSettings.shutter_options[i] & 1) ? 100 - ShutterRealToPercentPosition(Shutter[i].target_position, i) : ShutterRealToPercentPosition(Shutter[i].target_position, i); + uint8_t position = ShutterRealToPercentPosition(Shutter[i].real_position, i); + uint8_t target = ShutterRealToPercentPosition(Shutter[i].target_position, i); ResponseAppend_P(","); - ResponseAppend_P(JSON_SHUTTER_POS, i+1, position, Shutter[i].direction,target, Shutter[i].tilt_real_pos); + ResponseAppend_P(JSON_SHUTTER_POS, i+1, ((ShutterSettings.shutter_options[i] & 1) ? 100 - position : position), Shutter[i].direction, + ((ShutterSettings.shutter_options[i] & 1) ? 100 - target : target), Shutter[i].tilt_real_pos); #ifdef USE_DOMOTICZ if ((0 == TasmotaGlobal.tele_period) && (0 == i)) { DomoticzSensor(DZ_SHUTTER, position); @@ -2308,6 +2299,6 @@ void CmndShutterUnitTest(void) { } #else void CmndShutterUnitTest(void) {} -#endif +#endif // SHUTTER_UNITTEST #endif // ESP32 diff --git a/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino b/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino index 18940e681..566778289 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino @@ -1922,6 +1922,13 @@ bool Xdrv27(uint32_t function) result = DecodeCommand(kShutterCommands, ShutterCommand); } break; + for (uint8_t i = counter; i <= counterend; i++) { + XdrvMailbox.index = i; + XdrvMailbox.payload = rescue_payload; + XdrvMailbox.data_len = rescue_data_len; + result = DecodeCommand(kShutterCommands, ShutterCommand); + } + break; case FUNC_JSON_APPEND: for (uint8_t i = 0; i < TasmotaGlobal.shutters_present; i++) { uint8_t position = (Settings->shutter_options[i] & 1) ? 100 - Settings->shutter_position[i] : Settings->shutter_position[i];