Update xdrv_27_shutter.ino

This commit is contained in:
stefanbode 2021-11-16 21:21:04 +01:00 committed by GitHub
parent d20ac1138a
commit 8679cf52f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -368,6 +368,7 @@ void ShutterReportPosition(bool always, uint32_t index)
Response_P(PSTR("{")); Response_P(PSTR("{"));
uint32_t i = 0; uint32_t i = 0;
uint32_t n = TasmotaGlobal.shutters_present; uint32_t n = TasmotaGlobal.shutters_present;
uint8_t shutter_running = 0;
if( index != MAX_SHUTTERS) { if( index != MAX_SHUTTERS) {
i = index; i = index;
n = index+1; n = index+1;
@ -377,13 +378,14 @@ void ShutterReportPosition(bool always, uint32_t index)
uint32_t position = ShutterRealToPercentPosition(Shutter[i].real_position, i); uint32_t position = ShutterRealToPercentPosition(Shutter[i].real_position, i);
if (Shutter[i].direction != 0) { if (Shutter[i].direction != 0) {
ShutterLogPos(i); ShutterLogPos(i);
shutter_running++;
} }
if (i && index == MAX_SHUTTERS) { ResponseAppend_P(PSTR(",")); } if (i && index == MAX_SHUTTERS) { ResponseAppend_P(PSTR(",")); }
uint32_t target = ShutterRealToPercentPosition(Shutter[i].target_position, i); uint32_t target = ShutterRealToPercentPosition(Shutter[i].target_position, i);
ResponseAppend_P(JSON_SHUTTER_POS, i+1, (Settings->shutter_options[i] & 1) ? 100-position : position, Shutter[i].direction,(Settings->shutter_options[i] & 1) ? 100-target : target, Shutter[i].tilt_real_pos ); ResponseAppend_P(JSON_SHUTTER_POS, i+1, (Settings->shutter_options[i] & 1) ? 100-position : position, Shutter[i].direction,(Settings->shutter_options[i] & 1) ? 100-target : target, Shutter[i].tilt_real_pos );
} }
ResponseJsonEnd(); ResponseJsonEnd();
if (always || Shutter[i].direction != 0) { if (always || shutter_running) {
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, PSTR(D_PRFX_SHUTTER)); // RulesProcess() now re-entry protected MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, PSTR(D_PRFX_SHUTTER)); // RulesProcess() now re-entry protected
} }
//AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: rules_flag.shutter_moving: %d, moved %d"), TasmotaGlobal.rules_flag.shutter_moving, TasmotaGlobal.rules_flag.shutter_moved); //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: rules_flag.shutter_moving: %d, moved %d"), TasmotaGlobal.rules_flag.shutter_moving, TasmotaGlobal.rules_flag.shutter_moved);