Skip to content

Commit

Permalink
bump 5.4.1
Browse files Browse the repository at this point in the history
## [5.4.1] - (22.08.2021)
## Changes
- removed *envoyDevId* property, now is detect automatically
  • Loading branch information
grzegorz914 committed Aug 22, 2021
1 parent 7fed4dd commit f07c388
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 33 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Power Production Enable/Disable v5.2.0 and above!!!
- You can set task for the Envoy to Enable/Disable power production on the microinverters.
- On a typical system during daylight hours, the Envoy will execute the task within 15 minutes.
- This action require *envoyDevId*.
- Open http://envoy.local/backbone/application.js and search for *envoyDevId*.
- More info about Power Production task here: https://support.enphase.com/s/article/How-do-I-disable-and-enable-power-production

## [5.4.1] - (22.08.2021)
## Changes
- removed *envoyDevId* property, now is detect automatically

## [5.4.0] - (21.08.2021)
## Changes
- removed urllib
Expand Down
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<a href="https://github.com/grzegorz914/homebridge-enphase-envoy"><img src="https://raw.githubusercontent.com/grzegorz914/homebridge-enphase-envoy/master/homebridge-enphase-envoy.png" height="280"></a>
<a href="https://github.com/grzegorz914/homebridge-enphase-envoy"><img src="https://raw.githubusercontent.com/grzegorz914/homebridge-enphase-envoy/master/graphics/homebridge-enphase-envoy.png" height="280"></a>
</p>

<span align="center">
Expand Down Expand Up @@ -31,7 +31,7 @@ Supported *Envoy-IQ, Envoy-S Metered/Standard* and all peripheral devices.
- Envoy firmware 7.x.x and above not supported right now due to authentication method changed by Enphase.

### Info v5.2.15 and above!
- Added system Power Production Enable/Disable (required *envoyDevId*).
- Added system Power Production Enable/Disable.
- Finally detects Ensemble, Encharges and Enpowers (required *installerPasswd*).
### Info v4.x.x and above!
- Version 4.0.0 whole new concept.
Expand All @@ -57,8 +57,6 @@ Supported *Envoy-IQ, Envoy-S Metered/Standard* and all peripheral devices.
## Power Production Control
- You can set task for the Envoy to Enable/Disable power production on the microinverters.
- On a typical system during daylight hours, the Envoy will execute the task within 15 minutes.
- This action require *envoyDevId*.
- Open http://envoy.local/backbone/application.js and search for *envoyDevId*.
- More info about Power Production task here: https://support.enphase.com/s/article/How-do-I-disable-and-enable-power-production

