homebridge-enphase-envoy 10.2.0-beta.310 → 10.2.0-beta.311

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/envoydevice.js +36 -36
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": "10.2.0-beta.310",
5
+ "version": "10.2.0-beta.311",
6
6
  "description": "Homebridge plugin for Photovoltaic Energy System manufactured by Enphase.",
7
7
  "license": "MIT",
8
8
  "author": "grzegorz914",
@@ -3835,9 +3835,9 @@ class EnvoyDevice extends EventEmitter {
3835
3835
  sourceEnergy = meterEnabled ? sourceEim : sourcePcu;
3836
3836
  powerPeakStored = powerAndEnergyData.powerPeak ?? 0;
3837
3837
  power = Number.isFinite(sourceMeter?.power) ? sourceMeter.power : powerAndEnergyData.power;
3838
- powerLevel = this.powerProductionSummary > 1 ? this.scaleValue(power, 0, this.powerProductionSummary, 0, 100) : 0;
3838
+ powerLevel = this.powerProductionSummary > 1 && Number.isFinite(sourceMeter?.power) ? this.scaleValue(sourceMeter.power, 0, this.powerProductionSummary, 0, 100) : 0;
3839
3839
  powerState = powerLevel > 0;
3840
- powerPeak = Number.isFinite(power) ? Math.max(power, powerPeakStored) : powerPeakStored;
3840
+ powerPeak = Number.isFinite(sourceMeter?.power) ? Math.max(sourceMeter.power, powerPeakStored) : powerPeakStored;
3841
3841
  energyToday = Number.isFinite(sourceEnergy?.energyToday) ? sourceEnergy.energyToday : powerAndEnergyData.energyToday;
3842
3842
  energyLastSevenDays = Number.isFinite(sourceEnergy?.energyLastSevenDays) ? sourceEnergy.energyLastSevenDays : powerAndEnergyData.energyLastSevenDays;
3843
3843
  energyLifetime = Number.isFinite(sourceMeter?.energyLifetime) ? sourceMeter.energyLifetime : powerAndEnergyData.energyLifetime;
@@ -3850,7 +3850,7 @@ class EnvoyDevice extends EventEmitter {
3850
3850
  sourceEnergy = this.pv.powerAndEnergy[key];
3851
3851
  powerPeakStored = powerAndEnergyData.powerPeak ?? 0;
3852
3852
  power = Number.isFinite(sourceMeter?.power) ? sourceMeter.power : powerAndEnergyData.power;
3853
- powerPeak = Number.isFinite(power) ? Math.max(power, powerPeakStored) : powerPeakStored;
3853
+ powerPeak = Number.isFinite(sourceMeter?.power) ? Math.max(sourceMeter.power, powerPeakStored) : powerPeakStored;
3854
3854
  energyToday = Number.isFinite(sourceEnergy?.energyToday) ? sourceEnergy.energyToday : powerAndEnergyData.energyToday;
3855
3855
  energyLastSevenDays = Number.isFinite(sourceEnergy?.energyLastSevenDays) ? sourceEnergy.energyLastSevenDays : powerAndEnergyData.energyLastSevenDays;
3856
3856
  energyLifetime = Number.isFinite(sourceMeter?.energyLifetime) ? sourceMeter.energyLifetime : powerAndEnergyData.energyLifetime;
@@ -3863,7 +3863,7 @@ class EnvoyDevice extends EventEmitter {
3863
3863
  sourceEnergy = this.pv.powerAndEnergy[key];
3864
3864
  powerPeakStored = powerAndEnergyData.powerPeak ?? 0;
3865
3865
  power = Number.isFinite(sourceMeter?.power) ? sourceMeter.power : powerAndEnergyData.power;
3866
- powerPeak = Number.isFinite(power) ? Math.max(power, powerPeakStored) : powerPeakStored;
3866
+ powerPeak = Number.isFinite(sourceMeter?.power) ? Math.max(sourceMeter.power, powerPeakStored) : powerPeakStored;
3867
3867
  energyToday = Number.isFinite(sourceEnergy?.energyToday) ? sourceEnergy.energyToday : powerAndEnergyData.energyToday;
3868
3868
  energyLastSevenDays = Number.isFinite(sourceEnergy?.energyLastSevenDays) ? sourceEnergy.energyLastSevenDays : powerAndEnergyData.energyLastSevenDays;
3869
3869
  energyLifetime = Number.isFinite(sourceMeter?.energyLifetime) ? sourceMeter.energyLifetime : powerAndEnergyData.energyLifetime;
@@ -5143,16 +5143,17 @@ class EnvoyDevice extends EventEmitter {
5143
5143
 
5144
5144
  // Update characteristics
5145
5145
  if (deviceData.power !== 'notSupported') {
5146
- const powerLevel = this.powerProductionSummary > 1 ? this.scaleValue(deviceData.power, 0, this.powerProductionSummary, 0, 100) : 0;
5146
+ const powerLevel = this.powerProductionSummary > 1 && Number.isFinite(deviceData?.power) ? this.scaleValue(deviceData.power, 0, this.powerProductionSummary, 0, 100) : 0;
5147
5147
  const powerState = powerLevel > 0;
5148
5148
 
5149
5149
  // System accessory power state and level
5150
5150
  if (key === 'production') {
5151
- this.systemAccessory.state = powerState;
5152
- this.systemAccessory.level = powerLevel;
5151
+ const systemAccessory = this.systemAccessory;
5152
+ systemAccessory.state = powerState;
5153
+ systemAccessory.level = powerLevel;
5153
5154
  this.systemService
5154
- ?.updateCharacteristic(this.systemAccessory.characteristicType, powerState)
5155
- .updateCharacteristic(this.systemAccessory.characteristicType1, powerLevel);
5155
+ ?.updateCharacteristic(systemAccessory.characteristicType, powerState)
5156
+ .updateCharacteristic(systemAccessory.characteristicType1, powerLevel);
5156
5157
  }
5157
5158
 
5158
5159
  // Power level sensors
@@ -5892,8 +5893,8 @@ class EnvoyDevice extends EventEmitter {
5892
5893
  const characteristics = [
5893
5894
  { type: Characteristic.Alerts, label: 'alerts', value: envoy.alerts },
5894
5895
  { type: Characteristic.CommInterface, label: 'comm interface', value: envoy.network.primaryInterface },
5895
- { type: Characteristic.NetworkWebComm, label: 'web communication', value: envoy.network.webComm, postfix: `${envoy.network.webComm ? 'Yes' : 'No'}` },
5896
- { type: Characteristic.EverReportedToEnlighten, label: 'report to enlighten', value: envoy.network.everReportedToEnlighten, postfix: `${envoy.network.everReportedToEnlighten ? 'Yes' : 'No'}` },
5896
+ { type: Characteristic.NetworkWebComm, label: 'web communication', value: envoy.network.webComm, postfix: envoy.network.webComm ? 'Yes' : 'No' },
5897
+ { type: Characteristic.EverReportedToEnlighten, label: 'report to enlighten', value: envoy.network.everReportedToEnlighten, postfix: envoy.network.everReportedToEnlighten ? 'Yes' : 'No' },
5897
5898
  { type: Characteristic.CommNumAndLevel, label: 'communication devices and level', value: `${envoy.comm.num} / ${envoy.comm.level}`, unit: '%' },
5898
5899
  { type: Characteristic.CommNumPcuAndLevel, label: 'communication Microinverters and level', value: `${envoy.comm.pcuNum} / ${envoy.comm.pcuLevel}`, unit: '%' },
5899
5900
  { type: Characteristic.Tariff, label: 'tariff', value: envoy.tariff },
@@ -6165,10 +6166,10 @@ class EnvoyDevice extends EventEmitter {
6165
6166
 
6166
6167
  // Base characteristics
6167
6168
  const characteristics = [
6168
- { type: Characteristic.Producing, label: 'producing', value: pcu.producing, postfix: `${pcu.producing ? 'Yes' : 'No'}` },
6169
- { type: Characteristic.Communicating, label: 'communicating', value: pcu.communicating, postfix: `${pcu.communicating ? 'Yes' : 'No'}` },
6170
- { type: Characteristic.Provisioned, label: 'provisioned', value: pcu.provisioned, postfix: `${pcu.provisioned ? 'Yes' : 'No'}` },
6171
- { type: Characteristic.Operating, label: 'operating', value: pcu.operating, postfix: `${pcu.operating ? 'Yes' : 'No'}` },
6169
+ { type: Characteristic.Producing, label: 'producing', value: pcu.producing, postfix: pcu.producing ? 'Yes' : 'No' },
6170
+ { type: Characteristic.Communicating, label: 'communicating', value: pcu.communicating, postfix: pcu.communicating ? 'Yes' : 'No' },
6171
+ { type: Characteristic.Provisioned, label: 'provisioned', value: pcu.provisioned, postfix: pcu.provisioned ? 'Yes' : 'No' },
6172
+ { type: Characteristic.Operating, label: 'operating', value: pcu.operating, postfix: pcu.operating ? 'Yes' : 'No' },
6172
6173
  { type: Characteristic.Phase, label: 'phase', value: pcu.phase },
6173
6174
  { type: Characteristic.GfiClear, label: 'gfi clear', value: pcu.deviceControl },
6174
6175
  { type: Characteristic.Status, label: 'status', value: pcu.deviceStatus },
@@ -6234,16 +6235,16 @@ class EnvoyDevice extends EventEmitter {
6234
6235
  const characteristics = [
6235
6236
  { type: Characteristic.State, label: 'state', value: nsrb.relayState, postfix: nsrb.relayState ? 'Closed' : 'Open' },
6236
6237
  { type: Characteristic.LinesCount, label: 'lines', value: nsrb.linesCount },
6237
- { type: Characteristic.Communicating, label: 'communicating', value: nsrb.communicating, postfix: `${nsrb.communicating ? 'Yes' : 'No'}` },
6238
- { type: Characteristic.Provisioned, label: 'provisioned', value: nsrb.provisioned, postfix: `${nsrb.provisioned ? 'Yes' : 'No'}` },
6239
- { type: Characteristic.Operating, label: 'operating', value: nsrb.operating, postfix: `${nsrb.operating ? 'Yes' : 'No'}` },
6238
+ { type: Characteristic.Communicating, label: 'communicating', value: nsrb.communicating, postfix: nsrb.communicating ? 'Yes' : 'No' },
6239
+ { type: Characteristic.Provisioned, label: 'provisioned', value: nsrb.provisioned, postfix: nsrb.provisioned ? 'Yes' : 'No' },
6240
+ { type: Characteristic.Operating, label: 'operating', value: nsrb.operating, postfix: nsrb.operating ? 'Yes' : 'No' },
6240
6241
  { type: Characteristic.GfiClear, label: 'gfi clear', value: nsrb.deviceControl },
6241
6242
  { type: Characteristic.Status, label: 'status', value: nsrb.deviceStatus },
6242
6243
  { type: Characteristic.Firmware, label: 'firmware', value: nsrb.firmware },
6243
6244
  { type: Characteristic.ReadingTime, label: 'reading time', value: nsrb.readingTime },
6244
- { type: Characteristic.Line1Connected, label: 'line 1', value: nsrb.line1Connected, postfix: `${nsrb.line1Connected ? 'Closed' : 'Open'}` },
6245
- { type: Characteristic.Line2Connected, label: 'line 2', value: nsrb.line2Connected, postfix: `${nsrb.line2Connected ? 'Closed' : 'Open'}` },
6246
- { type: Characteristic.Line3Connected, label: 'line 3', value: nsrb.line3Connected, postfix: `${nsrb.line3Connected ? 'Closed' : 'Open'}` },
6245
+ { type: Characteristic.Line1Connected, label: 'line 1', value: nsrb.line1Connected, postfix: nsrb.line1Connected ? 'Closed' : 'Open' },
6246
+ { type: Characteristic.Line2Connected, label: 'line 2', value: nsrb.line2Connected, postfix: nsrb.line2Connected ? 'Closed' : 'Open' },
6247
+ { type: Characteristic.Line3Connected, label: 'line 3', value: nsrb.line3Connected, postfix: nsrb.line3Connected ? 'Closed' : 'Open' },
6247
6248
  ];
6248
6249
 
6249
6250
  if (nsrbsDetailedDataSupported) {
@@ -6326,7 +6327,7 @@ class EnvoyDevice extends EventEmitter {
6326
6327
  accessoryService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
6327
6328
 
6328
6329
  const characteristics = [
6329
- { type: characteristicType, label: 'state', value: state, postfix: `${state ? 'Discharged' : 'Charged'}` },
6330
+ { type: characteristicType, label: 'state', value: state, postfix: state ? 'Discharged' : 'Charged' },
6330
6331
  { type: characteristicType1, label: 'backup level', value: backupLevel, unit: '%' },
6331
6332
  ];
6332
6333
 
@@ -6412,12 +6413,12 @@ class EnvoyDevice extends EventEmitter {
6412
6413
  const characteristics = [
6413
6414
  { type: Characteristic.ChargeState, label: 'charge state', value: storage.chargeState },
6414
6415
  { type: Characteristic.Status, label: 'status', value: storage.deviceStatus },
6415
- { type: Characteristic.Producing, label: 'producing', value: storage.producing, postfix: `${storage.producing ? 'Yes' : 'No'}` },
6416
- { type: Characteristic.Communicating, label: 'communicating', value: storage.communicating, postfix: `${storage.communicating ? 'Yes' : 'No'}` },
6417
- { type: Characteristic.Provisioned, label: 'provisioned', value: storage.provisioned, postfix: `${storage.provisioned ? 'Yes' : 'No'}` },
6418
- { type: Characteristic.Operating, label: 'operating', value: storage.operating, postfix: `${storage.operating ? 'Yes' : 'No'}` },
6416
+ { type: Characteristic.Producing, label: 'producing', value: storage.producing, postfix: storage.producing ? 'Yes' : 'No' },
6417
+ { type: Characteristic.Communicating, label: 'communicating', value: storage.communicating, postfix: storage.communicating ? 'Yes' : 'No' },
6418
+ { type: Characteristic.Provisioned, label: 'provisioned', value: storage.provisioned, postfix: storage.provisioned ? 'Yes' : 'No' },
6419
+ { type: Characteristic.Operating, label: 'operating', value: storage.operating, postfix: storage.operating ? 'Yes' : 'No' },
6419
6420
  { type: Characteristic.GfiClear, label: 'gfi clear', value: storage.deviceControl },
6420
- { type: Characteristic.SleepEnabled, label: 'sleep', value: storage.sleepEnabled, postfix: `${storage.sleepEnabled ? 'Yes' : 'No'}` },
6421
+ { type: Characteristic.SleepEnabled, label: 'sleep', value: storage.sleepEnabled, postfix: storage.sleepEnabled ? 'Yes' : 'No' },
6421
6422
  { type: Characteristic.PercentFull, label: 'percent full', value: storage.percentFull, unit: '%' },
6422
6423
  { type: Characteristic.MaxCellTemp, label: 'max cell temperature', value: storage.maxCellTemp, unit: '°C' },
6423
6424
  { type: Characteristic.SleepMinSoc, label: 'sleep min soc', value: storage.sleepMinSoc, unit: 'min' },
@@ -6733,9 +6734,9 @@ class EnvoyDevice extends EventEmitter {
6733
6734
  if (ensemblesInstalled) {
6734
6735
  characteristics.push(
6735
6736
  { type: Characteristic.Status, label: 'status', value: ensemble.deviceStatus },
6736
- { type: Characteristic.Communicating, label: 'communicating', value: ensemble.communicating, postfix: `${ensemble.communicating ? 'Yes' : 'No'}` },
6737
- { type: Characteristic.Operating, label: 'operating', value: ensemble.operating, postfix: `${ensemble.operating ? 'Yes' : 'No'}` },
6738
- { type: Characteristic.GfiClear, label: 'gfi clear', value: ensemble.deviceControl, postfix: `${ensemble.deviceControl ? 'Yes' : 'No'}` },
6737
+ { type: Characteristic.Communicating, label: 'communicating', value: ensemble.communicating, postfix: ensemble.communicating ? 'Yes' : 'No' },
6738
+ { type: Characteristic.Operating, label: 'operating', value: ensemble.operating, postfix: ensemble.operating ? 'Yes' : 'No' },
6739
+ { type: Characteristic.GfiClear, label: 'gfi clear', value: ensemble.deviceControl, postfix: ensemble.deviceControl ? 'Yes' : 'No' },
6739
6740
  { type: Characteristic.Firmware, label: 'firmware', value: ensemble.firmware },
6740
6741
  { type: Characteristic.ReadingTime, label: 'reading time', value: ensemble.readingTime }
6741
6742
  );
@@ -6770,7 +6771,6 @@ class EnvoyDevice extends EventEmitter {
6770
6771
  if (ensemblesCountersSupported || ensemblesSecCtrlSupported) {
6771
6772
  const secctrl = this.pv.inventory.esubs.secctrl;
6772
6773
  const counters = this.pv.inventory.esubs.counters;
6773
- const phaseCount = this.pv.liveData.meters.isSplitPhase === 1 ? 1 : this.pv.liveData.meters.phaseCount;
6774
6774
 
6775
6775
  if (this.enableDebugMode) this.emit('debug', `Prepare Ensemble Summary Service`);
6776
6776
 
@@ -7064,16 +7064,16 @@ class EnvoyDevice extends EventEmitter {
7064
7064
  const characteristics = [
7065
7065
  { type: Characteristic.ChargeState, label: 'charge state', value: encharge.chargeState },
7066
7066
  { type: Characteristic.AdminState, label: 'admin state', value: encharge.adminStateStr },
7067
- { type: Characteristic.Communicating, label: 'communicating', value: encharge.communicating, postfix: `${encharge.communicating ? 'Yes' : 'No'}` },
7067
+ { type: Characteristic.Communicating, label: 'communicating', value: encharge.communicating, postfix: encharge.communicating ? 'Yes' : 'No' },
7068
7068
  { type: Characteristic.CommLevelSubGhz, label: 'sub GHz level', value: encharge.commLevelSubGhz, unit: '%' },
7069
7069
  { type: Characteristic.CommLevel24Ghz, label: '2.4GHz level', value: encharge.commLevel24Ghz, unit: '%' },
7070
- { type: Characteristic.SleepEnabled, label: 'sleep', value: encharge.sleepEnabled, postfix: `${encharge.sleepEnabled ? 'Yes' : 'No'}` },
7070
+ { type: Characteristic.SleepEnabled, label: 'sleep', value: encharge.sleepEnabled, postfix: encharge.sleepEnabled ? 'Yes' : 'No' },
7071
7071
  { type: Characteristic.PercentFull, label: 'percent full', value: encharge.percentFull, unit: '%' },
7072
7072
  { type: Characteristic.Temperature, label: 'temperature', value: encharge.temperature, unit: '°C' },
7073
7073
  { type: Characteristic.MaxCellTemp, label: 'max cell temperature', value: encharge.maxCellTemp, unit: '°C' },
7074
7074
  { type: Characteristic.LedStatus, label: 'LED status', value: encharge.ledStatus },
7075
7075
  { type: Characteristic.Capacity, label: 'capacity', value: encharge.capacity, unit: 'kWh' },
7076
- { type: Characteristic.DcSwitchOff, label: 'dc switch', value: encharge.dcSwitchOff, postfix: `${encharge.dcSwitchOff ? 'Off' : 'On'}` },
7076
+ { type: Characteristic.DcSwitchOff, label: 'dc switch', value: encharge.dcSwitchOff, postfix: encharge.dcSwitchOff ? 'Off' : 'On' },
7077
7077
  { type: Characteristic.Revision, label: 'revision', value: encharge.rev },
7078
7078
  { type: Characteristic.ReadingTime, label: 'reading time', value: encharge.readingTime },
7079
7079
  ];
@@ -7246,7 +7246,7 @@ class EnvoyDevice extends EventEmitter {
7246
7246
 
7247
7247
  const characteristics = [
7248
7248
  { type: Characteristic.AdminState, label: 'admin state', value: enpower.adminStateStr },
7249
- { type: Characteristic.Communicating, label: 'communicating', value: enpower.communicating, postfix: `${enpower.communicating ? 'Yes' : 'No'}` },
7249
+ { type: Characteristic.Communicating, label: 'communicating', value: enpower.communicating, postfix: enpower.communicating ? 'Yes' : 'No' },
7250
7250
  { type: Characteristic.CommLevelSubGhz, label: 'sub GHz level', value: enpower.commLevelSubGhz, unit: '%' },
7251
7251
  { type: Characteristic.CommLevel24Ghz, label: '2.4GHz level', value: enpower.commLevel24Ghz, unit: '%' },
7252
7252
  { type: Characteristic.Temperature, label: 'temperature', value: enpower.temperature, unit: '°C' },
@@ -7755,7 +7755,7 @@ class EnvoyDevice extends EventEmitter {
7755
7755
  if (getHome) this.timers.push({ name: 'updateHome', sampling: 120000 });
7756
7756
  if (getPowerAndEnergyData) this.timers.push({ name: 'updatePowerandEnergy', sampling: this.productionDataRefreshTime });
7757
7757
  if (getEnsemble) this.timers.push({ name: 'updateEnsemble', sampling: this.ensembleDataRefreshTime });
7758
- if (getLiveData) this.timers.push({ name: 'updateLiveData', sampling: this.liveDataRefreshTime });
7758
+ if (getLiveData) this.timers.push({ name: 'updateLiveData', sampling: 3000 });
7759
7759
  if (getGridProfile || getPlcLevel || getProductionState) this.timers.push({ name: 'updateGridPlcAndProductionState', sampling: 60000 });
7760
7760
 
7761
7761
  return true;