diff --git a/Changelog.md b/Changelog.md index 90c918a..974ed55 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,17 @@ # Changelog +# v5.0.5 - 2021-09-21 + +## Notable Changes +- New Speaker Type: `fan` + +## Other Changes +- Refreshing tv cache through config ui x will no longer cached inputs (like hdmi, cec etc.) + +## Bugfixes +- Fixed an issue where updating the TV via the config ui x saved incorrect data +- Minor bugfixes + # v5.0.3 - 2021-09-20 ## Other Changes diff --git a/config.schema.json b/config.schema.json index dad8db4..01477f7 100644 --- a/config.schema.json +++ b/config.schema.json @@ -408,6 +408,10 @@ { "title": "Switch", "enum": ["switch"] + }, + { + "title": "Fan", + "enum": ["fan"] } ], "description": "Accessory type for the speaker.", diff --git a/homebridge-ui/server.js b/homebridge-ui/server.js index 8c3e49c..0a1eb5f 100644 --- a/homebridge-ui/server.js +++ b/homebridge-ui/server.js @@ -209,6 +209,7 @@ class UiServer extends HomebridgePluginUiServer { } }); + //REMOVE NOT EXISTING APPS tvCache.apps = tvCache.apps.filter((cachedApp) => apps.find((app) => app.name === cachedApp.name)); //REFRESH CHANNELS @@ -220,6 +221,7 @@ class UiServer extends HomebridgePluginUiServer { } }); + //REMOVE NOT EXISTING APPS tvCache.channels = tvCache.channels.filter((cachedChannel) => channels.find((channel) => channel.uri === cachedChannel.uri) ); @@ -233,9 +235,9 @@ class UiServer extends HomebridgePluginUiServer { } }); - tvCache.commands = tvCache.commands.filter((cachedCommand) => + /*tvCache.commands = tvCache.commands.filter((cachedCommand) => commands.find((command) => command.value === cachedCommand.value) - ); + );*/ //REFRESH INPUTS inputs.forEach((exInput) => { @@ -246,25 +248,23 @@ class UiServer extends HomebridgePluginUiServer { } }); - tvCache.inputs = tvCache.inputs.filter((cachedExInput) => + /*tvCache.inputs = tvCache.inputs.filter((cachedExInput) => inputs.find((exInput) => exInput.uri === cachedExInput.uri) - ); + );*/ - await this.storeTV(tvCache); + await this.storeTV(tvCache, television.name); } else { tvCache = { name: television.name, - inputs: { - apps: apps, - channels: channels, - commands: commands, - inputs: inputs, - macros: television.macros || [], - }, + apps: apps, + channels: channels, + commands: commands, + inputs: inputs, + macros: television.macros || [], }; - } - await this.storeTV(tvCache); + await this.storeTV(tvCache); + } await setTimeoutAsync(1000); this.pushEvent('refreshTV', `${television.name}: Done!`); @@ -278,16 +278,12 @@ class UiServer extends HomebridgePluginUiServer { return await removeTVFromCache(name, this.homebridgeStoragePath); } - async storeTV(television) { + async storeTV(television, fileName) { if (!television.name) { throw new RequestError('Can not store television in cache. No name defined for television'); } - if (!television.inputs) { - throw new RequestError('No inputs defined!'); - } - - await writeTvToCache(television.name, this.homebridgeStoragePath, television.inputs); + await writeTvToCache(fileName || television.name, this.homebridgeStoragePath, television); } } diff --git a/homebridge-ui/ui/src/utils/config.schema.js b/homebridge-ui/ui/src/utils/config.schema.js index d9bcb51..7ffce70 100644 --- a/homebridge-ui/ui/src/utils/config.schema.js +++ b/homebridge-ui/ui/src/utils/config.schema.js @@ -329,6 +329,10 @@ export default { title: 'Switch', enum: ['switch'], }, + { + title: 'Fan', + enum: ['fan'], + }, ], description: 'Accessory type for the speaker.', }, diff --git a/homebridge-ui/ui/src/views/New.vue b/homebridge-ui/ui/src/views/New.vue index daf6f5b..dfd8988 100644 --- a/homebridge-ui/ui/src/views/New.vue +++ b/homebridge-ui/ui/src/views/New.vue @@ -324,13 +324,11 @@ export default { this.progressState = 'Storing..'; await window.homebridge.request('/storeTV', { name: this.form.name, - inputs: { - apps: apps, - channels: channels, - commands: commands, - inputs: inputs, - macros: [], - }, + apps: apps, + channels: channels, + commands: commands, + inputs: inputs, + macros: [], }); this.progress = 90; diff --git a/package-lock.json b/package-lock.json index 4a7d8f0..1c33658 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "homebridge-bravia-tvos", - "version": "5.0.3", + "version": "5.0.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 628edb6..f1bee45 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-bravia-tvos", - "version": "5.0.3", + "version": "5.0.5", "description": "Homebridge plugin for Sony Bravia Android TVs", "main": "index.js", "repository": { diff --git a/src/accessories/accessory.config.js b/src/accessories/accessory.config.js index 78d7689..9fb0bdb 100644 --- a/src/accessories/accessory.config.js +++ b/src/accessories/accessory.config.js @@ -5,7 +5,7 @@ const { validIP, validMAC } = require('../utils/utils'); const Config = (tvConfig) => { const validDisplayCatagories = ['apps', 'channels', 'commands', 'inputs', 'macros']; const validSpeakerOutput = ['speaker', 'headphone', 'other']; - const validSpeakerAccTypes = ['lightbulb', 'switch']; + const validSpeakerAccTypes = ['lightbulb', 'switch', 'fan']; const validChannelSources = ['dvbt', 'dvbc', 'dvbs', 'isdbt', 'isdbs', 'isdbc', 'analog']; const validInputSources = ['cec', 'component', 'composite', 'hdmi', 'scart', 'widi']; diff --git a/src/accessories/accessory.handler.js b/src/accessories/accessory.handler.js index fe01052..855467b 100644 --- a/src/accessories/accessory.handler.js +++ b/src/accessories/accessory.handler.js @@ -110,6 +110,16 @@ class Handler { .getService(this.api.hap.Service.Switch) .getCharacteristic(this.api.hap.Characteristic.On) .updateValue(!mute); + } else if (speakerType === 'fan') { + this.accessory + .getService(this.api.hap.Service.Fanv2) + .getCharacteristic(this.api.hap.Characteristic.Active) + .updateValue(mute ? 0 : 1); + + this.accessory + .getService(this.api.hap.Service.Fanv2) + .getCharacteristic(this.api.hap.Characteristic.RotationSpeed) + .updateValue(volume); } else { this.accessory .getService(this.api.hap.Service.Lightbulb) diff --git a/src/accessories/television/television.accessory.js b/src/accessories/television/television.accessory.js index a0a29bd..b4d4422 100644 --- a/src/accessories/television/television.accessory.js +++ b/src/accessories/television/television.accessory.js @@ -259,6 +259,22 @@ class Accessory { speakerService .getCharacteristic(this.api.hap.Characteristic.On) .onSet((state) => this.handler.setMute(state, true)); + } else if (speakerType === 'fan') { + let speakerService = this.accessory.addService( + this.api.hap.Service.Fanv2, + `${this.accessory.displayName} Speaker`, + 'speaker' + ); + + speakerService.addCharacteristic(this.api.hap.Characteristic.RotationSpeed); + + speakerService + .getCharacteristic(this.api.hap.Characteristic.Active) + .onSet((state) => this.handler.setMute(state, true)); + + speakerService + .getCharacteristic(this.api.hap.Characteristic.RotationSpeed) + .onSet((state) => this.handler.setVolume(state)); } else { let speakerService = this.accessory.addService( this.api.hap.Service.Lightbulb,