## Installation
Expand All @@ -79,7 +77,6 @@ Supported *Envoy-IQ, Envoy-S Metered/Standard* and all peripheral devices.
| `disableLogInfo`| If `true` then disable log info, all values and state will not be displayed in Homebridge log console |
| `envoyUser` | here set the envoy user or leave empty, standard is `envoy` (removed from 4.6.11, not nedded anymore) |
| `envoyPasswd` | here set the envoy password (only if U already changed the default password) |
| `envoyDevId` | here set the envoy device ID, open http://envoy.local/backbone/application.js and search for *envoyDevId*, this is nedded for Enable/Disable Power Production |
| `installerUser` | here set the optional installer user, standard is `installer` (removed from 4.6.11, not nedded anymore) |
| `installerPasswd` | here set the optional installer password, need to be generated, more info here: https://thecomputerperson.wordpress.com/2016/08/28/reverse-engineering-the-enphase-installer-toolkit/" |
| `enchargeStorage` | check *ON* if AC Batteries are installed. (not available from v3.5.0) |
Expand Down Expand Up @@ -111,7 +108,6 @@ Supported *Envoy-IQ, Envoy-S Metered/Standard* and all peripheral devices.
"disableLogInfo": false,
"envoyUser": "envoy", //removed from 4.6.11, not nedded anymore
"envoyPasswd": "",
"envoyDevId": "",
"installerUser": "installer", //removed from 4.6.11 not nedded anymore
"installerPasswd": "",
"acBatteriesStorageOffset": 0, //removed from 4.9.0 not nedded anymore
Expand Down
7 changes: 0 additions & 7 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@
"description": "Here set envoy password (only if U already changed default password).",
"required": false
},
"envoyDevId": {
"title": "Envoy Device Id",
"type": "string",
"description": "Here set envoy device Id, open http://envoy.local/backbone/application.js and search for *envoyDevId*",
"required": false
},
"installerPasswd": {
"title": "Installer password",
"type": "string",
Expand Down Expand Up @@ -127,7 +121,6 @@
"expandable": true,
"expanded": false,
"items": [
"devices[].envoyDevId",
"devices[].envoyPasswd",
"devices[].installerPasswd"
]
Expand Down
File renamed without changes
36 changes: 25 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const path = require('path');
const axios = require('axios').default;
const AxiosDigestAuth = require('./src/digestAuth.js');
const axiosDigestAuth = require('./src/digestAuth.js');
const fs = require('fs');
const fsPromises = require('fs').promises;
const parseStringPromise = require('xml2js').parseStringPromise;
Expand Down Expand Up @@ -2408,7 +2408,6 @@ class envoyDevice {
this.refreshInterval = config.refreshInterval || 5;
this.disableLogInfo = config.disableLogInfo || false;
this.envoyPasswd = config.envoyPasswd;
this.envoyDevId = config.envoyDevId;
this.installerPasswd = config.installerPasswd;
this.productionPowerMaxDetected = config.powerProductionMaxDetected || 0;
this.productionEnergyLifetimeOffset = config.energyProductionLifetimeOffset || 0;
Expand Down Expand Up @@ -2461,6 +2460,7 @@ class envoyDevice {
this.productionPowerMode = false;

//envoy
this.envoyDevId = '';
this.envoySerialNumber = '';
this.envoyFirmware = '';
this.envoySoftwareBuildEpoch = 0;
Expand Down Expand Up @@ -2660,6 +2660,20 @@ class envoyDevice {
const buildTimeQmt = new Date(parseInfoData.envoy_info.build_info[0].build_time_gmt[0] * 1000).toLocaleString();
const buildId = parseInfoData.envoy_info.build_info[0].build_id[0];

//get envoyDevId
try {
if (this.checkDeviceInfo) {
const envoyBackboneAppData = await axios.get(this.url + ENVOY_API_URL.BackboneApplication);
const data = envoyBackboneAppData.data;
const envoyDevId = data.substr(data.indexOf('envoyDevId:') + 11, 9);
if (envoyDevId.length == 9) {
this.envoyDevId = envoyDevId;
}
}
} catch (error) {
this.log.error('Device: %s %s, requesting envoyDevId error: %s', this.host, this.name, error);
};

//data
this.infoData = infoData;
this.parseInfoData = parseInfoData;
Expand All @@ -2673,7 +2687,7 @@ class envoyDevice {

const updateHomeData = infoData.status == 200 ? this.updateHomeData() : false;
} catch (error) {
this.log.error('Device: %s %s, requesting infoData eror, trying to reconnect, error: %s', this.host, this.name, error);
this.log.error('Device: %s %s, requesting infoData error: %s', this.host, this.name, error);
this.checkDeviceState = false;
this.checkDeviceInfo = true;
};
Expand All @@ -2700,7 +2714,7 @@ class envoyDevice {
this.enchargesInstalled = enchargesInstalled;
this.ensembleInstalled = ensembleInstalled;

const updateProductionPowerModeOrInventoryData = homeData.status == 200 ? (this.installerPasswd && this.envoyDevId) ? this.updateProductionPowerModeData() : this.updateInventoryData() : false;
const updateProductionPowerModeOrInventoryData = homeData.status == 200 ? (this.installerPasswd && this.envoyDevId.length == 9) ? this.updateProductionPowerModeData() : this.updateInventoryData() : false;
} catch (error) {
this.log.error('Device: %s %s, homeData error: %s', this.host, this.name, error);
this.checkDeviceState = false;
Expand All @@ -2711,7 +2725,7 @@ class envoyDevice {
async updateProductionPowerModeData() {
this.log.debug('Device: %s %s, requesting powerModeData.', this.host, this.name);
try {
const digestAuth = new AxiosDigestAuth({
const digestAuth = new axiosDigestAuth({
user: INSTALLER_USER,
passwd: this.installerPasswd
});
Expand Down Expand Up @@ -2809,7 +2823,7 @@ class envoyDevice {
async updateEnsembleInventoryData() {
this.log.debug('Device: %s %s, requesting ensembleInventoryData.', this.host, this.name);
try {
const digestAuth = new AxiosDigestAuth({
const digestAuth = new axiosDigestAuth({
user: INSTALLER_USER,
passwd: this.installerPasswd
});
Expand Down Expand Up @@ -2843,7 +2857,7 @@ class envoyDevice {
async updateEnsembleStatusData() {
this.log.debug('Device: %s %s, requesting ensembleStatusData.', this.host, this.name);
try {
const digestAuth = new AxiosDigestAuth({
const digestAuth = new axiosDigestAuth({
user: INSTALLER_USER,
passwd: this.installerPasswd
});
Expand Down Expand Up @@ -2908,7 +2922,7 @@ class envoyDevice {
this.log.debug('Device: %s %s, requesting microinvertersData', this.host, this.name);
try {
const passwd = this.envoyPasswd || this.envoySerialNumber.substring(6);
const digestAuth = new AxiosDigestAuth({
const digestAuth = new axiosDigestAuth({
user: ENVOY_USER,
passwd: passwd
});
Expand Down Expand Up @@ -3023,7 +3037,7 @@ class envoyDevice {
async updateCommLevelData() {
this.log.debug('Device: %s %s, requesting pcuCommLevelData.', this.host, this.name);
try {
const digestAuth = new AxiosDigestAuth({
const digestAuth = new axiosDigestAuth({
user: INSTALLER_USER,
passwd: this.installerPasswd,
});
Expand Down Expand Up @@ -4544,7 +4558,7 @@ class envoyDevice {
this.log('Device: %s %s, envoy: %s, check comm level: %s', this.host, accessoryName, this.envoySerialNumber, state ? 'Yes' : 'No');
}
});
if (this.installerPasswd) {
if (this.installerPasswd && this.envoyDevId.length == 9) {
enphaseEnvoyService.getCharacteristic(Characteristic.enphaseEnvoyProductionPowerMode)
.onGet(async () => {
const state = this.productionPowerMode;
Expand All @@ -4555,7 +4569,7 @@ class envoyDevice {
})
.onSet(async (state) => {
try {
const digestAuth = new AxiosDigestAuth({
const digestAuth = new axiosDigestAuth({
user: INSTALLER_USER,
passwd: this.installerPasswd,
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": false,
"displayName": "Enphase Envoy",
"name": "homebridge-enphase-envoy",
"version": "5.4.0",
"version": "5.4.1",
"description": "Homebridge plugin (https://github.com/homebridge/homebridge) to read data from Enphase Envoy-S.",
"license": "MIT",
"author": "grzegorz914",
Expand Down
1 change: 0 additions & 1 deletion sample-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"refreshInterval": 30,
"disableLogInfo": false,
"envoyPasswd": "",
"envoyDevId": "",
"installerPasswd": "",
"powerProductionMaxDetected": 5400,
"energyProductionLifetimeOffset": 0,
Expand Down
8 changes: 3 additions & 5 deletions src/digestAuth.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
"use strict";
const crypto = require('crypto');
const axios = require('axios');
const axios = require('axios').default;
let count = 0;

class AxiosDigestAuth {
class axiosDigestAuth {
constructor({
axios: axiosInst,
user,
passwd
}) {
this.axios = axiosInst ? axiosInst : axios.default;
this.user = user;
this.passwd = passwd;
}
Expand Down Expand Up @@ -51,4 +49,4 @@ class AxiosDigestAuth {
}
};
}
module.exports = AxiosDigestAuth;
module.exports = axiosDigestAuth;

0 comments on commit f07c388

Please sign in to comment.