Skip to content

Commit

Permalink
release v5.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
grzegorz914 committed Dec 1, 2024
1 parent 0b50506 commit 8a05fc1
Show file tree
Hide file tree
Showing 14 changed files with 679 additions and 656 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- after update to 4.7.x buttons, sensors, volume display type need to be configure again using config UI
- after update to 3.15.x need remove the accessory frome Home app and add it again

## [5.2.0] - (01.12.2024)

## Changes

- move from commonJS to esm module
- moved constants.json to constants.js
- cleanup

## [5.1.11] - (07.09.2024)

## Changes
Expand Down
40 changes: 20 additions & 20 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
'use strict';
const path = require('path');
const fs = require('fs');
const MainZone = require('./src/mainzone.js');
const Zone2 = require('./src/zone2.js');
const Zone3 = require('./src/zone3.js');
const Surround = require('./src/surround.js');
const ImpulseGenerator = require('./src/impulsegenerator.js');
const CONSTANTS = require('./src/constants.json');
import { join } from 'path';
import { mkdirSync, existsSync, writeFileSync } from 'fs';
import MainZone from './src/mainzone.js';
import Zone2 from './src/zone2.js';
import Zone3 from './src/zone3.js';
import Surround from './src/surround.js';
import ImpulseGenerator from './src/impulsegenerator.js';
import { PluginName, PlatformName, ZoneNameShort } from './src/constants.js';

class DenonPlatform {
constructor(log, config, api) {
// only load if configured
if (!config || !Array.isArray(config.devices)) {
log.warn(`No configuration found for ${CONSTANTS.PluginName}`);
log.warn(`No configuration found for ${PluginName}`);
return;
}
this.accessories = [];

//check if prefs directory exist
const prefDir = path.join(api.user.storagePath(), 'denonTv');
const prefDir = join(api.user.storagePath(), 'denonTv');
try {
fs.mkdirSync(prefDir, { recursive: true });
mkdirSync(prefDir, { recursive: true });
} catch (error) {
log.error(`Prepare directory error: ${error.message ?? error}`);
return;
Expand Down Expand Up @@ -56,7 +56,7 @@ class DenonPlatform {
const refreshInterval = device.refreshInterval * 1000 || 5000;

//check files exists, if not then create it
const postFix = `${CONSTANTS.ZoneNameShort[zoneControl]}${host.split('.').join('')}`
const postFix = `${ZoneNameShort[zoneControl]}${host.split('.').join('')}`
const devInfoFile = `${prefDir}/devInfo_${postFix}`;
const inputsFile = `${prefDir}/inputs_${postFix}`;
const inputsNamesFile = `${prefDir}/inputsNames_${postFix}`;
Expand All @@ -71,8 +71,8 @@ class DenonPlatform {
];

files.forEach((file) => {
if (!fs.existsSync(file)) {
fs.writeFileSync(file, '');
if (!existsSync(file)) {
writeFileSync(file, '');
}
});
} catch (error) {
Expand All @@ -86,7 +86,7 @@ class DenonPlatform {
try {
const mainZone = new MainZone(api, device, zoneControl, deviceName, host, port, generation, devInfoFile, inputsFile, inputsNamesFile, inputsTargetVisibilityFile, refreshInterval);
mainZone.on('publishAccessory', (accessory) => {
api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
api.publishExternalAccessories(PluginName, [accessory]);
log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
})
.on('devInfo', (devInfo) => {
Expand Down Expand Up @@ -131,7 +131,7 @@ class DenonPlatform {
try {
const zone2 = new Zone2(api, device, zoneControl, deviceName, host, port, generation, devInfoFile, inputsFile, inputsNamesFile, inputsTargetVisibilityFile, refreshInterval);
zone2.on('publishAccessory', (accessory) => {
api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
api.publishExternalAccessories(PluginName, [accessory]);
log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
})
.on('devInfo', (devInfo) => {
Expand Down Expand Up @@ -176,7 +176,7 @@ class DenonPlatform {
try {
const zone3 = new Zone3(api, device, zoneControl, deviceName, host, port, generation, devInfoFile, inputsFile, inputsNamesFile, inputsTargetVisibilityFile, refreshInterval);
zone3.on('publishAccessory', (accessory) => {
api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
api.publishExternalAccessories(PluginName, [accessory]);
log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
})
.on('devInfo', (devInfo) => {
Expand Down Expand Up @@ -221,7 +221,7 @@ class DenonPlatform {
try {
const surround = new Surround(api, device, zoneControl, deviceName, host, port, generation, devInfoFile, inputsFile, inputsNamesFile, inputsTargetVisibilityFile, refreshInterval);
surround.on('publishAccessory', (accessory) => {
api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
api.publishExternalAccessories(PluginName, [accessory]);
log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
})
.on('devInfo', (devInfo) => {
Expand Down Expand Up @@ -276,6 +276,6 @@ class DenonPlatform {
}
};

module.exports = (api) => {
api.registerPlatform(CONSTANTS.PluginName, CONSTANTS.PlatformName, DenonPlatform, true);
export default (api) => {
api.registerPlatform(PluginName, PlatformName, DenonPlatform, true);
};
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"displayName": "Denon TV",
"name": "homebridge-denon-tv",
"version": "5.1.27",
"version": "5.2.0",
"description": "Homebridge plugin to control Denon/Marantz AV Receivers.",
"license": "MIT",
"author": "grzegorz914",
Expand All @@ -16,6 +16,7 @@
"bugs": {
"url": "https://github.com/grzegorz914/homebridge-denon-tv/issues"
},
"type": "module",
"main": "index.js",
"files": [
"src",
Expand Down
Loading

0 comments on commit 8a05fc1

Please sign in to comment.