@@ -41,12 +41,14 @@ module.exports = function(RED) {
41
41
break ;
42
42
case "customPosition" :
43
43
commandName = "setClosure" ;
44
- parameters = [ String ( msg . payload . position ) ] ;
44
+ parameters = [ msg . payload . position ] ;
45
45
statusProgressText = "Going to " + msg . payload . position + "%..." ;
46
46
statusDoneText = "Set to " + msg . payload . position + "%" ;
47
47
expectedState = { open : true , position : msg . payload . position } ;
48
48
}
49
49
50
+
51
+
50
52
var command = { } ;
51
53
command . name = commandName ;
52
54
if ( parameters . length > 0 ) {
@@ -79,7 +81,19 @@ module.exports = function(RED) {
79
81
80
82
tahomalink . continueWhenFinished ( node . device , expectedState )
81
83
. 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
+
83
97
node . send ( msg ) ;
84
98
} ) ;
85
99
} ) ;
@@ -111,21 +125,4 @@ module.exports = function(RED) {
111
125
} ) ;
112
126
return ;
113
127
} ) ;
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
- } ) ;
131
128
} ;
0 commit comments