Skip to content

Commit 43aa9c8

Browse files
committed
Optimizations of reading pseudo-realtime power data
1 parent 3627f6f commit 43aa9c8

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ How to find SN and Check code for registration is described here: https://github
6262

6363
## Changelog
6464

65+
### **WORK IN PROGRESS**
66+
67+
- (Gaspode) Optimizations of reading pseudo-realtime power data for slow systems
68+
6569
### 3.0.0 (2024-12-21)
6670

6771
- (Gaspode) **Breaking Change:** Renamed state "Charging_period 1_end" to "Charging_period_1_end"

main.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,14 @@ class OpenAPI {
279279
type: 'string',
280280
unit: null,
281281
},
282+
{
283+
alphaAttrName: 'uploadTime',
284+
role: 'text',
285+
id: 'Upload_time',
286+
name: 'Upload time to Alpha ESS Cloud',
287+
type: 'string',
288+
unit: null,
289+
},
282290
],
283291
},
284292
{
@@ -875,8 +883,8 @@ class OpenAPI {
875883
});
876884
if (latestEntry.uploadTime != null) {
877885
const deliveredTs = new Date(latestEntry.uploadTime.replace(' ', 'T')).getTime();
878-
if (Date.now() - deliveredTs < 300000) {
879-
// ensure that the data is not older than 5 minutes
886+
if (Date.now() - deliveredTs < 600000) {
887+
// ensure that the data is not older than 10 minutes
880888
await this.adapter.createAndUpdateStates(group, latestEntry);
881889
} else {
882890
this.adapter.log.error(
@@ -1414,7 +1422,7 @@ class AlphaEss extends utils.Adapter {
14141422
const groupInfo = this.getStateInfoList()[gidx];
14151423

14161424
if (groupInfo.isSchedule) {
1417-
groupInfo.interval = 300; // 5 Minutes, used for watchdog only
1425+
groupInfo.interval = 600; // 10 Minutes, used for watchdog only
14181426
} else {
14191427
groupInfo.interval = this.config[groupInfo.intervalName] * groupInfo.intervalFactor;
14201428
this.log.debug(`${groupInfo.intervalName}: ${groupInfo.interval}`);
@@ -2058,15 +2066,15 @@ class AlphaEss extends utils.Adapter {
20582066
*/
20592067
calculateIntervalInMs(timeInS, groupInfo) {
20602068
if (groupInfo.isSchedule) {
2061-
// In this case we calculate the seconds until the next full 5 minutes plus 10 seconds
2069+
// In this case we calculate the seconds until the next full 5 minutes plus 50 seconds
20622070
const now = new Date();
20632071
const minutes = now.getMinutes();
20642072
const seconds = now.getSeconds();
20652073
const nextFullFiveMinute = Math.ceil((minutes + 1) / 5) * 5;
20662074
const remainingMinutes = nextFullFiveMinute - minutes - 1;
20672075
const remainingSeconds = 60 - seconds;
20682076

2069-
timeInS = remainingMinutes * 60 + remainingSeconds + 10;
2077+
timeInS = remainingMinutes * 60 + remainingSeconds + 50;
20702078
} else {
20712079
if (this.errorCount < 5) {
20722080
return timeInS * 1000;

0 commit comments

Comments
 (0)