iobroker.pv-notifications 1.0.99 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -339,15 +339,14 @@ sadam6752@gmail.com
339
339
  ### **WORK IN PROGRESS**
340
340
  -->
341
341
 
342
- ### 1.0.99 (2026-03-01)
342
+ ### 1.1.0 (2026-03-01)
343
343
 
344
- * (FIX) Weekly stats auto-saved every Sunday at 23:55 (before sourceanalytix reset at 00:00)
345
- * (FIX) Monthly stats auto-saved on last day of month at 23:55 (before sourceanalytix reset at 00:00)
346
- * (ADD) User can freely configure send time for weekly/monthly stats via statsWeekDay, statsWeekTime, monthlyStatsDay, monthlyStatsTime
344
+ * (FIX) buildFullMessage() and buildEmptyMessage() now read from INTERNAL states (statistics.currentPower, etc.) instead of external config states
345
+ * (FIX) buildFullMessage() and buildEmptyMessage() converted to async functions with await
347
346
 
348
- ### 1.0.98 (2026-03-01)
347
+ ### 1.0.99 (2026-03-01)
349
348
 
350
- * (FIX) Weekly/monthly stats now read directly from external states using getForeignStateAsync (not from internal states)
349
+ * (FIX) Weekly stats auto-saved every Sunday at 23:55 (before sourceanalytix reset at 00:00)
351
350
 
352
351
  ### 1.0.93 (2026-02-27)
353
352
 
package/io-package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "pv-notifications",
4
- "version": "1.0.99",
4
+ "version": "1.1.0",
5
5
  "titleLang": {
6
6
  "en": "PV Notifications",
7
7
  "de": "PV-Benachrichtigungen",
package/main.js CHANGED
@@ -639,7 +639,7 @@ class PvNotifications extends utils.Adapter {
639
639
  const allowNotification = (!nightTime || !nightModeActive) && (!quietTime || !quietModeActive);
640
640
 
641
641
  if (allowNotification && !this.status.full && this.canNotify('full')) {
642
- const message = this.buildFullMessage(soc);
642
+ const message = await this.buildFullMessage(soc);
643
643
  this.sendTelegram(message, 'high');
644
644
  this.status.full = true;
645
645
  this.status.lastNotification.full = Date.now();
@@ -668,7 +668,7 @@ class PvNotifications extends utils.Adapter {
668
668
  const blockedByQuietTime = quietTime && quietModeActive;
669
669
 
670
670
  if (allowEmptyNotification && !blockedByQuietTime) {
671
- const message = this.buildEmptyMessage(soc);
671
+ const message = await this.buildEmptyMessage(soc);
672
672
  this.sendTelegram(message, 'high');
673
673
  this.status.empty = true;
674
674
  this.status.lastNotification.empty = Date.now();
@@ -852,11 +852,17 @@ class PvNotifications extends utils.Adapter {
852
852
  *
853
853
  * @param {number} soc - Battery state of charge in percent
854
854
  */
855
- buildFullMessage(soc) {
856
- const power = this.getStateValue(this.config.powerProduction);
857
- const totalProd = this.getStateValue(this.config.totalProduction);
858
- const feedIn = this.getStateValue(this.config.feedIn);
859
- const consumption = this.getStateValue(this.config.consumption);
855
+ async buildFullMessage(soc) {
856
+ // Werte aus INTERNEN States lesen (aktualisiert in Echtzeit durch onStateChange)
857
+ const powerState = await this.getStateAsync('statistics.currentPower');
858
+ const totalProdState = await this.getStateAsync('statistics.currentTotalProduction');
859
+ const feedInState = await this.getStateAsync('statistics.currentFeedIn');
860
+ const consumptionState = await this.getStateAsync('statistics.currentConsumption');
861
+
862
+ const power = powerState && powerState.val !== null ? powerState.val : 0;
863
+ const totalProd = totalProdState && totalProdState.val !== null ? totalProdState.val : 0;
864
+ const feedIn = feedInState && feedInState.val !== null ? feedInState.val : 0;
865
+ const consumption = consumptionState && consumptionState.val !== null ? consumptionState.val : 0;
860
866
 
861
867
  let message = `🔋 *${this.translate('Battery full')}* (${soc}%)
862
868
 
@@ -900,9 +906,13 @@ class PvNotifications extends utils.Adapter {
900
906
  *
901
907
  * @param {number} soc - Battery state of charge in percent
902
908
  */
903
- buildEmptyMessage(soc) {
904
- const gridPower = this.getStateValue(this.config.gridPower);
905
- const consumption = this.getStateValue(this.config.consumption);
909
+ async buildEmptyMessage(soc) {
910
+ // Werte aus INTERNEN States lesen (aktualisiert in Echtzeit durch onStateChange)
911
+ const gridPowerState = await this.getStateAsync('statistics.currentGridPower');
912
+ const consumptionState = await this.getStateAsync('statistics.currentConsumption');
913
+
914
+ const gridPower = gridPowerState && gridPowerState.val !== null ? gridPowerState.val : 0;
915
+ const consumption = consumptionState && consumptionState.val !== null ? consumptionState.val : 0;
906
916
 
907
917
  let message = `🔋 *${this.translate('Battery empty')}* (${soc}%)
908
918
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.pv-notifications",
3
- "version": "1.0.99",
3
+ "version": "1.1.0",
4
4
  "description": "PV-Anlage Batterie-Status Telegram Benachrichtigungen",
5
5
  "author": {
6
6
  "name": "Alex1808 via LLM: Qwen",