Skip to content

Commit 27dc65b

Browse files
committed
Added output and fixed position parameter
1 parent 77180b4 commit 27dc65b

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

tahoma.js

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ module.exports = function(RED) {
4141
break;
4242
case "customPosition":
4343
commandName = "setClosure";
44-
parameters = [String(msg.payload.position)];
44+
parameters = [msg.payload.position];
4545
statusProgressText = "Going to "+ msg.payload.position +"%...";
4646
statusDoneText = "Set to "+ msg.payload.position +"%";
4747
expectedState = {open: true, position: msg.payload.position};
4848
}
4949

50+
51+
5052
var command = {};
5153
command.name = commandName;
5254
if(parameters.length > 0) {
@@ -79,7 +81,19 @@ module.exports = function(RED) {
7981

8082
tahomalink.continueWhenFinished(node.device, expectedState)
8183
.then(function() {
82-
node.status({fill: 'green', shape: 'dot', text: statusDoneText});
84+
node.status({
85+
fill: 'green',
86+
shape: 'dot',
87+
text: statusDoneText
88+
});
89+
90+
if(!('payload' in msg)) {
91+
msg.payload = {};
92+
}
93+
94+
// TODO: Find a better way to handle "my" position.
95+
msg.payload.output = expectedState ? expectedState : {open: true};
96+
8397
node.send(msg);
8498
});
8599
});
@@ -111,21 +125,4 @@ module.exports = function(RED) {
111125
});
112126
return;
113127
});
114-
115-
RED.httpAdmin.get('/tahomasomfy/updateState/:node', function(req, res, next){
116-
var configNode = RED.nodes.getNode(req.params.boxid);
117-
118-
tahomalink.login(configNode.username, configNode.password)
119-
.then(function() {
120-
tahomalink.getDeviceState(req.params.deviceid)
121-
.then(function(body) {
122-
if(typeof body === "string") {
123-
body = JSON.parse(body);
124-
}
125-
126-
res.json(body);
127-
});
128-
});
129-
return;
130-
});
131128
};

0 commit comments

Comments
 (0)