Skip to content

Commit

Permalink
Add room to device msg (#43)
Browse files Browse the repository at this point in the history
* #43 Add room to device msg

Signed-off-by: hxmelab <hxmelab@gmail.com>

* #43 Merge master

Signed-off-by: hxmelab <hxmelab@gmail.com>
  • Loading branch information
hxmelab committed Mar 8, 2021
1 parent c0f617c commit 7f06731
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions nodes/shc-device.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
'IntrusionDetectionControl,Keypad,LatestMotion,' +
'PowerMeter,PowerSwitch,PresenceSimulationConfiguration,' +
'PrivacyMode,RoomClimateControl,ShutterContact, ' +
'ShutterControl, SmokeDetectorCheck,TemperatureLevel,ValveTappet,' +
'ShutterControl,SmokeDetectorCheck,TemperatureLevel,ValveTappet,' +
'MultiLevelSwitch,HSBColorActuator,HueColorTemperature,HueBlinkingActuator,' +
'BinarySwitch';

Expand All @@ -54,7 +54,7 @@
const shcConfig = RED.nodes.node($('#node-input-shc').val());
const selectDevice = $('#node-input-device');

function format(device) {
function format(device, roomName) {
let services = '';

try {
Expand All @@ -69,7 +69,7 @@
}

return $('<option/>')
.val(device.name + '|' + device.id + '|' + device.deviceModel + '|' + services)
.val(device.name + '|' + device.id + '|' + device.deviceModel + '|' + services + '|' + roomName)
.text(device.name);
}

Expand Down Expand Up @@ -112,7 +112,7 @@
const optGroup = $('<optgroup label="Devices"></optgroup>');
selectDevice.append(optGroup);
optGroup.append($('<option/>')
.val('all|all|all|' + supportedServices)
.val('all|all|all|' + supportedServices + '|')
.text('All Devices'));

// Service in this context means e.g. alarm system, presence simulation,
Expand All @@ -134,7 +134,7 @@
const roomGroup = $('<optgroup label="' + roomName + '"></optgroup>');
selectDevice.append(roomGroup);
deviceList.reduce((parent, device) => {
parent.append(format(device));
parent.append(format(device, roomName));
return parent;
}, roomGroup);
}, this);
Expand Down
3 changes: 2 additions & 1 deletion nodes/shc-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = function (RED) {
this.deviceName = config.device.split('|')[0];
this.deviceId = config.device.split('|')[1];
this.deviceModel = config.device.split('|')[2];
this.roomName = config.device.split('|')[4];
this.serviceId = config.service;
this.state = config.state;
this.poll = config.poll;
Expand Down Expand Up @@ -100,7 +101,7 @@ module.exports = function (RED) {
}

setMsgObject(data) {
const msg = {topic: (this.name || this.deviceName)};
const msg = {topic: (this.name || this.deviceName), room: this.roomName};
if (this.serviceId && this.state) {
if (data.state && Object.prototype.hasOwnProperty.call(data.state, this.state)) {
msg.payload = this.convertState(data.state[this.state]);
Expand Down
5 changes: 2 additions & 3 deletions 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": "node-red-contrib-bosch-shc",
"version": "0.3.25",
"version": "0.3.26",
"description": "Bosch Smart Home Controller (SHC) nodes for Node-Red",
"repository": "https://github.com/hxmelab/node-red-contrib-bosch-shc",
"main": "none",
Expand Down

0 comments on commit 7f06731

Please sign in to comment.