Skip to content

Commit

Permalink
release 3.2.3
Browse files Browse the repository at this point in the history
## Changed
- cleanup
- rebuild mqtt topics
  • Loading branch information
grzegorz914 committed Aug 29, 2022
1 parent dcef645 commit 0dc362b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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.3.3] - (29.08.2022)
## Changed
- cleanup
- rebuild mqtt topics

## [2.3.2] - (28.08.2022)
## Changed
- fix publish MQTT message
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Homebridge plugin for Microsoft game Consoles. Tested with Xbox One X/S and Xbox
* Siri can be used for all functions, some times need create legacy buttons/switches/sensors.
* Automations can be used for all functions, some times need create legacy buttons/switches/sensors.
* Record Game DVR with additional button.
* MQTT Client publisch all available data from device.
* MQTT publisch topic *Info*, *State* as payload JSON data.

<p align="left">
<a href="https://github.com/grzegorz914/homebridge-xbox-tv"><img alt="Accessory tile in the HomeKit app" src="https://raw.githubusercontent.com/grzegorz914/homebridge-xbox-tv/master/graphics/homekit.png" width="382" /></a>
Expand Down
37 changes: 23 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class XBOXDEVICE {
this.log('Device: %s %s, %s', this.host, this.name, message);
})
.on('error', (error) => {
this.log('Device: %s %s, %s', this.host, this.name, error);
this.log.error('Device: %s %s, %s', this.host, this.name, error);
})
.on('debug', (message) => {
this.log('Device: %s %s, debug: %s', this.host, this.name, message);
Expand Down Expand Up @@ -225,22 +225,12 @@ class XBOXDEVICE {
userToken: this.userToken,
uhs: this.userHash,
infoLog: this.disableLogInfo,
debugLog: this.enableDebugMode,
mqttEnabled: this.mqttEnabled
debugLog: this.enableDebugMode
});

this.xboxLocalApi.on('connected', (message) => {
this.log('Device: %s %s, %s', this.host, this.name, message)
})
.on('error', (error) => {
this.log('Device: %s %s, %s', this.host, this.name, error);
})
.on('debug', (message) => {
this.log('Device: %s %s, %s', this.host, this.name, message);
})
.on('message', (message) => {
this.log('Device: %s %s, %s', this.host, this.name, message);
})
.on('deviceInfo', async (firmwareRevision, locale) => {
if (!this.disableLogDeviceInfo) {
this.log('-------- %s --------', this.name);
Expand All @@ -256,11 +246,13 @@ class XBOXDEVICE {
'manufacturer': this.manufacturer,
'modelName': this.modelName,
'serialNumber': this.serialNumber,
'firmwareRevision': firmwareRevision
'firmwareRevision': firmwareRevision,
'locale': locale
};
const devInfo = JSON.stringify(obj, null, 2);
const writeDevInfo = await fsPromises.writeFile(this.devInfoFile, devInfo);
const debug = this.enableDebugMode ? this.log('Device: %s %s, debug saved device info: %s', this.host, this.name, devInfo) : false;
const mqtt = this.mqttEnabled ? this.mqtt.send('Info', obj) : false;
} catch (error) {
this.log.error('Device: %s %s, device info error: %s', this.host, this.name, error);
};
Expand All @@ -269,6 +261,14 @@ class XBOXDEVICE {
})
.on('stateChanged', (power, titleId, inputReference, volume, mute, mediaState) => {
const inputIdentifier = this.inputsReference.indexOf(inputReference) >= 0 ? this.inputsReference.indexOf(inputReference) : this.inputsTitleId.indexOf(titleId) >= 0 ? this.inputsTitleId.indexOf(titleId) : this.inputIdentifier;
const obj = {
'power': power,
'titleId': titleId,
'app': inputReference,
'volume': volume,
'mute': mute,
'mediaState': mediaState,
};

//update characteristics
if (this.televisionService) {
Expand Down Expand Up @@ -298,7 +298,16 @@ class XBOXDEVICE {
this.muteState = mute;
this.mediaState = mediaState;
this.inputIdentifier = inputIdentifier;
this.mqtt.send('Info', this.devInfo);
const mqtt = this.mqttEnabled ? this.mqtt.send('State', obj) : false;
})
.on('error', (error) => {
this.log.error('Device: %s %s, %s', this.host, this.name, error);
})
.on('debug', (message) => {
this.log('Device: %s %s, %s', this.host, this.name, message);
})
.on('message', (message) => {
this.log('Device: %s %s, %s', this.host, this.name, message);
})
.on('mqtt', (topic, message) => {
this.mqtt.send(topic, message);
Expand Down
2 changes: 0 additions & 2 deletions src/xboxlocalapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class XBOXLOCALAPI extends EventEmitter {
this.userHash = config.uhs;
this.infoLog = config.infoLog;
this.debugLog = config.debugLog;
this.mqttEnabled = config.mqttEnabled;

this.crypto = new SGCrypto();
this.isConnected = false;
Expand Down Expand Up @@ -300,7 +299,6 @@ class XBOXLOCALAPI extends EventEmitter {

this.emit('stateChanged', power, titleId, inputReference, volume, mute, mediaState);
const debug = this.debugLog ? this.emit('debug', `Status changed, app Id: ${titleId}, reference: ${inputReference}`) : false;
const mqtt1 = this.mqttEnabled ? this.emit('mqtt', 'State', JSON.stringify(decodedMessage, null, 2)) : false;
};
};
}).on('channelResponse', (message) => {
Expand Down

0 comments on commit 0dc362b

Please sign in to comment.