Skip to content

Commit

Permalink
get virtualdevice groups from /etc/config/groups.gson
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed Jan 4, 2019
1 parent 6f867f2 commit beab10d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions nodes/ccu-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ module.exports = function (RED) {
this.channelRooms = {};
this.channelFunctions = {};

this.groups = {};

this.sysvar = {};
this.program = {};
this.setVariableQueue = {};
Expand Down Expand Up @@ -505,11 +507,34 @@ module.exports = function (RED) {
}
}

getGroupsData() {
return new Promise(resolve => {
this.logger.debug('virtualdevices get groups');
this.rega.exec(`
var stdoutGroups;
var stderrGroups;
system.Exec("cat /etc/config/groups.gson", &stdoutGroups, &stderrGroups);
`, (err, stdout, objects) => {
if (!err && objects && objects.stderrGroups === 'null') {
try {
const {groups} = JSON.parse(objects.stdoutGroups);
groups.forEach(group => {
this.groups[group.id] = group;
});

} catch (error) {}
}
resolve();
});
});
}

getRegaData() {
return this.getRegaChannels()
.then(() => this.getRegaRooms())
.then(() => this.getRegaFunctions())
.then(() => this.getRegaValues())
.then(() => this.getGroupsData())
.catch(this.logger.error);
}

Expand Down

0 comments on commit beab10d

Please sign in to comment.