homebridge-enphase-envoy 9.6.8 → 9.6.9

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/CHANGELOG.md CHANGED
@@ -5,7 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [9.6.8] - (06.12.2024)
8
+ ## [9.6.9] - (17.12.2024)
9
+
10
+ ## Changes
11
+
12
+ - fix livedData characteristics warning [#173](https://github.com/grzegorz914/homebridge-enphase-envoy/issues/173)
13
+ - cleanup
14
+
15
+ ## [9.6.8] - (16.12.2024)
9
16
 
10
17
  ## Changes
11
18
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "private": false,
3
3
  "displayName": "Enphase Envoy",
4
4
  "name": "homebridge-enphase-envoy",
5
- "version": "9.6.8",
5
+ "version": "9.6.9",
6
6
  "description": "Homebridge plugin for Photovoltaic Energy System manufactured by Enphase.",
7
7
  "license": "MIT",
8
8
  "author": "grzegorz914",
@@ -2145,7 +2145,7 @@ class EnvoyDevice extends EventEmitter {
2145
2145
  activeCount: productionCtInverters.activeCount,
2146
2146
  readingTime: new Date(productionCtInverters.readingTime * 1000).toLocaleString(),
2147
2147
  power: productionCtInverters.wNow ?? 0, //watts
2148
- powerKw: productionCtInverters.wNow / 1000 ?? 0, //kW
2148
+ powerKw: (productionCtInverters.wNow ?? 0) / 1000, //kW
2149
2149
  energyLifeTime: (productionCtInverters.whLifetime + this.energyProductionLifetimeOffset),
2150
2150
  energyLifeTimeKw: (productionCtInverters.whLifetime + this.energyProductionLifetimeOffset) / 1000,
2151
2151
  }
@@ -2600,9 +2600,9 @@ class EnvoyDevice extends EventEmitter {
2600
2600
  activeCount: acBatteries.activeCount ?? 0,
2601
2601
  readingTime: new Date(acBatteries.readingTime * 1000).toLocaleString() ?? '',
2602
2602
  power: acBatteries.wNow ?? 0,
2603
- powerKw: acBatteries.wNow / 1000 ?? 0,
2603
+ powerKw: (acBatteries.wNow ?? 0) / 1000,
2604
2604
  energy: (acBatteries.whNow + this.acBatterieStorageOffset) ?? 0,
2605
- energyKw: (acBatteries.whNow + this.acBatterieStorageOffset) / 1000 ?? 0,
2605
+ energyKw: ((acBatteries.whNow + this.acBatterieStorageOffset) ?? 0) / 1000,
2606
2606
  chargeStatus: ApiCodes[acBatteries.state] ?? 'Unknown',
2607
2607
  energyStateSum: acBatteries.whNow > 0 ?? false,
2608
2608
  percentFullSum: 0
@@ -3959,7 +3959,7 @@ class EnvoyDevice extends EventEmitter {
3959
3959
  mainRelayState: liveDataMeters.main_relay_state,
3960
3960
  genRelayState: liveDataMeters.gen_relay_state,
3961
3961
  backupBatMode: liveDataMeters.backup_bat_mode,
3962
- backupSoc: liveDataMeters.backup_soc,
3962
+ backupSoc: liveDataMeters.backup_soc ?? 0,
3963
3963
  isSplitPhase: liveDataMeters.is_split_phase,
3964
3964
  phaseCount: liveDataMeters.phase_count,
3965
3965
  encAggSoc: liveDataMeters.enc_agg_soc,
@@ -4031,36 +4031,52 @@ class EnvoyDevice extends EventEmitter {
4031
4031
  return false;
4032
4032
  }
4033
4033
 
4034
- //iterate over active meters
4034
+ // Iterate over active meters
4035
4035
  activeDeviceTypes.forEach((type, index) => {
4036
+ if (!type.meter) return;
4037
+
4038
+ const {
4039
+ agg_p_mw, agg_s_mva, agg_p_ph_a_mw, agg_p_ph_b_mw, agg_p_ph_c_mw,
4040
+ agg_s_ph_a_mva, agg_s_ph_b_mva, agg_s_ph_c_mva
4041
+ } = type.meter;
4042
+
4036
4043
  const obj = {
4037
4044
  type: type.type,
4038
- activePower: type.meter.agg_p_mw / 1000000 ?? 0,
4039
- apparentPower: type.meter.agg_s_mva / 1000000 ?? 0,
4040
- activePowerL1: type.meter.agg_p_ph_a_mw / 1000000 ?? 0,
4041
- activePowerL2: type.meter.agg_p_ph_b_mw / 1000000 ?? 0,
4042
- activePowerL3: type.meter.agg_p_ph_c_mw / 1000000 ?? 0,
4043
- apparentPowerL1: type.meter.agg_s_ph_a_mva / 1000000 ?? 0,
4044
- apparentPowerL2: type.meter.agg_s_ph_b_mva / 1000000 ?? 0,
4045
- apparentPowerL3: type.meter.agg_s_ph_c_mva / 1000000 ?? 0
4046
- }
4047
- //add device to pv object devices
4045
+ activePower: agg_p_mw === null ? 'notSupported' : agg_p_mw / 1000000,
4046
+ apparentPower: agg_s_mva === null ? 'notSupported' : agg_s_mva / 1000000,
4047
+ activePowerL1: agg_p_ph_a_mw === null ? 'notSupported' : agg_p_ph_a_mw / 1000000,
4048
+ activePowerL2: agg_p_ph_b_mw === null ? 'notSupported' : agg_p_ph_b_mw / 1000000,
4049
+ activePowerL3: agg_p_ph_c_mw === null ? 'notSupported' : agg_p_ph_c_mw / 1000000,
4050
+ apparentPowerL1: agg_s_ph_a_mva === null ? 'notSupported' : agg_s_ph_a_mva / 1000000,
4051
+ apparentPowerL2: agg_s_ph_b_mva === null ? 'notSupported' : agg_s_ph_b_mva / 1000000,
4052
+ apparentPowerL3: agg_s_ph_c_mva === null ? 'notSupported' : agg_s_ph_c_mva / 1000000
4053
+ };
4054
+
4055
+ // Add device to pv object devices
4048
4056
  this.pv.liveData.devices.push(obj);
4049
4057
 
4050
- //update characteristics
4058
+ // Update characteristics
4051
4059
  if (this.liveDataServices) {
4052
- this.liveDataServices[index]
4053
- .updateCharacteristic(Characteristic.enphaseLiveDataActivePower, obj.activePower)
4054
- .updateCharacteristic(Characteristic.enphaseLiveDataActivePowerL1, obj.activePowerL1)
4055
- .updateCharacteristic(Characteristic.enphaseLiveDataActivePowerL2, obj.activePowerL2)
4056
- .updateCharacteristic(Characteristic.enphaseLiveDataActivePowerL3, obj.activePowerL3)
4057
- .updateCharacteristic(Characteristic.enphaseLiveDataApparentPower, obj.apparentPower)
4058
- .updateCharacteristic(Characteristic.enphaseLiveDataApparentPowerL1, obj.apparentPowerL1)
4059
- .updateCharacteristic(Characteristic.enphaseLiveDataApparentPowerL2, obj.apparentPowerL2)
4060
- .updateCharacteristic(Characteristic.enphaseLiveDataApparentPowerL3, obj.apparentPowerL3)
4060
+ const characteristics = [
4061
+ { key: 'activePower', characteristic: Characteristic.enphaseLiveDataActivePower },
4062
+ { key: 'activePowerL1', characteristic: Characteristic.enphaseLiveDataActivePowerL1 },
4063
+ { key: 'activePowerL2', characteristic: Characteristic.enphaseLiveDataActivePowerL2 },
4064
+ { key: 'activePowerL3', characteristic: Characteristic.enphaseLiveDataActivePowerL3 },
4065
+ { key: 'apparentPower', characteristic: Characteristic.enphaseLiveDataApparentPower },
4066
+ { key: 'apparentPowerL1', characteristic: Characteristic.enphaseLiveDataApparentPowerL1 },
4067
+ { key: 'apparentPowerL2', characteristic: Characteristic.enphaseLiveDataApparentPowerL2 },
4068
+ { key: 'apparentPowerL3', characteristic: Characteristic.enphaseLiveDataApparentPowerL3 }
4069
+ ];
4070
+
4071
+ characteristics.forEach(({ key, characteristic }) => {
4072
+ if (obj[key] !== 'notSupported') {
4073
+ this.liveDataServices[index].updateCharacteristic(characteristic, obj[key]);
4074
+ }
4075
+ });
4061
4076
  }
4062
4077
  });
4063
4078
 
4079
+
4064
4080
  //encharge backup level sensors
4065
4081
  if (this.enchargeBackupLevelActiveSensorsCount > 0) {
4066
4082
  for (let i = 0; i < this.enchargeBackupLevelActiveSensorsCount; i++) {
@@ -6621,54 +6637,70 @@ class EnvoyDevice extends EventEmitter {
6621
6637
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare Live Data ${liveDataType} Service`) : false;
6622
6638
  const liveDataService = accessory.addService(Service.enphaseLiveDataService, `Live Data ${liveDataType}`, liveDataType);
6623
6639
  liveDataService.setCharacteristic(Characteristic.ConfiguredName, `Live Data ${liveDataType}`);
6624
- liveDataService.getCharacteristic(Characteristic.enphaseLiveDataActivePower)
6625
- .onGet(async () => {
6626
- const value = liveData.activePower;
6627
- const info = this.disableLogInfo ? false : this.emit('message', `Live Data ${liveDataType}, active power: ${value} kW`);
6628
- return value;
6629
- });
6630
- liveDataService.getCharacteristic(Characteristic.enphaseLiveDataActivePowerL1)
6631
- .onGet(async () => {
6632
- const value = liveData.activePowerL1;
6633
- const info = this.disableLogInfo ? false : this.emit('message', `Live Data ${liveDataType} L1, active power: ${value} kW`);
6634
- return value;
6635
- });
6636
- liveDataService.getCharacteristic(Characteristic.enphaseLiveDataActivePowerL2)
6637
- .onGet(async () => {
6638
- const value = liveData.activePowerL2;
6639
- const info = this.disableLogInfo ? false : this.emit('message', `Live Data ${liveDataType} L2, active power: ${value} kW`);
6640
- return value;
6641
- });
6642
- liveDataService.getCharacteristic(Characteristic.enphaseLiveDataActivePowerL3)
6643
- .onGet(async () => {
6644
- const value = liveData.activePowerL3;
6645
- const info = this.disableLogInfo ? false : this.emit('message', `Live Data ${liveDataType} L3, active power: ${value} kW`);
6646
- return value;
6647
- });
6648
- liveDataService.getCharacteristic(Characteristic.enphaseLiveDataApparentPower)
6649
- .onGet(async () => {
6650
- const value = liveData.apparentPower;
6651
- const info = this.disableLogInfo ? false : this.emit('message', `Live Data ${liveDataType}, apparent power: ${value} kVA`);
6652
- return value;
6653
- });
6654
- liveDataService.getCharacteristic(Characteristic.enphaseLiveDataApparentPowerL1)
6655
- .onGet(async () => {
6656
- const value = liveData.apparentPowerL1;
6657
- const info = this.disableLogInfo ? false : this.emit('message', `Live Data ${liveDataType} L1, apparent power: ${value} kVA`);
6658
- return value;
6659
- });
6660
- liveDataService.getCharacteristic(Characteristic.enphaseLiveDataApparentPowerL2)
6661
- .onGet(async () => {
6662
- const value = liveData.apparentPowerL2;
6663
- const info = this.disableLogInfo ? false : this.emit('message', `Live Data ${liveDataType} L2, apparent power: ${value} kVA`);
6664
- return value;
6665
- });
6666
- liveDataService.getCharacteristic(Characteristic.enphaseLiveDataApparentPowerL3)
6667
- .onGet(async () => {
6668
- const value = liveData.apparentPowerL3;
6669
- const info = this.disableLogInfo ? false : this.emit('message', `Live Data ${liveDataType} L3, apparent power: ${value} kVA`);
6670
- return value;
6671
- });
6640
+ if (liveData.activePower !== 'notSupported') {
6641
+ liveDataService.getCharacteristic(Characteristic.enphaseLiveDataActivePower)
6642
+ .onGet(async () => {
6643
+ const value = liveData.activePower;
6644
+ const info = this.disableLogInfo ? false : this.emit('message', `Live Data ${liveDataType}, active power: ${value} kW`);
6645
+ return value;
6646
+ });
6647
+ };
6648
+ if (liveData.activePowerL1 !== 'notSupported') {
6649
+ liveDataService.getCharacteristic(Characteristic.enphaseLiveDataActivePowerL1)
6650
+ .onGet(async () => {
6651
+ const value = liveData.activePowerL1;
6652
+ const info = this.disableLogInfo ? false : this.emit('message', `Live Data ${liveDataType} L1, active power: ${value} kW`);
6653
+ return value;
6654
+ });
6655
+ }
6656
+ if (liveData.activePowerL2 !== 'notSupported') {
6657
+ liveDataService.getCharacteristic(Characteristic.enphaseLiveDataActivePowerL2)
6658
+ .onGet(async () => {
6659
+ const value = liveData.activePowerL2;
6660
+ const info = this.disableLogInfo ? false : this.emit('message', `Live Data ${liveDataType} L2, active power: ${value} kW`);
6661
+ return value;
6662
+ });
6663
+ }
6664
+ if (liveData.activePowerL3 !== 'notSupported') {
6665
+ liveDataService.getCharacteristic(Characteristic.enphaseLiveDataActivePowerL3)
6666
+ .onGet(async () => {
6667
+ const value = liveData.activePowerL3;
6668
+ const info = this.disableLogInfo ? false : this.emit('message', `Live Data ${liveDataType} L3, active power: ${value} kW`);
6669
+ return value;
6670
+ });
6671
+ }
6672
+ if (liveData.activePower !== 'notSupported') {
6673
+ liveDataService.getCharacteristic(Characteristic.enphaseLiveDataApparentPower)
6674
+ .onGet(async () => {
6675
+ const value = liveData.apparentPower;
6676
+ const info = this.disableLogInfo ? false : this.emit('message', `Live Data ${liveDataType}, apparent power: ${value} kVA`);
6677
+ return value;
6678
+ });
6679
+ }
6680
+ if (liveData.apparentPowerL1 !== 'notSupported') {
6681
+ liveDataService.getCharacteristic(Characteristic.enphaseLiveDataApparentPowerL1)
6682
+ .onGet(async () => {
6683
+ const value = liveData.apparentPowerL1;
6684
+ const info = this.disableLogInfo ? false : this.emit('message', `Live Data ${liveDataType} L1, apparent power: ${value} kVA`);
6685
+ return value;
6686
+ });
6687
+ }
6688
+ if (liveData.apparentPowerL2 !== 'notSupported') {
6689
+ liveDataService.getCharacteristic(Characteristic.enphaseLiveDataApparentPowerL2)
6690
+ .onGet(async () => {
6691
+ const value = liveData.apparentPowerL2;
6692
+ const info = this.disableLogInfo ? false : this.emit('message', `Live Data ${liveDataType} L2, apparent power: ${value} kVA`);
6693
+ return value;
6694
+ });
6695
+ }
6696
+ if (liveData.apparentPowerL3 !== 'notSupported') {
6697
+ liveDataService.getCharacteristic(Characteristic.enphaseLiveDataApparentPowerL3)
6698
+ .onGet(async () => {
6699
+ const value = liveData.apparentPowerL3;
6700
+ const info = this.disableLogInfo ? false : this.emit('message', `Live Data ${liveDataType} L3, apparent power: ${value} kVA`);
6701
+ return value;
6702
+ });
6703
+ }
6672
6704
  this.liveDataServices.push(liveDataService);
6673
6705
  }
6674
6706
  };