Skip to content

Commit

Permalink
Revert "Add mandatory traits"
Browse files Browse the repository at this point in the history
This reverts commit 59ed28f.
  • Loading branch information
atrovato committed Oct 19, 2023
1 parent 59ed28f commit b6d3f13
Show file tree
Hide file tree
Showing 20 changed files with 14 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const { DEVICE_FEATURE_CATEGORIES } = require('../../../../utils/constants');
const curtainType = {
key: 'action.devices.types.CURTAIN',
category: DEVICE_FEATURE_CATEGORIES.CURTAIN,
mandatoryTraits: ['action.devices.traits.OpenClose'],
};

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const { DEVICE_FEATURE_CATEGORIES } = require('../../../../utils/constants');
const lightType = {
key: 'action.devices.types.LIGHT',
category: DEVICE_FEATURE_CATEGORIES.LIGHT,
mandatoryTraits: ['action.devices.traits.OnOff'],
};

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const { DEVICE_FEATURE_CATEGORIES } = require('../../../../utils/constants');
const shutterType = {
key: 'action.devices.types.SHUTTER',
category: DEVICE_FEATURE_CATEGORIES.SHUTTER,
mandatoryTraits: ['action.devices.traits.OpenClose'],
};

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const { DEVICE_FEATURE_CATEGORIES } = require('../../../../utils/constants');
const switchType = {
key: 'action.devices.types.SWITCH',
category: DEVICE_FEATURE_CATEGORIES.SWITCH,
mandatoryTraits: ['action.devices.traits.OnOff'],
};

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ const { DEVICE_FEATURE_CATEGORIES } = require('../../../../utils/constants');
const televisionType = {
key: 'action.devices.types.TV',
category: DEVICE_FEATURE_CATEGORIES.TELEVISION,
mandatoryTraits: [
'action.devices.traits.AppSelector',
'action.devices.traits.InputSelector',
'action.devices.traits.MediaState',
'action.devices.traits.OnOff',
'action.devices.traits.TransportControl',
'action.devices.traits.Volume',
],
};

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ async function onExecute(body) {
// Command key not found
logger.error(`GoogleActions "${exec.command}" command is not managed.`);
// All devices are failure
commands.push({ ids: [selector], status: 'ERROR', errorCode: 'functionNotSupported' });
commands.push({ ids: [selector], status: 'ERROR' });
} else {
const commandExecutor = trait.commands[exec.command];

const deviceStatus = { ids: [selector] };
const deviceStatus = { ids: [selector], status: 'ERROR' };
// Build related feature events according incomping attributes
// errorCodes : see https://developers.home.google.com/cloud-to-cloud/intents/errors-exceptions
const { events = [], errorCode } = await commandExecutor(gladysDevice, exec.params, this.gladys);
const { events = [] } = await commandExecutor(gladysDevice, exec.params, this.gladys);

if (events.length > 0) {
events.forEach((eventMessage) => {
Expand All @@ -61,9 +60,6 @@ async function onExecute(body) {
this.gladys.event.emit(EVENTS.ACTION.TRIGGERED, action);
});
deviceStatus.status = 'PENDING';
} else {
deviceStatus.status = 'ERROR';
deviceStatus.errorCode = errorCode || 'functionNotSupported';
}

commands.push(deviceStatus);
Expand Down

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions server/services/google-actions/lib/traits/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
const { appSelectorTrait } = require('./googleActions.appSelector.trait');
const { brightnessTrait } = require('./googleActions.brightness.trait');
const { channelTrait } = require('./googleActions.channel.trait');
const { colorSettingTrait } = require('./googleActions.colorSetting.trait');
const { inputSelectorTrait } = require('./googleActions.inputSelector.trait');
const { onOffTrait } = require('./googleActions.onOff.trait');
const { openCloseTrait } = require('./googleActions.openClose.trait');
const { transportControl } = require('./googleActions.transportControl.trait');
const { volumeTrait } = require('./googleActions.volume.trait');

const TRAITS = [
appSelectorTrait,
brightnessTrait,
channelTrait,
colorSettingTrait,
inputSelectorTrait,
onOffTrait,
openCloseTrait,
transportControl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const exploreTrait = (trait, feature) => {
* @param {object} feature - Gladys device feature.
* @returns {object} GoogleActions device type and traits.
* @example
* determineTrait(device);
* determineTypeAndTraits(device);
*/
function determineTrait(feature) {
// Matching feature trait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ function determineTypeAndTraits(device) {
if (nbFeatureTypeMatch > nbFeatureTypeMatches) {
type = deviceType.key;
nbFeatureTypeMatches = nbFeatureTypeMatch;

const mandatoryTraits = deviceType.mandatoryTraits || [];
mandatoryTraits.forEach((trait) => {
// Add mandatory trait only if missing
if (!traits.includes(trait)) {
traits.push(trait);
}
});
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('GoogleActions Handler - onSync - brightness (light)', () => {
{
id: 'device-1',
type: 'action.devices.types.LIGHT',
traits: ['action.devices.traits.Brightness', 'action.devices.traits.OnOff'],
traits: ['action.devices.traits.Brightness'],
attributes: {},
name: {
name: 'Device 1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('GoogleActions Handler - onSync - brightness (switch)', () => {
{
id: 'device-1',
type: 'action.devices.types.SWITCH',
traits: ['action.devices.traits.Brightness', 'action.devices.traits.OnOff'],
traits: ['action.devices.traits.Brightness'],
attributes: {},
name: {
name: 'Device 1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,7 @@ describe('GoogleActions Handler - onSync - channel (tv)', () => {
{
id: 'device-1',
type: 'action.devices.types.TV',
traits: [
'action.devices.traits.Channel',
'action.devices.traits.AppSelector',
'action.devices.traits.InputSelector',
'action.devices.traits.MediaState',
'action.devices.traits.OnOff',
'action.devices.traits.TransportControl',
'action.devices.traits.Volume',
],
traits: ['action.devices.traits.Channel'],
attributes: {
commandOnlyChannels: true,
},
Expand Down Expand Up @@ -154,15 +146,7 @@ describe('GoogleActions Handler - onSync - channel (tv)', () => {
{
id: 'device-1',
type: 'action.devices.types.TV',
traits: [
'action.devices.traits.Channel',
'action.devices.traits.AppSelector',
'action.devices.traits.InputSelector',
'action.devices.traits.MediaState',
'action.devices.traits.OnOff',
'action.devices.traits.TransportControl',
'action.devices.traits.Volume',
],
traits: ['action.devices.traits.Channel'],
attributes: {
commandOnlyChannels: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('GoogleActions Handler - onSync - color', () => {
{
id: 'device-1',
type: 'action.devices.types.LIGHT',
traits: ['action.devices.traits.ColorSetting', 'action.devices.traits.OnOff'],
traits: ['action.devices.traits.ColorSetting'],
attributes: {
colorModel: 'rgb',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('GoogleActions Handler - onSync - color', () => {
{
id: 'device-1',
type: 'action.devices.types.LIGHT',
traits: ['action.devices.traits.ColorSetting', 'action.devices.traits.OnOff'],
traits: ['action.devices.traits.ColorSetting'],
attributes: {
colorTemperatureRange: {
temperatureMinK: 2203,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,7 @@ describe('GoogleActions Handler - onSync - onOff (tv)', () => {
{
id: 'device-1',
type: 'action.devices.types.TV',
traits: [
'action.devices.traits.OnOff',
'action.devices.traits.AppSelector',
'action.devices.traits.InputSelector',
'action.devices.traits.MediaState',
'action.devices.traits.TransportControl',
'action.devices.traits.Volume',
],
traits: ['action.devices.traits.OnOff'],
attributes: {},
name: {
name: 'Device 1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,7 @@ describe('GoogleActions Handler - onSync - TransportControl (tv)', () => {
{
id: 'device-1',
type: 'action.devices.types.TV',
traits: [
'action.devices.traits.TransportControl',
'action.devices.traits.AppSelector',
'action.devices.traits.InputSelector',
'action.devices.traits.MediaState',
'action.devices.traits.OnOff',
'action.devices.traits.Volume',
],
traits: ['action.devices.traits.TransportControl'],
attributes: {
transportControlSupportedCommands: ['PAUSE', 'RESUME', 'STOP', 'NEXT', 'PREVIOUS'],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,7 @@ describe('GoogleActions Handler - onSync - volume (tv)', () => {
{
id: 'device-1',
type: 'action.devices.types.TV',
traits: [
'action.devices.traits.Volume',
'action.devices.traits.AppSelector',
'action.devices.traits.InputSelector',
'action.devices.traits.MediaState',
'action.devices.traits.OnOff',
'action.devices.traits.TransportControl',
],
traits: ['action.devices.traits.Volume'],
attributes: {
volumeMaxLevel: 45,
volumeCanMuteAndUnmute: false,
Expand Down Expand Up @@ -166,14 +159,7 @@ describe('GoogleActions Handler - onSync - volume (tv)', () => {
{
id: 'device-1',
type: 'action.devices.types.TV',
traits: [
'action.devices.traits.Volume',
'action.devices.traits.AppSelector',
'action.devices.traits.InputSelector',
'action.devices.traits.MediaState',
'action.devices.traits.OnOff',
'action.devices.traits.TransportControl',
],
traits: ['action.devices.traits.Volume'],
attributes: {
volumeMaxLevel: 30,
volumeCanMuteAndUnmute: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ describe('GoogleActions Handler - onExecute', () => {
{
ids: ['device-1'],
status: 'ERROR',
errorCode: 'functionNotSupported',
},
],
},
Expand Down Expand Up @@ -255,7 +254,6 @@ describe('GoogleActions Handler - onExecute', () => {
{
ids: ['device-1'],
status: 'ERROR',
errorCode: 'functionNotSupported',
},
],
},
Expand Down

0 comments on commit b6d3f13

Please sign in to comment.