Skip to content

Commit 0ac3b69

Browse files
committed
fix(Thermostat): Add support for ECO mode; close #83
1 parent 656c353 commit 0ac3b69

File tree

3 files changed

+159
-72
lines changed

3 files changed

+159
-72
lines changed

device-types.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,11 @@ const temperatureScale = (val) => {
353353

354354
const thermostatMode = (val) => {
355355
const isValid =
356-
val === 'AUTO' || val === 'HEAT' || val === 'COOL' || val === 'OFF'
356+
val === 'AUTO' ||
357+
val === 'HEAT' ||
358+
val === 'COOL' ||
359+
val === 'ECO' ||
360+
val === 'OFF'
357361
if (!isValid) {
358362
return false
359363
}

directives.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ const directives = {
160160
}
161161
if (
162162
request.directive.payload.thermostatMode.value === 'COOL' ||
163-
request.directive.payload.thermostatMode.value === 'HEAT'
163+
request.directive.payload.thermostatMode.value === 'HEAT' ||
164+
request.directive.payload.thermostatMode.value === 'ECO'
164165
) {
165166
newState['powerState'] = 'ON'
166167
} else if (request.directive.payload.thermostatMode.value === 'OFF') {

examples/thermostat.json

Lines changed: 152 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,47 @@
11
[
22
{
3-
"id": "f8d7ccba.de9cf",
3+
"id": "ec192310.979d5",
44
"type": "vsh-virtual-device",
55
"z": "7ecdfb0b.fa7794",
66
"name": "bedroom",
77
"topic": "bedroom/thermostat",
8-
"connection": "c653a955.290d98",
8+
"connection": "",
99
"template": "THERMOSTAT",
1010
"passthrough": true,
1111
"diff": false,
1212
"filter": false,
13-
"x": 940,
14-
"y": 1400,
15-
"wires": [["185af96.c50b507"]]
13+
"x": 1340,
14+
"y": 1440,
15+
"wires": [["90b1f25d.d713"]]
1616
},
1717
{
18-
"id": "6ae812d4.64f2ac",
18+
"id": "521b6c26.571e64",
1919
"type": "inject",
2020
"z": "7ecdfb0b.fa7794",
2121
"name": "current temp = 19.7 °C",
2222
"props": [
23-
{ "p": "payload.temperature", "v": "19.7", "vt": "num" },
24-
{ "p": "payload.scale", "v": "CELSIUS", "vt": "str" }
23+
{
24+
"p": "payload.temperature",
25+
"v": "19.7",
26+
"vt": "num"
27+
},
28+
{
29+
"p": "payload.scale",
30+
"v": "CELSIUS",
31+
"vt": "str"
32+
}
2533
],
2634
"repeat": "",
2735
"crontab": "",
2836
"once": false,
2937
"onceDelay": 0.1,
3038
"topic": "",
31-
"x": 700,
32-
"y": 1400,
33-
"wires": [["f8d7ccba.de9cf"]]
39+
"x": 1100,
40+
"y": 1440,
41+
"wires": [["ec192310.979d5"]]
3442
},
3543
{
36-
"id": "185af96.c50b507",
44+
"id": "90b1f25d.d713",
3745
"type": "debug",
3846
"z": "7ecdfb0b.fa7794",
3947
"name": "",
@@ -44,167 +52,241 @@
4452
"complete": "false",
4553
"statusVal": "",
4654
"statusType": "auto",
47-
"x": 1230,
48-
"y": 1400,
55+
"x": 1630,
56+
"y": 1440,
4957
"wires": []
5058
},
5159
{
52-
"id": "366a3ec7.f45d32",
60+
"id": "1b9ebdb3.4ce6b2",
5361
"type": "inject",
5462
"z": "7ecdfb0b.fa7794",
5563
"name": "current temp = 22 °C",
5664
"props": [
57-
{ "p": "payload.temperature", "v": "22", "vt": "num" },
58-
{ "p": "payload.scale", "v": "CELSIUS", "vt": "str" }
65+
{
66+
"p": "payload.temperature",
67+
"v": "22",
68+
"vt": "num"
69+
},
70+
{
71+
"p": "payload.scale",
72+
"v": "CELSIUS",
73+
"vt": "str"
74+
}
5975
],
6076
"repeat": "",
6177
"crontab": "",
6278
"once": false,
6379
"onceDelay": 0.1,
6480
"topic": "",
65-
"x": 700,
66-
"y": 1440,
67-
"wires": [["f8d7ccba.de9cf"]]
81+
"x": 1100,
82+
"y": 1480,
83+
"wires": [["ec192310.979d5"]]
6884
},
6985
{
70-
"id": "34e9d23d.def9ce",
86+
"id": "c19e6295.a1337",
7187
"type": "inject",
7288
"z": "7ecdfb0b.fa7794",
7389
"name": "target temp = 20 °C",
7490
"props": [
75-
{ "p": "payload.targetTemperature", "v": "20", "vt": "num" },
76-
{ "p": "payload.targetScale", "v": "CELSIUS", "vt": "str" }
91+
{
92+
"p": "payload.targetTemperature",
93+
"v": "20",
94+
"vt": "num"
95+
},
96+
{
97+
"p": "payload.targetScale",
98+
"v": "CELSIUS",
99+
"vt": "str"
100+
}
77101
],
78102
"repeat": "",
79103
"crontab": "",
80104
"once": false,
81105
"onceDelay": 0.1,
82106
"topic": "",
83-
"x": 690,
84-
"y": 1520,
85-
"wires": [["f8d7ccba.de9cf"]]
107+
"x": 1090,
108+
"y": 1560,
109+
"wires": [["ec192310.979d5"]]
86110
},
87111
{
88-
"id": "202115cf.212b8a",
112+
"id": "362951d9.1d9e3e",
89113
"type": "inject",
90114
"z": "7ecdfb0b.fa7794",
91115
"name": "target temp = 22.5 °C",
92116
"props": [
93-
{ "p": "payload.targetTemperature", "v": "22.5", "vt": "num" },
94-
{ "p": "payload.targetScale", "v": "CELSIUS", "vt": "str" }
117+
{
118+
"p": "payload.targetTemperature",
119+
"v": "22.5",
120+
"vt": "num"
121+
},
122+
{
123+
"p": "payload.targetScale",
124+
"v": "CELSIUS",
125+
"vt": "str"
126+
}
95127
],
96128
"repeat": "",
97129
"crontab": "",
98130
"once": false,
99131
"onceDelay": 0.1,
100132
"topic": "",
101-
"x": 700,
102-
"y": 1560,
103-
"wires": [["f8d7ccba.de9cf"]]
133+
"x": 1100,
134+
"y": 1600,
135+
"wires": [["ec192310.979d5"]]
104136
},
105137
{
106-
"id": "3871c53e.5e060a",
138+
"id": "56680f44.6827a",
107139
"type": "comment",
108140
"z": "7ecdfb0b.fa7794",
109141
"name": "THERMOSTAT",
110142
"info": "",
111-
"x": 680,
112-
"y": 1160,
143+
"x": 1080,
144+
"y": 1200,
113145
"wires": []
114146
},
115147
{
116-
"id": "94404dca.ad50b",
148+
"id": "10fa60e2.65222f",
117149
"type": "comment",
118150
"z": "7ecdfb0b.fa7794",
119151
"name": "Alexa, make it warmer in here.",
120152
"info": "",
121-
"x": 760,
122-
"y": 1240,
153+
"x": 1160,
154+
"y": 1280,
123155
"wires": []
124156
},
125157
{
126-
"id": "cb3a71d8.b0511",
158+
"id": "ee97291.e7937d8",
127159
"type": "comment",
128160
"z": "7ecdfb0b.fa7794",
129161
"name": "Alexa, make it cooler in here.",
130162
"info": "",
131-
"x": 760,
132-
"y": 1280,
163+
"x": 1160,
164+
"y": 1320,
133165
"wires": []
134166
},
135167
{
136-
"id": "305cc496.f4bdbc",
168+
"id": "e41e1df4.35e2f",
137169
"type": "comment",
138170
"z": "7ecdfb0b.fa7794",
139171
"name": "Alexa, set bedroom thermostat to twenty.",
140172
"info": "",
141-
"x": 800,
142-
"y": 1200,
173+
"x": 1200,
174+
"y": 1240,
143175
"wires": []
144176
},
145177
{
146-
"id": "f742ce9a.db0b6",
178+
"id": "921caef2.454cf",
147179
"type": "comment",
148180
"z": "7ecdfb0b.fa7794",
149181
"name": "Alexa, what's the temperature of bedroom thermostat?",
150182
"info": "",
151-
"x": 840,
152-
"y": 1320,
183+
"x": 1240,
184+
"y": 1360,
153185
"wires": []
154186
},
155187
{
156-
"id": "7b1a6735.ced7a8",
188+
"id": "a4dd21a6.1a75e",
157189
"type": "inject",
158190
"z": "7ecdfb0b.fa7794",
159191
"name": "mode = AUTO",
160-
"props": [{ "p": "payload.thermostatMode", "v": "AUTO", "vt": "str" }],
192+
"props": [
193+
{
194+
"p": "payload.thermostatMode",
195+
"v": "AUTO",
196+
"vt": "str"
197+
}
198+
],
161199
"repeat": "",
162200
"crontab": "",
163201
"once": false,
164202
"onceDelay": 0.1,
165203
"topic": "",
166-
"x": 670,
167-
"y": 1640,
168-
"wires": [["f8d7ccba.de9cf"]]
204+
"x": 1070,
205+
"y": 1680,
206+
"wires": [["ec192310.979d5"]]
169207
},
170208
{
171-
"id": "5e3718a.25277e8",
209+
"id": "39ff2a1f.437cd6",
172210
"type": "inject",
173211
"z": "7ecdfb0b.fa7794",
174212
"name": "mode = HEAT",
175-
"props": [{ "p": "payload.thermostatMode", "v": "HEAT", "vt": "str" }],
213+
"props": [
214+
{
215+
"p": "payload.thermostatMode",
216+
"v": "HEAT",
217+
"vt": "str"
218+
}
219+
],
176220
"repeat": "",
177221
"crontab": "",
178222
"once": false,
179223
"onceDelay": 0.1,
180224
"topic": "",
181-
"x": 670,
182-
"y": 1680,
183-
"wires": [["f8d7ccba.de9cf"]]
225+
"x": 1070,
226+
"y": 1720,
227+
"wires": [["ec192310.979d5"]]
184228
},
185229
{
186-
"id": "1072ec7.feef314",
230+
"id": "fe487ec6.d62f4",
187231
"type": "inject",
188232
"z": "7ecdfb0b.fa7794",
189233
"name": "mode = COOL",
190-
"props": [{ "p": "payload.thermostatMode", "v": "COOL", "vt": "str" }],
234+
"props": [
235+
{
236+
"p": "payload.thermostatMode",
237+
"v": "COOL",
238+
"vt": "str"
239+
}
240+
],
191241
"repeat": "",
192242
"crontab": "",
193243
"once": false,
194244
"onceDelay": 0.1,
195245
"topic": "",
196-
"x": 680,
197-
"y": 1720,
198-
"wires": [["f8d7ccba.de9cf"]]
246+
"x": 1080,
247+
"y": 1760,
248+
"wires": [["ec192310.979d5"]]
249+
},
250+
{
251+
"id": "d14af22e.2a3f3",
252+
"type": "inject",
253+
"z": "7ecdfb0b.fa7794",
254+
"name": "mode = ECO",
255+
"props": [
256+
{
257+
"p": "payload.thermostatMode",
258+
"v": "ECO",
259+
"vt": "str"
260+
}
261+
],
262+
"repeat": "",
263+
"crontab": "",
264+
"once": false,
265+
"onceDelay": 0.1,
266+
"topic": "",
267+
"x": 1070,
268+
"y": 1800,
269+
"wires": [["ec192310.979d5"]]
199270
},
200271
{
201-
"id": "c653a955.290d98",
202-
"type": "vsh-connection",
203-
"name": "SANDBOX: cornelius.suermann@gmail.com",
204-
"port": "8883",
205-
"accessTokenExpiry": "1623058880575",
206-
"debug": true,
207-
"backendUrl": "https://hbsky6oavf.execute-api.eu-west-1.amazonaws.com/dev",
208-
"lwaClientId": "amzn1.application-oa2-client.cc2605d7d7d64fb28b90e75f64622bfa"
272+
"id": "5cc18f22.5aad3",
273+
"type": "inject",
274+
"z": "7ecdfb0b.fa7794",
275+
"name": "mode = OFF",
276+
"props": [
277+
{
278+
"p": "payload.thermostatMode",
279+
"v": "OFF",
280+
"vt": "str"
281+
}
282+
],
283+
"repeat": "",
284+
"crontab": "",
285+
"once": false,
286+
"onceDelay": 0.1,
287+
"topic": "",
288+
"x": 1070,
289+
"y": 1840,
290+
"wires": [["ec192310.979d5"]]
209291
}
210292
]

0 commit comments

Comments
 (0)