Skip to content

Commit

Permalink
v5.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
seydx committed Sep 21, 2021
1 parent d80778b commit a97e338
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 30 deletions.
12 changes: 12 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@
{
"title": "Switch",
"enum": ["switch"]
},
{
"title": "Fan",
"enum": ["fan"]
}
],
"description": "Accessory type for the speaker.",
Expand Down
36 changes: 16 additions & 20 deletions homebridge-ui/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
);
Expand All @@ -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) => {
Expand All @@ -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!`);
Expand All @@ -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);
}
}

Expand Down
4 changes: 4 additions & 0 deletions homebridge-ui/ui/src/utils/config.schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ export default {
title: 'Switch',
enum: ['switch'],
},
{
title: 'Fan',
enum: ['fan'],
},
],
description: 'Accessory type for the speaker.',
},
Expand Down
12 changes: 5 additions & 7 deletions homebridge-ui/ui/src/views/New.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/accessories/accessory.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand Down
10 changes: 10 additions & 0 deletions src/accessories/accessory.handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions src/accessories/television/television.accessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a97e338

Please sign in to comment.