homebridge-enphase-envoy 10.3.0-beta.4 → 10.3.0-beta.5

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/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.3.0-beta.4",
5
+ "version": "10.3.0-beta.5",
6
6
  "description": "Homebridge p7ugin for Photovoltaic Energy System manufactured by Enphase.",
7
7
  "license": "MIT",
8
8
  "author": "grzegorz914",
package/src/envoydata.js CHANGED
@@ -338,7 +338,6 @@ class EnvoyData extends EventEmitter {
338
338
  devices: [],
339
339
  settings: {},
340
340
  tariff: {},
341
- tariffRaw: {},
342
341
  ratedPowerSumKw: null,
343
342
  realPowerSumKw: null,
344
343
  phaseA: false,
@@ -450,7 +449,7 @@ class EnvoyData extends EventEmitter {
450
449
  const tokenNotValid = errorString.includes('status code 401');
451
450
  if (tokenNotValid) {
452
451
  if (this.checkTokenRunning) return;
453
-
452
+
454
453
  this.feature.info.jwtToken.token = '';
455
454
  this.feature.info.tokenValid = false;
456
455
  return;
@@ -1963,7 +1962,7 @@ class EnvoyData extends EventEmitter {
1963
1962
  };
1964
1963
 
1965
1964
  // Calculate encharges rated power summary in kW
1966
- this.pv.inventory.esubs.encharges.ratedPowerSumKw = enchargesRatedPowerSummary.length > 0 ? (enchargesRatedPowerSummary.reduce((total, num) => total + num, 0) / enchargesRatedPowerSummary.length) / 1000 : null;
1965
+ this.pv.inventory.esubs.encharges.ratedPowerSumKw = enchargesRatedPowerSummary.length > 0 ? enchargesRatedPowerSummary.reduce((total, num) => total + num, 0) / 1000 : null;
1967
1966
  }
1968
1967
 
1969
1968
  // Update enpowers statuses if installed
@@ -2043,7 +2042,7 @@ class EnvoyData extends EventEmitter {
2043
2042
  if (this.logDebug) this.emit('debug', `Ensemble power response:`, responseData);
2044
2043
 
2045
2044
  const devices = responseData.devices ?? [];
2046
- if (!devices.length === 0) return false;
2045
+ if (devices.length === 0) return false;
2047
2046
 
2048
2047
  // update encharges
2049
2048
  const enchargesRealPowerSummary = [];
@@ -2052,7 +2051,7 @@ class EnvoyData extends EventEmitter {
2052
2051
  const serialNumber = device.serial_num;
2053
2052
  const encharge = encharges.find(device => device.serialNumber === serialNumber);
2054
2053
  if (this.logDebug) this.emit('debug', `Ensemble device power:`, device);
2055
- if (!device) continue;
2054
+ if (!encharge) continue;
2056
2055
 
2057
2056
  encharge.power = {
2058
2057
  serialNumber: device.serial_num,
@@ -2066,7 +2065,7 @@ class EnvoyData extends EventEmitter {
2066
2065
  }
2067
2066
 
2068
2067
  // Calculate encharges real power summary in kW
2069
- this.pv.inventory.esubs.encharges.realPowerSumKw = enchargesRealPowerSummary.length > 0 ? (enchargesRealPowerSummary.reduce((total, num) => total + num, 0) / enchargesRealPowerSummary.length) / 1000 : null;
2068
+ this.pv.inventory.esubs.encharges.realPowerSumKw = enchargesRealPowerSummary.length > 0 ? enchargesRealPowerSummary.reduce((total, num) => total + num, 0) / 1000000 : null;
2070
2069
 
2071
2070
  // ensemble power supported
2072
2071
  this.feature.ensemble.power.supported = true;
@@ -2092,15 +2091,14 @@ class EnvoyData extends EventEmitter {
2092
2091
  const enchargesSettingsSupported = 'enc_settings' in enchargesSettings;
2093
2092
  if (!enchargesSettingsSupported) return false;
2094
2093
 
2095
- const settings = enchargesSettings.enc_settings;
2096
- const encharges = this.pv.inventory.esubs.encharges;
2097
- encharges.settings = {
2098
- enable: settings.enable, // boolean
2099
- country: settings.country, // string
2100
- currentLimit: settings.current_limit, // float
2101
- perPhase: settings.per_phase // boolean
2094
+ const settings = {
2095
+ enable: enchargesSettings.enc_settings.enable, // boolean
2096
+ country: enchargesSettings.enc_settings.country, // string
2097
+ currentLimit: enchargesSettings.enc_settings.current_limit, // float
2098
+ perPhase: enchargesSettings.enc_settings.per_phase // boolean
2102
2099
  };
2103
2100
 
2101
+ this.pv.inventory.esubs.encharges.settings = settings;
2104
2102
  this.feature.inventory.esubs.encharges.settings.supported = true;
2105
2103
 
2106
2104
  // RESTFul and MQTT update
@@ -2119,12 +2117,11 @@ class EnvoyData extends EventEmitter {
2119
2117
  try {
2120
2118
  const response = await this.axiosInstance.get(ApiUrls.TariffSettingsGetPut);
2121
2119
  const tariffSettings = response.data;
2122
-
2123
2120
  if (this.logDebug) this.emit('debug', 'Tariff:', tariffSettings);
2124
2121
 
2125
2122
  const enchargesTariffSupported = 'tariff' in tariffSettings;
2126
2123
  if (!enchargesTariffSupported) return false;
2127
- this.pv.inventory.esubs.encharges.tariffRaw = tariffSettings;
2124
+
2128
2125
  this.pv.inventory.esubs.encharges.tariff = tariffSettings;
2129
2126
  this.feature.inventory.esubs.encharges.tariff.supported = true;
2130
2127
 
@@ -2549,7 +2546,7 @@ class EnvoyData extends EventEmitter {
2549
2546
  if (this.logDebug) this.emit('debug', `Requesting set encharge settings`);
2550
2547
 
2551
2548
  try {
2552
- const tariff = this.pv.inventory.esubs.encharges.tariffRaw.tariff;
2549
+ const tariff = this.pv.inventory.esubs.encharges.tariff.tariff;
2553
2550
  tariff.storage_settings.mode = profile;
2554
2551
  tariff.storage_settings.reserved_soc = reservedSoc;
2555
2552
  tariff.storage_settings.charge_from_grid = chargeFromGrid;
@@ -1988,8 +1988,8 @@ class EnvoyDevice extends EventEmitter {
1988
1988
  }
1989
1989
 
1990
1990
  if (ensemblesCountersSupported) characteristics.push({ type: Characteristic.RestPower, label: 'rest power', value: counters.restPowerKw, unit: 'kW' });
1991
- if (enchargesStatusSupported) characteristics.push({ type: Characteristic.RatedPower, label: 'rated power', value: this.pv.inventoryData.esubs.ratedPowerSumKw, unit: 'kW' });
1992
- if (enchargesPowerSupported) characteristics.push({ type: Characteristic.RealPower, label: 'real power', value: this.pv.inventoryData.esubs.realPowerSumKw, unit: 'kW' });
1991
+ if (enchargesStatusSupported) characteristics.push({ type: Characteristic.RatedPower, label: 'rated power', value: this.pv.inventoryData.esubs.encharges.ratedPowerSumKw, unit: 'kW' });
1992
+ if (enchargesPowerSupported) characteristics.push({ type: Characteristic.RealPower, label: 'real power', value: this.pv.inventoryData.esubs.encharges.realPowerSumKw, unit: 'kW' });
1993
1993
 
1994
1994
  for (const { type, label, value, unit = '', postfix = '' } of characteristics) {
1995
1995
  if (!this.functions.isValidValue(value)) continue;
@@ -2399,24 +2399,23 @@ class EnvoyDevice extends EventEmitter {
2399
2399
  if (this.logDebug) this.emit('debug', `Prepare ${enchargeName} Profile Sensor Services`);
2400
2400
 
2401
2401
  this.enchargeProfileSensorsServices = [];
2402
-
2403
2402
  for (let i = 0; i < this.enchargeProfileSensors.length; i++) {
2404
2403
  const sensor = this.enchargeProfileSensors[i];
2405
2404
  const { namePrefix, name, serviceType, characteristicType } = sensor;
2406
2405
  const serviceName = namePrefix ? `${accessoryName} ${name}` : name;
2407
2406
 
2408
- const service = accessory.addService(serviceType, serviceName, `enchargeProfileSensorService${i}`);
2409
- service.addOptionalCharacteristic(Characteristic.ConfiguredName);
2410
- service.setCharacteristic(Characteristic.ConfiguredName, serviceName);
2407
+ const sensorService = accessory.addService(serviceType, serviceName, `enchargeProfileSensorService${i}`);
2408
+ sensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
2409
+ sensorService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
2411
2410
 
2412
- service.getCharacteristic(characteristicType)
2411
+ sensorService.getCharacteristic(characteristicType)
2413
2412
  .onGet(async () => {
2414
2413
  const currentState = sensor.state;
2415
2414
  if (this.logInfo) this.emit('info', `${enchargeName} profile: ${name}, state: ${currentState ? 'Active' : 'Not Active'}`);
2416
2415
  return currentState;
2417
2416
  });
2418
2417
 
2419
- this.enchargeProfileSensorsServices.push(service);
2418
+ this.enchargeProfileSensorsServices.push(sensorService);
2420
2419
  }
2421
2420
  }
2422
2421
  }