homebridge-melcloud-control 3.3.31 → 3.3.32-beta.1

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
@@ -16,6 +16,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
16
16
  - do not configure it manually, always using Config UI X
17
17
  - required Homebridge v2.0.0 and above
18
18
 
19
+ ## [3.3.31] - (29.11.2024)
20
+
21
+ ## Changes
22
+
23
+ - move from commonJS to esm module, fixing [#180](https://github.com/grzegorz914/homebridge-melcloud-control/issues/180)
24
+
19
25
  ## [3.3.20] - (25.09.2024)
20
26
 
21
27
  ## Changes
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
- const { HomebridgePluginUiServer, RequestError } = require('@homebridge/plugin-ui-utils');
4
- const MelCloud = require('../src/melcloud.js')
3
+ import { HomebridgePluginUiServer } from '@homebridge/plugin-ui-utils';
4
+ import MelCloud from '../src/melcloud.js';
5
5
 
6
6
  class PluginUiServer extends HomebridgePluginUiServer {
7
7
  constructor() {
package/index.js CHANGED
@@ -1,27 +1,28 @@
1
1
  'use strict';
2
- const path = require('path');
3
- const fs = require('fs');
4
- const MelCloud = require('./src/melcloud.js')
5
- const DeviceAta = require('./src/deviceata.js')
6
- const DeviceAtw = require('./src/deviceatw.js')
7
- const DeviceErv = require('./src/deviceerv.js')
8
- const CONSTANTS = require('./src/constants.json');
2
+ import { join } from 'path';
3
+ import { mkdirSync } from 'fs';
4
+ import MelCloud from './src/melcloud.js';
5
+ import DeviceAta from './src/deviceata.js';
6
+ import DeviceAtw from './src/deviceatw.js';
7
+ import DeviceErv from './src/deviceerv.js';
8
+ import constants from './constants.json' assert { type: 'json' };
9
+ const { PluginName, PlatformName } = constants;
9
10
 
10
11
  class MelCloudPlatform {
11
12
  constructor(log, config, api) {
12
13
  // only load if configured
13
14
  if (!config || !Array.isArray(config.accounts)) {
14
- log.warn(`No configuration found for ${CONSTANTS.PluginName}`);
15
+ log.warn(`No configuration found for ${PluginName}`);
15
16
  return;
16
17
  }
17
18
  this.accessories = [];
18
19
  const accountsName = [];
19
20
 
20
21
  //create directory if it doesn't exist
21
- const prefDir = path.join(api.user.storagePath(), 'melcloud');
22
+ const prefDir = join(api.user.storagePath(), 'melcloud');
22
23
  try {
23
24
  //create directory if it doesn't exist
24
- fs.mkdirSync(prefDir, { recursive: true });
25
+ mkdirSync(prefDir, { recursive: true });
25
26
  } catch (error) {
26
27
  log.error(`Prepare directory error: ${error}`);
27
28
  return;
@@ -121,7 +122,7 @@ class MelCloudPlatform {
121
122
  airConditioner.on('publishAccessory', (accessory) => {
122
123
 
123
124
  //publish device
124
- api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
125
+ api.publishExternalAccessories(PluginName, [accessory]);
125
126
  log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
126
127
  })
127
128
  .on('devInfo', (devInfo) => {
@@ -166,7 +167,7 @@ class MelCloudPlatform {
166
167
  heatPump.on('publishAccessory', (accessory) => {
167
168
 
168
169
  //publish device
169
- api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
170
+ api.publishExternalAccessories(PluginName, [accessory]);
170
171
  log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
171
172
  })
172
173
  .on('devInfo', (devInfo) => {
@@ -211,7 +212,7 @@ class MelCloudPlatform {
211
212
  energyRecoveryVentilation.on('publishAccessory', (accessory) => {
212
213
 
213
214
  //publish device
214
- api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
215
+ api.publishExternalAccessories(PluginName, [accessory]);
215
216
  log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
216
217
  })
217
218
  .on('devInfo', (devInfo) => {
@@ -250,6 +251,6 @@ class MelCloudPlatform {
250
251
  };
251
252
  };
252
253
 
253
- module.exports = (api) => {
254
- api.registerPlatform(CONSTANTS.PluginName, CONSTANTS.PlatformName, MelCloudPlatform, true);
254
+ export default (api) => {
255
+ api.registerPlatform(PluginName, PlatformName, MelCloudPlatform, true);
255
256
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "3.3.31",
4
+ "version": "3.3.32-beta.1",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",