Skip to content

Commit

Permalink
release 2.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
grzegorz914 committed Jan 2, 2024
1 parent 3613d2d commit 3c5e78f
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 15 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down
28 changes: 22 additions & 6 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down Expand Up @@ -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
}
}
}
Expand Down Expand Up @@ -803,7 +817,7 @@
{
"key": "devices",
"type": "tabarray",
"title": "{{ value.name || 'new device' }}",
"title": "{{ value.name || 'device' }}",
"items": [
"devices[].name",
"devices[].host",
Expand All @@ -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",
Expand All @@ -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"
]
}
]
Expand Down Expand Up @@ -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"
]
}
]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
15 changes: 10 additions & 5 deletions sample-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -72,7 +76,8 @@
{
"name": "Dashboard",
"reference": "Xbox.Dashboard_8wekyb3d8bbwe!Xbox.Dashboard.Application",
"displayType": -1
"displayType": -1,
"namePrefix": false
}
],
"webApiControl": false,
Expand Down
12 changes: 10 additions & 2 deletions src/xboxdevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3c5e78f

Please sign in to comment.