@@ -18,6 +18,7 @@ const mqtt = require('mqtt');
1818let recon_timer = null ;
1919let lastQuotInterval = null ;
2020let haLoadInterval = null ;
21+ let msgCalcInterval = null ;
2122
2223const version = require ( './io-package.json' ) . common . version ;
2324
@@ -53,6 +54,8 @@ class EcoflowMqtt extends utils.Adapter {
5354 this . haDevices = null ;
5455 this . haCounter = 0 ;
5556 this . haCountMem = 0 ;
57+ this . efCounter = 0 ;
58+ this . efCountMem = 0 ;
5659 this . onlineDevices = [ ] ;
5760
5861 this . on ( 'ready' , this . onReady . bind ( this ) ) ;
@@ -669,17 +672,20 @@ class EcoflowMqtt extends utils.Adapter {
669672 this . log . debug ( 'EF no topics for subscription' ) ;
670673 }
671674 this . setState ( 'info.connection' , true , true ) ;
675+ //avg load of receiving telegrams from EF cloud
676+ msgCalcInterval = this . setInterval ( ( ) => {
677+ const msgcnt = this . efCounter - this . efCountMem ;
678+ this . efCountMem = this . efCounter ;
679+ this . setState ( 'info.efConnAvgLoad' , { val : msgcnt , ack : true } ) ;
680+ } , 10 * 1000 ) ;
672681 } ) ;
673682
674683 this . client . on ( 'message' , async ( topic , message ) => {
675- // message is Buffer
676- // this.log.debug(topic + ' got ' + message.toString());
677-
678684 const msgtop = ef . getIdFromTopic ( topic , this . mqttUserId ) ;
679685 const msgtype = msgtop . msg ;
680686 //this topic only contains the id of device
681687 topic = msgtop . topic ;
682-
688+ this . efCounter ++ ;
683689 let devtype = '' ;
684690 let logged = false ;
685691 let devicelogged = false ;
@@ -1301,11 +1307,15 @@ class EcoflowMqtt extends utils.Adapter {
13011307 }
13021308 if ( lastQuotInterval ) {
13031309 this . clearInterval ( lastQuotInterval ) ;
1304- this . log . debug ( 'lastQuotInterval interval stopped' ) ;
1310+ this . log . debug ( 'lastQuotInterval interval stopped' ) ;
13051311 }
13061312 if ( haLoadInterval ) {
13071313 clearInterval ( haLoadInterval ) ;
1308- this . log . debug ( 'haConnAvgLoad interval stopped' ) ;
1314+ this . log . debug ( 'haConnAvgLoad interval stopped' ) ;
1315+ }
1316+ if ( msgCalcInterval ) {
1317+ clearInterval ( msgCalcInterval ) ;
1318+ this . log . debug ( 'msgCalc interval stopped' ) ;
13091319 }
13101320 if ( this . haClient && this . haDevices ) {
13111321 // await ha.publishAsync(this, this.config.haTopic + '/iob/info/status', 'offline', 1);
0 commit comments