homebridge-enphase-envoy 9.6.1 → 9.6.3

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,6 +5,12 @@ 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.3] - (02.12.2024)
9
+
10
+ ## Changes
11
+
12
+ - prevent crasch if production control is enabled and credentials data is not installer
13
+
8
14
  ## [9.6.0] - (30.11.2024)
9
15
 
10
16
  ## Changes
@@ -34,7 +34,7 @@
34
34
  "title": "Firmware 7.x.x",
35
35
  "type": "boolean",
36
36
  "default": false,
37
- "description": "This enable support for Envoy with firmware v7.x.x and newer.",
37
+ "description": "This enable support for Envoy with firmware v7.x.x / v8.x.x and newer.",
38
38
  "required": true
39
39
  },
40
40
  "envoyFirmware7xxTokenGenerationMode": {
package/index.js CHANGED
@@ -1,7 +1,5 @@
1
- 'use strict';
2
- import fs from 'fs';
3
1
  import { join } from 'path';
4
- import { mkdirSync } from 'fs';
2
+ import { mkdirSync, existsSync, writeFileSync } from 'fs';
5
3
  import EnvoyDevice from './src/envoydevice.js';
6
4
  import ImpulseGenerator from './src/impulsegenerator.js';
7
5
  import { PluginName, PlatformName } from './src/constants.js';
@@ -84,8 +82,8 @@ class EnvoyPlatform {
84
82
  ];
85
83
 
86
84
  files.forEach((file) => {
87
- if (!fs.existsSync(file)) {
88
- fs.writeFileSync(file, '0');
85
+ if (!existsSync(file)) {
86
+ writeFileSync(file, '0');
89
87
  }
90
88
  });
91
89
  } catch (error) {
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.1",
5
+ "version": "9.6.3",
6
6
  "description": "Homebridge plugin for Photovoltaic Energy System manufactured by Enphase.",
7
7
  "license": "MIT",
8
8
  "author": "grzegorz914",
@@ -18,7 +18,9 @@
18
18
  "url": "https://github.com/grzegorz914/homebridge-enphase-envoy/issues"
19
19
  },
20
20
  "type": "module",
21
- "main": "index.js",
21
+ "exports": {
22
+ ".": "./index.js"
23
+ },
22
24
  "files": [
23
25
  "src",
24
26
  "index.js",
package/src/digestauth.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import crypto from 'crypto';
3
2
  import axios from 'axios';
4
3
  import EventEmitter from 'events';
@@ -1,6 +1,4 @@
1
- "use strict";
2
- import { promises } from 'fs';
3
- const fsPromises = promises;
1
+ import { promises as fsPromises } from 'fs';
4
2
  import axios from 'axios';
5
3
  import { Agent } from 'https';
6
4
  import { XMLParser, XMLBuilder, XMLValidator } from 'fast-xml-parser';
@@ -2707,6 +2705,13 @@ class EnvoyDevice extends EventEmitter {
2707
2705
  const mqtt = this.mqttConnected ? this.mqtt.emit('publish', 'Power Mode', powerProductionState) : false;
2708
2706
  return true;
2709
2707
  } catch (error) {
2708
+ const errorString = error.toString();
2709
+ const tokenNotValid = errorString.includes('status code 401');
2710
+ if (tokenNotValid) {
2711
+ this.emit('warn', 'Power production control will not work, you need installer credentials data.')
2712
+ return false;
2713
+ }
2714
+
2710
2715
  throw new Error(`Update power production state error: ${error.message || error}`);
2711
2716
  };
2712
2717
  };
package/src/envoytoken.js CHANGED
@@ -1,6 +1,4 @@
1
- "use strict";
2
- import { promises } from 'fs';
3
- const fsPromises = promises;
1
+ import { promises as fsPromises } from 'fs';
4
2
  import axios from 'axios';
5
3
  import EventEmitter from 'events';
6
4
  import { EnphaseUrls } from './constants.js';
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import EventEmitter from 'events';
3
2
 
4
3
  class ImpulseGenerator extends EventEmitter {
package/src/mqtt.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import asyncMqtt from 'async-mqtt';
3
2
  const { connectAsync } = asyncMqtt;
4
3
  import EventEmitter from 'events';
package/src/passwdcalc.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import crypto from 'crypto';
3
2
  import EventEmitter from 'events';
4
3
 
package/src/restful.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  import express, { json } from 'express';
3
2
  import EventEmitter from 'events';
4
3