Skip to content

Commit

Permalink
Fix MQTT root issue in controller node
Browse files Browse the repository at this point in the history
Fixes second issue in #15
  • Loading branch information
Thomas Mørch committed Jun 21, 2018
1 parent 687186f commit 987dff7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": {
"name": "Thomas Bowman Mørch"
},
"version": "3.1.1",
"version": "3.1.2",
"scripts": {
"build": "mkdir -p dist/nodes/ && cp -a src/nodes/*.html dist/nodes/ && cp -R src/migrations dist && tsc ",
"pretest": "tsc",
Expand Down
2 changes: 2 additions & 0 deletions src/lib/mysensors-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class MysensorsController {
private timeResponse: boolean,
private timeZone: string,
private measurementSystem: string,
private mqttRoot: string,
) { }

public async messageHandler(msg: IMysensorsMsg): Promise<IMysensorsMsg | undefined> {
Expand Down Expand Up @@ -97,6 +98,7 @@ export class MysensorsController {
private encode(msg: IMysensorsMsg| undefined) {
let encoder: IDecoder| undefined;
if (NullCheck.isDefinedOrNonNull(msg)) {
msg.topicRoot = this.mqttRoot;
if (msg.origin === MsgOrigin.serial) {
encoder = new MysensorsSerial();
} else if (msg.origin === MsgOrigin.mqtt) {
Expand Down
1 change: 1 addition & 0 deletions src/nodes/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface IControllerProperties extends NodeProperties {
timeresponse?: boolean;
timezone?: string;
measurementsystem?: string;
mqttroot?: string;
}

export interface IControllerConfig extends Node {
Expand Down
7 changes: 6 additions & 1 deletion src/nodes/controller.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
handleid: {value: true},
timeresponse: {value: true},
timezone: {value: 'UTC'},
measurementsystem: {value: 'M'}
measurementsystem: {value: 'M'},
mqttroot: {value: 'mys-out'}
},
inputs:1,
outputs:1,
Expand Down Expand Up @@ -51,6 +52,10 @@
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-mqttroot"><i class="icon-tag"></i> MQTT root</label>
<input type="text" id="node-input-mqttroot" placeholder="mys-out">
</div>
<div class="form-row">
<label for="node-input-database"><i class="icon-tag"></i> Database</label>
<input type="text" id="node-input-database" placeholder="Database">
Expand Down
1 change: 1 addition & 0 deletions src/nodes/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export = (RED: Red) => {
props.timeresponse || true,
props.timezone || 'UTC',
props.measurementsystem || 'M',
props.mqttroot || 'mys-out',
);
this.on('input', (msg: IMysensorsMsg) => {
(this.controller).messageHandler(msg).then((msgOut: IMysensorsMsg| undefined) => {
Expand Down

0 comments on commit 987dff7

Please sign in to comment.