Skip to content

Commit acd83ce

Browse files
committed
Merge remote-tracking branch 'original/master' into bewee/patch-4
2 parents 577e96d + 0589d36 commit acd83ce

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

manifest.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
"options": {
1818
"default": {
1919
"persistPropertyValues": false,
20-
"randomizePropertyValues": false
20+
"randomizePropertyValues": false,
21+
"excludeDefaultThings": false
2122
},
2223
"schema": {
2324
"type": "object",
2425
"required": [
2526
"persistPropertyValues",
26-
"randomizePropertyValues"
27+
"randomizePropertyValues",
28+
"excludeDefaultThings"
2729
],
2830
"properties": {
2931
"persistPropertyValues": {
@@ -34,6 +36,10 @@
3436
"description": "Whether or not to periodically generate new property values",
3537
"type": "boolean"
3638
},
39+
"excludeDefaultThings": {
40+
"description": "Whether or not to exclude the default virtual things",
41+
"type": "boolean"
42+
},
3743
"customThings": {
3844
"description": "Custom virtual things to create",
3945
"type": "array",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"devDependencies": {
2525
"babel-eslint": "^10.1.0",
26-
"eslint": "^7.14.0"
26+
"eslint": "^7.25.0"
2727
},
2828
"files": [
2929
"LICENSE",

virtual-things-adapter.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,10 +1515,12 @@ class VirtualThingsAdapter extends Adapter {
15151515
}
15161516

15171517
addAllThings() {
1518-
for (let i = 0; i < VIRTUAL_THINGS.length; i++) {
1519-
const id = `virtual-things-${i}`;
1520-
if (!this.devices[id]) {
1521-
new VirtualThingsDevice(this, id, VIRTUAL_THINGS[i]);
1518+
if (!this.config.excludeDefaultThings) {
1519+
for (let i = 0; i < VIRTUAL_THINGS.length; i++) {
1520+
const id = `virtual-things-${i}`;
1521+
if (!this.devices[id]) {
1522+
new VirtualThingsDevice(this, id, VIRTUAL_THINGS[i]);
1523+
}
15221524
}
15231525
}
15241526

@@ -1533,8 +1535,10 @@ class VirtualThingsAdapter extends Adapter {
15331535
continue;
15341536
}
15351537

1536-
descr.properties = descr.properties || [];
1537-
for (const property of descr.properties) {
1538+
const properties = (descr.properties || []).map((property) => {
1539+
return Object.assign({}, property);
1540+
});
1541+
for (const property of properties) {
15381542
// Clean up properties
15391543
if (!['number', 'integer'].includes(property.type)) {
15401544
delete property.unit;
@@ -1576,7 +1580,7 @@ class VirtualThingsAdapter extends Adapter {
15761580
break;
15771581
case 'string':
15781582
// just in case
1579-
property.default = `${property.default}`;
1583+
property.default = `${property.default || ''}`;
15801584
break;
15811585
}
15821586
}
@@ -1602,7 +1606,7 @@ class VirtualThingsAdapter extends Adapter {
16021606
events: [],
16031607
};
16041608

1605-
for (const property of descr.properties) {
1609+
for (const property of properties) {
16061610
const prop = {
16071611
name: property.name,
16081612
value: property.default,

0 commit comments

Comments
 (0)