@@ -195,6 +195,7 @@ struct SHUTTERGLOBAL {
195
195
bool callibration_run = false ; // if true a callibration is running and additional measures are captured
196
196
uint8_t stopp_armed = 0 ; // Count each step power usage is below limit of 1 Watt
197
197
uint16_t cycle_time = 0 ; // used for shuttersetup to get accurate timing
198
+ bool sensor_data_reported = false ; // ensure that shutter sensor data reported every sedond is only reported if shutter is moving and there is a change.
198
199
} ShutterGlobal;
199
200
200
201
#define SHT_DIV_ROUND (__A, __B ) (((__A) + (__B)/2 ) / (__B))
@@ -946,7 +947,7 @@ void ShutterRelayChanged(void)
946
947
947
948
void ShutterReportPosition (bool always, uint32_t index)
948
949
{
949
- Response_P ( PSTR ( " { " ));
950
+
950
951
uint32_t i = 0 ;
951
952
uint32_t n = TasmotaGlobal.shutters_present ;
952
953
uint8_t shutter_running = 0 ;
@@ -958,7 +959,7 @@ void ShutterReportPosition(bool always, uint32_t index)
958
959
959
960
// Allow function exit if nothing to report (99.9% use case)
960
961
if (!always && !shutter_running) return ;
961
-
962
+ Response_P ( PSTR ( " { " ));
962
963
if ( index != MAX_SHUTTERS_ESP32) {
963
964
i = index ;
964
965
n = index +1 ;
@@ -976,7 +977,7 @@ void ShutterReportPosition(bool always, uint32_t index)
976
977
uint32_t position = ShutterRealToPercentPosition (Shutter[i].real_position , i);
977
978
uint32_t target = ShutterRealToPercentPosition (Shutter[i].target_position , i);
978
979
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 );
979
- }
980
+ }
980
981
ResponseJsonEnd ();
981
982
if (always || shutter_running) {
982
983
MqttPublishPrefixTopicRulesProcess_P (RESULT_OR_STAT, PSTR (D_PRFX_SHUTTER)); // RulesProcess() now re-entry protected
@@ -1196,6 +1197,7 @@ void ShutterStartInit(uint32_t i, int32_t direction, int32_t target_pos)
1196
1197
Shutter[i].target_position = target_pos;
1197
1198
Shutter[i].start_position = Shutter[i].real_position ;
1198
1199
TasmotaGlobal.rules_flag .shutter_moving = 1 ;
1200
+ ShutterGlobal.sensor_data_reported = false ;
1199
1201
ShutterAllowPreStartProcedure (i);
1200
1202
Shutter[i].time = Shutter[i].last_reported_time = 0 ;
1201
1203
@@ -2330,18 +2332,24 @@ bool Xdrv27(uint32_t function)
2330
2332
}
2331
2333
break ;
2332
2334
case FUNC_JSON_APPEND:
2333
- for (uint8_t i = 0 ; i < TasmotaGlobal.shutters_present ; i++) {
2334
- ResponseAppend_P (" ," );
2335
- uint8_t position = ShutterRealToPercentPosition (Shutter[i].real_position , i);
2336
- position = (ShutterSettings.shutter_options [i] & 1 ) ? 100 - position : position;
2337
- uint8_t target = ShutterRealToPercentPosition (Shutter[i].target_position , i);
2338
- target = (ShutterSettings.shutter_options [i] & 1 ) ? 100 - target : target;
2339
- ResponseAppend_P (JSON_SHUTTER_POS, i + 1 , position, Shutter[i].direction , target, Shutter[i].tilt_real_pos );
2340
- #ifdef USE_DOMOTICZ
2341
- if ((0 == TasmotaGlobal.tele_period ) && (0 == i)) {
2342
- DomoticzSensor (DZ_SHUTTER, position);
2335
+ if (!ShutterGlobal.sensor_data_reported ) {
2336
+ ShutterGlobal.sensor_data_reported = true ;
2337
+ for (uint8_t i = 0 ; i < TasmotaGlobal.shutters_present ; i++) {
2338
+ ResponseAppend_P (" ," );
2339
+ uint8_t position = ShutterRealToPercentPosition (Shutter[i].real_position , i);
2340
+ position = (ShutterSettings.shutter_options [i] & 1 ) ? 100 - position : position;
2341
+ uint8_t target = ShutterRealToPercentPosition (Shutter[i].target_position , i);
2342
+ target = (ShutterSettings.shutter_options [i] & 1 ) ? 100 - target : target;
2343
+ ResponseAppend_P (JSON_SHUTTER_POS, i + 1 , position, Shutter[i].direction , target, Shutter[i].tilt_real_pos );
2344
+ if (Shutter[i].direction != 0 ) {
2345
+ ShutterGlobal.sensor_data_reported = false ;
2346
+ }
2347
+ #ifdef USE_DOMOTICZ
2348
+ if ((0 == TasmotaGlobal.tele_period ) && (0 == i)) {
2349
+ DomoticzSensor (DZ_SHUTTER, position);
2350
+ }
2351
+ #endif // USE_DOMOTICZ
2343
2352
}
2344
- #endif // USE_DOMOTICZ
2345
2353
}
2346
2354
break ;
2347
2355
case FUNC_SET_POWER:
0 commit comments