Skip to content

Commit

Permalink
Merge branch 'master' into z2m-fix-join
Browse files Browse the repository at this point in the history
  • Loading branch information
VonOx authored May 23, 2022
2 parents d6afbd2 + ba97d1a commit 4bb9eb7
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 4 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v4.8.9](https://github.com/GladysAssistant/Gladys/compare/v4.8.8...v4.8.9)

> 20 May 2022
- Alexa: Fix execute on multiple device feature + reject when device is not found [`#1536`](https://github.com/GladysAssistant/Gladys/pull/1536)

#### [v4.8.8](https://github.com/GladysAssistant/Gladys/compare/v4.8.7...v4.8.8)

> 20 May 2022
- docs: add rpochet as a contributor for code [`#1535`](https://github.com/GladysAssistant/Gladys/pull/1535)
- Fix API documentation of Telegram integration [`#1524`](https://github.com/GladysAssistant/Gladys/pull/1524)
- Fix #1476 : Fix line break in chat message [`#1533`](https://github.com/GladysAssistant/Gladys/pull/1533)
- Bluetooth: Add missing await in start function [`#1529`](https://github.com/GladysAssistant/Gladys/pull/1529)
- Add Alexa integration with Gladys Plus [`#1396`](https://github.com/GladysAssistant/Gladys/pull/1396)
- Display 2FA secret in Gladys Plus configure 2FA screen [`#1521`](https://github.com/GladysAssistant/Gladys/pull/1521)
- Upgrade ESLint configuration + preact-cli + preact [`#1520`](https://github.com/GladysAssistant/Gladys/pull/1520)
- Fix #1476 : Fix line break in chat message (#1533) [`#1476`](https://github.com/GladysAssistant/Gladys/issues/1476)
- Update CHANGELOG [`2588389`](https://github.com/GladysAssistant/Gladys/commit/2588389495bb93ec4b04cd371f36b29587ec340f)

#### [v4.8.7](https://github.com/GladysAssistant/Gladys/compare/v4.8.6...v4.8.7)

> 16 May 2022
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": "gladys",
"version": "4.8.8",
"version": "4.8.9",
"description": "A privacy-first, open-source home assistant",
"main": "index.js",
"engines": {
Expand Down
12 changes: 10 additions & 2 deletions server/services/alexa/lib/alexa.onExecute.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
const uuid = require('uuid');
const get = require('get-value');
const { EVENTS, ACTIONS, ACTIONS_STATUS, DEVICE_FEATURE_CATEGORIES } = require('../../../utils/constants');
const {
EVENTS,
ACTIONS,
ACTIONS_STATUS,
DEVICE_FEATURE_CATEGORIES,
DEVICE_FEATURE_TYPES,
} = require('../../../utils/constants');
const { BadParameters, NotFoundError } = require('../../../utils/coreErrors');
const { writeValues, readValues } = require('./deviceMappings');

Expand All @@ -25,7 +31,9 @@ function onExecute(body) {
switch (directiveNamespace) {
case 'Alexa.PowerController':
deviceFeature = deviceInMemory.features.find(
(f) => f.category === DEVICE_FEATURE_CATEGORIES.SWITCH || f.category === DEVICE_FEATURE_CATEGORIES.LIGHT,
(f) =>
(f.category === DEVICE_FEATURE_CATEGORIES.SWITCH || f.category === DEVICE_FEATURE_CATEGORIES.LIGHT) &&
f.type === DEVICE_FEATURE_TYPES.LIGHT.BINARY,
);
value = writeValues['Alexa.PowerController'](directiveName);
break;
Expand Down
4 changes: 4 additions & 0 deletions server/services/alexa/lib/alexa.onReportState.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const uuid = require('uuid');
const get = require('get-value');

const { mappings, readValues } = require('./deviceMappings');
const { NotFoundError } = require('../../../utils/coreErrors');

/**
* @public
Expand All @@ -13,6 +14,9 @@ const { mappings, readValues } = require('./deviceMappings');
function onReportState(body) {
const deviceSelector = get(body, 'directive.endpoint.endpointId');
const device = this.gladys.stateManager.get('device', deviceSelector);
if (!device) {
throw new NotFoundError(`Device "${deviceSelector}" not found`);
}
const properties = [];
const now = new Date().toISOString();
device.features.forEach((feature) => {
Expand Down
4 changes: 4 additions & 0 deletions server/test/services/alexa/lib/alexa.onExecute.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const DEVICE_1_LIGHT = {
selector: 'device-1',
external_id: 'device-1-external-id',
features: [
{
category: 'light',
type: 'brightness',
},
{
category: 'light',
type: 'binary',
Expand Down
27 changes: 27 additions & 0 deletions server/test/services/alexa/lib/alexa.onReportState.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,31 @@ describe('alexa.onReportState', () => {
},
});
});
it('Should return device not found', async () => {
const gladys = {
stateManager: {
get: fake.returns(null),
},
};

const alexaHandler = new AlexaHandler(gladys, serviceId);
const body = {
directive: {
header: {
namespace: 'Alexa',
name: 'ReportState',
payloadVersion: '3',
messageId: 'a05c8249-1cdd-41dd-bc1d-5a14ab4b98eb',
correlationToken:
'AAAAAAAAAQBe8ATzt+PzWVqbUXXQAv6JAAIAAAAAAADgCDHXLLn3nx8SmjtElD2w8CfsniSH6KxFhbRSgD/sELuMpZTr4Jl/E3Nip62gpI2QqFNm/TrQ/Pi+XSFtf/4AVCDxe4bV2FAXSVu61AsuUlhbdqdvjUoaHOuqSLW8F3Qj9z3HWhfvTCMEbbhw4XVDWOsyXb9nknvswimA+R4ftNdBx5POWZGxWtbvU+yeBStTV+QwSSZaHWjzQdi/LAo1KW35MkmLikny7Y7J097LTTL1Tof6IkLsi9/gxOtUUFvnD4yIkWeHTT110Ch6R4kDuonNtOiHsTmMMRtsY5kRWoIL9VMfX6QHWjamhvd+XJp4sXkLMBdtJ3aTzfsUNrQIdrcPTox9qTNjShunTlbAYkq1TSUXaylEGHvcwHrbo7ZoUlBvidqnJGUNRJPxOHHyfCm5VqFzuFI8AG1W/dj1W4Di0AAND/mwzjZKUTRsiX4uEaRw8/Na4Qj/GBMuT18hUoGpe7t/UYw5JFw+MXm0kn/5jKe9r62xil3TN8BK9ODQDP9zq08+iiT0CBtEX5F4Drrowb57IwcW7nt/hkCeeyR59B/Z6nPsSq0NQ+rd1w4a1iHIyaTU6acQsKwmaX1OeTvtT2p7U/HhqfhVMSqA7ybGhQDF4FPPzIbh+o+D1S+AX9m9nVSSJNwoevikdZimCbk1l1HmUrhz78GO+j0yFg==',
},
endpoint: { endpointId: 'device-1' },
payload: {},
},
user: { id: 'cbd42dc1-1b15-4c59-bea6-7e01968a9603', local_user_id: '275faa00-8a9c-4747-8fbe-417ddb966b16' },
};
expect(() => {
alexaHandler.onReportState(body);
}).to.throw('Device "device-1" not found');
});
});

0 comments on commit 4bb9eb7

Please sign in to comment.