Skip to content

Commit

Permalink
release v3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
grzegorz914 committed Jan 19, 2025
1 parent fa48a8f commit 8c043d5
Show file tree
Hide file tree
Showing 13 changed files with 1,080 additions and 1,026 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- After update to 2.x.x the plugin settings (xboxLiveId) need to be updated
- After update to v3.0.0 RESTFull and MQTT config settings need to be updated

## [3.3.0] - (19.01.2025)

## Changes

- added possibility to disable/enable log success, info, warn, error
- refactor cnnect code
- bump dependencies
- config schema updated
- redme updated
- cleanup

## [3.2.0] - (30.11.2024)

## Changes
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,12 @@ Homebridge plugin for Microsoft game Consoles. Tested with Xbox One X/S and Xbox
| `volumeControlName` | Here set Your own volume control name or leave empty. |
| `volumeControl` | Here choice what a additional volume control mode You want to use (`0 - None/Disabled`, `1 - Lightbulb`, `2 - Fan`), not working yet. |
| `infoButtonCommand` | Here select the function of `I` button in RC app. |
| `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. |
| `disableLogInfo` | If enabled, disable log info, all values and state will not be displayed in Homebridge log console. |
| `disableLogSuccess` | If enabled, disable logging device success. |
| `disableLogWarn` | If enabled, disable logging device warnings. |
| `disableLogError` | If enabled, disable logging device error. |
| `enableDebugMode` | If enabled, deep log will be present in homebridge console. |
| `restFul` | This is RSTful server. |
| `enable` | If enabled, RESTful server will start automatically and respond to any path request. |
| `port` | Here set the listening `Port` for RESTful server. |
Expand Down
39 changes: 29 additions & 10 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -696,25 +696,41 @@
],
"required": false
},
"enableDebugMode": {
"title": "Debug",
"disableLogDeviceInfo": {
"title": "Disable Log Device Info",
"type": "boolean",
"default": false,
"description": "This enable debug mode.",
"description": "This disable logging device info by every connections device to the network.",
"required": false
},
"disableLogInfo": {
"title": "Disable Log Info",
"type": "boolean",
"default": false,
"description": "This disable logging values and states on every it change.",
"required": false
},
"disableLogDeviceInfo": {
"title": "Disable Log Device Info",
"disableLogSuccess": {
"title": "Disable Log Success",
"type": "boolean",
"default": false,
"required": false
},
"disableLogWarn": {
"title": "Disable Log Warn",
"type": "boolean",
"default": false,
"required": false
},
"disableLogError": {
"title": "Disable Log Error",
"type": "boolean",
"default": false,
"required": false
},
"enableDebugMode": {
"title": "Enable Log Debug",
"type": "boolean",
"default": false,
"description": "This disable log device info by every connections device to the network.",
"required": false
},
"restFul": {
Expand Down Expand Up @@ -983,11 +999,14 @@
},
{
"key": "devices[]",
"title": "System",
"title": "Log",
"items": [
"devices[].enableDebugMode",
"devices[].disableLogDeviceInfo",
"devices[].disableLogInfo",
"devices[].disableLogDeviceInfo"
"devices[].disableLogSuccess",
"devices[].disableLogWarn",
"devices[].disableLogError",
"devices[].enableDebugMode"
]
},
{
Expand Down
44 changes: 25 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ class XboxPlatform {
return;
}

//debug config
const enableDebugMode = device.enableDebugMode;
const debug = enableDebugMode ? log.info(`Device: ${host} ${deviceName}, Did finish launching.`) : false;
//log config
const enableDebugMode = device.enableDebugMode || false;
const disableLogDeviceInfo = device.disableLogDeviceInfo || false;
const disableLogInfo = device.disableLogInfo || false;
const disableLogSuccess = device.disableLogSuccess || false;
const disableLogWarn = device.disableLogWarn || false;
const disableLogError = device.disableLogError || false;
const debug = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, did finish launching.`);
const config = {
...device,
xboxLiveId: 'removed',
Expand All @@ -46,7 +51,7 @@ class XboxPlatform {
passwd: 'removed'
}
};
const debug1 = enableDebugMode ? log.info(`Device: ${host} ${deviceName}, Config: ${JSON.stringify(config, null, 2)}`) : false;
const debug1 = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, Config: ${JSON.stringify(config, null, 2)}.`);

//check files exists, if not then create it
const postFix = host.split('.').join('');
Expand All @@ -72,7 +77,7 @@ class XboxPlatform {
}
});
} catch (error) {
log.error(`Device: ${host} ${deviceName}, Prepare files error: ${error}`);
const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, Prepare files error: ${error}.`);
return;
}

