From fa01c17a2d5f6c6248c07533f8bcde429c734bbb Mon Sep 17 00:00:00 2001 From: Grzegorz Date: Tue, 2 Jan 2024 10:39:58 +0100 Subject: [PATCH] release 4.5.0 --- CHANGELOG.md | 6 ++++++ README.md | 2 ++ config.schema.json | 20 ++++++++++++++++++-- package.json | 6 +++--- sample-config.json | 9 ++++++--- src/denondevice.js | 12 ++++++++++-- 6 files changed, 45 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d47b7b6..2299ec8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## The properties *inputs.displayType* and *surrounds.displayType* are removed. ## Note - after update to 3.15.x need remove the accessory frome Home app and add it again. +## [4.5.0] - (02.01.2024) +## Changes +- added possibility to disable prefix name for buttons and sensors [#215](https://github.com/grzegorz914/homebridge-denon-tv/issues/215) +- config schema updated +- cleanup + ## [4.4.0] - (29.12.2023) ## Changes - added possibility to select display inputs order, possible by `None`, `Alphabetically Name`, `Alphabetically Reference` diff --git a/README.md b/README.md index b48a424..551a59c 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ Tested with Denon AVR-X6300H, Denon AVR-X2700H, Denon AVR-3311CI, Marantz SR8012 | `buttons.name` | Here set *Button Name* which You want expose to the *Homebridge/HomeKit*. | | `buttons.reference` | Here choice function for additional control button for Main Zone. | | `buttons.displayType` | Here select display type in HomeKit app, possible `-1 - None/Disabled`, `0 - Outlet`, `1 - Switch`.| +| `buttons.namePrefix` | Here enable/disable the accessory name as a prefix for button name.| | `sensorPower`| If enabled, then the Power will be exposed as a `Contact Sensor` to use with automations. | | `sensorVolume`| If enabled, then the Volume will be exposed as a `Contact Sensor` to use with automations. | | `sensorMute`| If enabled, then the Mute will be exposed as a `Contact Sensor` to use with automations. | @@ -88,6 +89,7 @@ Tested with Denon AVR-X6300H, Denon AVR-X2700H, Denon AVR-3311CI, Marantz SR8012 | `sensorInputs.name` | Here set own *Name* which You want expose to the *Homebridge/HomeKit* for this sensor. | | `sensorInputs.reference` | Here set *Reference* like `CBL/SAT`, `GAME` to be exposed as `Contact Sensor` active on switch to this Input. | | `sensorInputs.displayType` | Here select sensor type to be exposed in HomeKit app, `-1 - None/Disabled`, `0 - Motion Sensor`, `1 - Occupancy Sensor`, `2 - Contact Sensor`. | +| `sensorInputs.namePrefix` | Here enable/disable the accessory name as a prefix for sensor name.| | `enableDebugMode` | If enabled, deep log will be present in homebridge console. | | `disableLogInfo` | If enabled, disable log info, all values and state will not be displayed in Homebridge log console. | | `disableLogDeviceInfo` | If enabled, add ability to disable log device info by every connections device to the network. | diff --git a/config.schema.json b/config.schema.json index bcece6d..f54eb2f 100644 --- a/config.schema.json +++ b/config.schema.json @@ -4441,6 +4441,13 @@ ], "description": "Here select display type in HomeKit app.", "required": true + }, + "namePrefix": { + "title": "Prefix", + "type": "boolean", + "default": false, + "description": "Here enable/disable the accessory name as a prefix for button name.", + "required": true } } } @@ -4525,6 +4532,13 @@ ], "description": "Here select sensor type to be exposed in HomeKit app.", "required": true + }, + "namePrefix": { + "title": "Prefix", + "type": "boolean", + "default": false, + "description": "Here enable/disable the accessory name as a prefix for sensor name.", + "required": true } } } @@ -4838,7 +4852,8 @@ "items": [ "devices[].buttons[].name", "devices[].buttons[].reference", - "devices[].buttons[].displayType" + "devices[].buttons[].displayType", + "devices[].buttons[].namePrefix" ] } ] @@ -4877,7 +4892,8 @@ "items": [ "devices[].sensorInputs[].name", "devices[].sensorInputs[].reference", - "devices[].sensorInputs[].displayType" + "devices[].sensorInputs[].displayType", + "devices[].sensorInputs[].namePrefix" ] } ] diff --git a/package.json b/package.json index bad9081..5ba94cc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "displayName": "Denon TV", "name": "homebridge-denon-tv", - "version": "4.4.4", + "version": "4.5.0", "description": "Homebridge plugin to control Denon/Marantz AV Receivers.", "license": "MIT", "author": "grzegorz914", @@ -42,8 +42,8 @@ "heos" ], "funding": { - "type" : "github", - "url" : "https://github.com/sponsors/grzegorz914" + "type": "github", + "url": "https://github.com/sponsors/grzegorz914" }, "contributors": [], "scripts": { diff --git a/sample-config.json b/sample-config.json index 945e955..0f48549 100644 --- a/sample-config.json +++ b/sample-config.json @@ -44,12 +44,14 @@ { "name": "MASTER POWER ON", "reference": "0PWON", - "displayType": -1 + "displayType": -1, + "namePrefix": false }, { "name": "ZM POWER ON", "reference": "0ZMON", - "displayType": -1 + "displayType": -1, + "namePrefix": false } ], "sensorPower": false, @@ -60,7 +62,8 @@ { "name": "Tuner Sat", "reference": "CBL/SAT", - "displayType": -1 + "displayType": -1, + "namePrefix": false } ], "enableDebugMode": false, diff --git a/src/denondevice.js b/src/denondevice.js index da45296..49e3053 100644 --- a/src/denondevice.js +++ b/src/denondevice.js @@ -1049,13 +1049,17 @@ class DenonDevice extends EventEmitter { //get display type const sensorInputDisplayType = sensorInput.displayType >= 0 ? sensorInput.displayType : -1; + //get button reference + const namePrefix = sensorInput.namePrefix ?? false; + if (sensorInputDisplayType >= 0) { if (sensorInputName && sensorInputReference) { + const name = namePrefix ? `${accessoryName} ${sensorInputName}` : sensorInputName; const serviceType = [Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][sensorInputDisplayType]; const characteristicType = [Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][sensorInputDisplayType]; const sensorInputService = new serviceType(`${accessoryName} ${sensorInputName}`, `Sensor ${i}`); sensorInputService.addOptionalCharacteristic(Characteristic.ConfiguredName); - sensorInputService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${sensorInputName}`); + sensorInputService.setCharacteristic(Characteristic.ConfiguredName, name); sensorInputService.getCharacteristic(characteristicType) .onGet(async () => { const state = this.power ? (this.reference === sensorInputReference) : false; @@ -1093,12 +1097,16 @@ class DenonDevice extends EventEmitter { //get button display type const buttonDisplayType = button.displayType >= 0 ? button.displayType : -1; + //get button reference + const namePrefix = button.namePrefix ?? false; + if (buttonDisplayType >= 0) { if (buttonName && buttonReference) { const serviceType = [Service.Outlet, Service.Switch][buttonDisplayType]; + const name = namePrefix ? `${accessoryName} ${buttonName}` : buttonName; const buttonService = new serviceType(`${this.sZoneName} ${buttonName}`, `Button ${i}`); buttonService.addOptionalCharacteristic(Characteristic.ConfiguredName); - buttonService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${buttonName}`); + buttonService.setCharacteristic(Characteristic.ConfiguredName, name); buttonService.getCharacteristic(Characteristic.On) .onGet(async () => { const state = false;