From 3c5e78f3f859f545f6018b465c8e4df2dfa8c36f Mon Sep 17 00:00:00 2001 From: Grzegorz Date: Tue, 2 Jan 2024 12:23:45 +0100 Subject: [PATCH] release 2.12.0 --- CHANGELOG.md | 6 ++++++ README.md | 4 +++- config.schema.json | 28 ++++++++++++++++++++++------ package.json | 2 +- sample-config.json | 15 ++++++++++----- src/xboxdevice.js | 12 ++++++++++-- 6 files changed, 52 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d08755d..23755c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### NOTE!!! ## After update to 2.x.x the plugin settings (xboxLiveId) need to be updated. +## [2.12.0] - (02.01.2024) +## Changes +- added possibility to disable prefix name for buttons and sensors +- config schema updated +- cleanup + ## [2.11.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 3b77491..6980c8f 100644 --- a/README.md +++ b/README.md @@ -89,12 +89,14 @@ Homebridge plugin for Microsoft game Consoles. Tested with Xbox One X/S and Xbox | `buttons.command` | Here select button control mode or command, `Reboot` and `Switch App/Game`- only possible if `webApiControl` enabled. | | `buttons.oneStoreProductId` | Here set *Input oneStoreProductId*, only possible if `webApiControl` enabled. | | `buttons.displayType` | Here select display type in HomeKit app, possible `None/Disabled`, `Outlet`, `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 `Motion Sensor` (active on Power ON). | | `sensorInput`| If enabled, then the Input will be exposed as a `Motion Sensor` (active on every Input change). | | `sensorScreenSaver`| If enabled, then the Screen Saver will be exposed as a `Motion Sensor` (active on change to Screen Saver). | | `sensorInputs.name` | Here set own *Name* which You want expose to the *Homebridge/HomeKit* for this sensor. | -| `sensorInputs.reference` | Here set *Reference* like `Xbox.Dashboard_8wekyb3d8bbwe!Xbox.Dashboard.Application` to be exposed as sensor (active on switch to this Input). | +| `sensorInputs.reference` | Here set *Reference* like `Xbox.Dashboard_8wekyb3d8bbwe!Xbox.Dashboard.Application` to be exposed as sensor (active on switch to this Input). | | `sensorInputs.displayType` | Here select sensor type to be exposed in HomeKit app, possible `None/Disabled`, `Motion Sensor`, `Occupancy Sensor`, `Contact Sensor`. | +| `sensorInputs.namePrefix` | Here enable/disable the accessory name as a prefix for sensor name.| | `webApiControl` | This enable console control over Web Api. Additional functions are available in `Advanced Settings` section. | | `webApiPowerOnOff` | This enable `Power` control over Web Api. | | `webApiToken` | Required if `webApiControl` enabled, use Authorization Manager to get it. | diff --git a/config.schema.json b/config.schema.json index c8f5b09..fc1958b 100644 --- a/config.schema.json +++ b/config.schema.json @@ -441,6 +441,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 } } } @@ -518,6 +525,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 } } } @@ -803,7 +817,7 @@ { "key": "devices", "type": "tabarray", - "title": "{{ value.name || 'new device' }}", + "title": "{{ value.name || 'device' }}", "items": [ "devices[].name", "devices[].host", @@ -824,7 +838,7 @@ { "key": "devices[].inputs", "type": "tabarray", - "title": "{{ value.name || 'new input' }}", + "title": "{{ value.name || 'input' }}", "items": [ "devices[].inputs[].name", "devices[].inputs[].reference", @@ -847,12 +861,13 @@ { "key": "devices[].buttons", "type": "tabarray", - "title": "{{ value.name || 'new button' }}", + "title": "{{ value.name || 'button' }}", "items": [ "devices[].buttons[].name", "devices[].buttons[].command", "devices[].buttons[].oneStoreProductId", - "devices[].buttons[].displayType" + "devices[].buttons[].displayType", + "devices[].buttons[].namePrefix" ] } ] @@ -886,11 +901,12 @@ { "key": "devices[].sensorInputs", "type": "tabarray", - "title": "{{ value.name || 'new sensor' }}", + "title": "{{ value.name || 'sensor' }}", "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 c302830..399eae7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "displayName": "Xbox TV", "name": "homebridge-xbox-tv", - "version": "2.11.8", + "version": "2.12.0", "description": "Homebridge plugin to control Xbox game consoles.", "license": "MIT", "author": "grzegorz914", diff --git a/sample-config.json b/sample-config.json index 6b1194c..5649137 100644 --- a/sample-config.json +++ b/sample-config.json @@ -46,23 +46,27 @@ { "name": "Play", "command": "play", - "displayType": -1 + "displayType": -1, + "namePrefix": false }, { "name": "Record Game DVR", "command": "recordGameDvr", - "displayType": -1 + "displayType": -1, + "namePrefix": false }, { "name": "Reboot", "command": "reboot", - "displayType": -1 + "displayType": -1, + "namePrefix": false }, { "name": "A Way Out", "command": "switchAppGame", "oneStoreProductId": "oneStoreProductId", - "displayType": -1 + "displayType": -1, + "namePrefix": false } ], "sensorPower": false, @@ -72,7 +76,8 @@ { "name": "Dashboard", "reference": "Xbox.Dashboard_8wekyb3d8bbwe!Xbox.Dashboard.Application", - "displayType": -1 + "displayType": -1, + "namePrefix": false } ], "webApiControl": false, diff --git a/src/xboxdevice.js b/src/xboxdevice.js index 8260f2d..690ec6b 100644 --- a/src/xboxdevice.js +++ b/src/xboxdevice.js @@ -1006,13 +1006,17 @@ class XboxDevice extends EventEmitter { //get sensor display type const sensorInputDisplayType = sensorInput.displayType >= 0 ? sensorInput.displayType : -1; + //get sensor name prefix + const namePrefix = sensorInput.namePrefix ?? false; + if (sensorInputDisplayType >= 0) { if (sensorInputName && sensorInputReference) { const serviceType = [Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][sensorInputDisplayType]; + const name = namePrefix ? `${accessoryName} ${sensorInputName}` : sensorInputName; 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; @@ -1070,12 +1074,16 @@ class XboxDevice extends EventEmitter { //get button display type const buttonDisplayType = button.displayType >= 0 ? button.displayType : -1; + //get button name prefix + const namePrefix = button.namePrefix ?? false; + if (buttonDisplayType >= 0) { if (buttonName && buttonCommand && buttonMode) { const serviceType = [Service.Outlet, Service.Switch][buttonDisplayType]; + const name = namePrefix ? `${accessoryName} ${buttonName}` : buttonName; const buttonService = new serviceType(`${accessoryName} ${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;