Expand All @@ -81,45 +86,46 @@ class XboxPlatform {
const xboxDevice = new XboxDevice(api, device, authTokenFile, devInfoFile, inputsFile, inputsNamesFile, inputsTargetVisibilityFile);
xboxDevice.on('publishAccessory', (accessory) => {
api.publishExternalAccessories(PluginName, [accessory]);
log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
const emitLog = disableLogSuccess ? false : log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
})
.on('devInfo', (devInfo) => {
log.info(devInfo);
const emitLog = disableLogDeviceInfo ? false : log.info(devInfo);
})
.on('success', (message) => {
log.success(`Device: ${host} ${deviceName}, ${message}`);
.on('success', (success) => {
const emitLog = disableLogSuccess ? false : log.success(`Device: ${host} ${deviceName}, ${success}.`);
})
.on('message', (message) => {
log.info(`Device: ${host} ${deviceName}, ${message}`);
.on('info', (info) => {
const emitLog = disableLogInfo ? false : log.info(`Device: ${host} ${deviceName}, ${info}.`);
})
.on('debug', (debug) => {
log.info(`Device: ${host} ${deviceName}, debug: ${debug}`);
const emitLog = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, debug: ${debug}.`);
})
.on('warn', (warn) => {
log.warn(`warn: ${host} ${deviceName}, ${warn}`);
const lemitLogog = disableLogWarn ? false : log.warn(`Device: ${host} ${deviceName}, ${warn}.`);
})
.on('error', (error) => {
log.error(`Device: ${host} ${deviceName}, ${error}`);
const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}.`);
});

//create impulse generator
const impulseGenerator = new ImpulseGenerator();
impulseGenerator.on('start', async () => {
try {
await xboxDevice.start();
impulseGenerator.stop();
const startDone = await xboxDevice.start();
const stopImpulseGenerator = startDone ? impulseGenerator.stop() : false;
} catch (error) {
const logError = disableLogConnectError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
};
}).on('state', (state) => {
const debug = enableDebugMode ? state ? log.info(`Device: ${host} ${deviceName}, Start impulse generator started.`) : log.info(`Device: ${host} ${deviceName}, Start impulse generator stopped.`) : false;
const emitLog = !enableDebugMode ? false : state ? log.info(`Device: ${host} ${deviceName}, Start impulse generator started.`) : log.info(`Device: ${host} ${deviceName}, Start impulse generator stopped.`);
});

//start impulse generator
impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
} catch (error) {
log.error(`Device: ${host} ${deviceName}, Did finish launching error: ${error}`);
throw new Error(`Device: ${host} ${deviceName}, Did finish launching error: ${error}.`);
}
await new Promise(resolve => setTimeout(resolve, 500));
}
});
}
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"displayName": "Xbox TV",
"name": "homebridge-xbox-tv",
"version": "3.2.2",
"version": "3.3.0",
"description": "Homebridge plugin to control Xbox game consoles.",
"license": "MIT",
"author": "grzegorz914",
Expand Down Expand Up @@ -40,7 +40,7 @@
"elliptic": "^6.6.1",
"hex-to-binary": "^1.0.1",
"jsrsasign": "^11.1.0",
"uuid": "^11.0.3",
"uuid": "^11.0.5",
"ping": "^0.4.4",
"express": "^4.21.2",
"axios": "^1.7.9"
Expand Down
35 changes: 21 additions & 14 deletions sample-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,28 @@
"volumeControlNamePrefix": false,
"volumeControlName": "Volume",
"volumeControl": 0,
"enableDebugMode": false,
"disableLogInfo": false,
"disableLogDeviceInfo": false,
"enableRestFul": false,
"restFulPort": 3000,
"restFulDebug": false,
"enableMqtt": false,
"mqttDebug": false,
"mqttHost": "192.168.1.33",
"mqttPort": 1883,
"mqttClientId": "",
"mqttPrefix": "home/xbox",
"mqttAuth": false,
"mqttUser": "user",
"mqttPass": "password"
"disableLogInfo": false,
"disableLogSuccess": false,
"disableLogWarn": false,
"disableLogError": false,
"enableDebugMode": false,
"restFul": {
"enable": false,
"port": 3000,
"debug": false
},
"mqtt": {
"enable": false,
"host": "192.168.1.33",
"port": 1883,
"clientId": "",
"prefix": "home/envoy",
"auth": false,
"user": "user",
"pass": "password",
"debug": false
}
}
]
}
Expand Down
26 changes: 13 additions & 13 deletions src/impulsegenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class ImpulseGenerator extends EventEmitter {

async start(timers) {
if (this.timersState) {
await this.stop();
this.state(true);
return true;
}

this.timers = [];
Expand All @@ -22,28 +23,27 @@ class ImpulseGenerator extends EventEmitter {
};

//update state
this.timersState = true;
this.state();

this.state(true);
return true;
}

async stop() {
if (this.timersState) {
this.timers.forEach(timer => clearInterval(timer));
if (!this.timersState) {
this.state(false);
return true;
}

//update state
this.timers.forEach(timer => clearInterval(timer));
this.timers = [];
this.timersState = false;
this.state();

return true;
this.state(false);
return true
}

state() {
this.emit('state', this.timersState);
return this.timersState;
state(state) {
this.timersState = state;
this.emit('state', state);
}
}
export default ImpulseGenerator;

Loading

0 comments on commit 8c043d5

Please sign in to comment.