mirror of
https://github.com/lasthead0/yandex2mqtt.git
synced 2025-08-08 01:00:31 +03:00
test
This commit is contained in:
@@ -34,13 +34,15 @@ class Device {
|
|||||||
room: options.room || '',
|
room: options.room || '',
|
||||||
type: options.type || 'devices.types.light',
|
type: options.type || 'devices.types.light',
|
||||||
custom_data: {
|
custom_data: {
|
||||||
allowedUsers: options.allowedUsers || [1],
|
|
||||||
mqtt: options.mqtt || [],
|
mqtt: options.mqtt || [],
|
||||||
valueMapping: options.valueMapping || [],
|
valueMapping: options.valueMapping || [],
|
||||||
},
|
},
|
||||||
capabilities: (options.capabilities || []).map(c => Object.assign({}, c, {state: (c.state == undefined) ? this.initState(c) : c.state})),
|
capabilities: (options.capabilities || []).map(c => Object.assign({}, c, {state: (c.state == undefined) ? this.initState(c) : c.state})),
|
||||||
properties: (options.properties || []).map(p => Object.assign({}, p, {state: (p.state == undefined) ? this.initState(p) : p.state}))
|
properties: (options.properties || []).map(p => Object.assign({}, p, {state: (p.state == undefined) ? this.initState(p) : p.state})),
|
||||||
}
|
};
|
||||||
|
this.meta = {
|
||||||
|
allowedUsers: options.allowedUsers || [1],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create init state (for capabilities and properties) on device object create */
|
/* Create init state (for capabilities and properties) on device object create */
|
||||||
|
@@ -35,8 +35,7 @@ module.exports.devices = [
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (const d of global.devices) {
|
for (const d of global.devices) {
|
||||||
console.log(d);
|
const {allowedUsers} = d.meta;
|
||||||
const {allowedUsers} = d.custom_data;
|
|
||||||
if (Array.isArray(allowedUsers) && allowedUsers.indexOf(userId)) {
|
if (Array.isArray(allowedUsers) && allowedUsers.indexOf(userId)) {
|
||||||
console.log(d.getInfo());
|
console.log(d.getInfo());
|
||||||
r.payload.devices.push(d.getInfo());
|
r.payload.devices.push(d.getInfo());
|
||||||
|
Reference in New Issue
Block a user