forked from ElephantEight/GenGenSceneController
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathL_GenGenSceneController.lua
More file actions
executable file
·4711 lines (4492 loc) · 194 KB
/
L_GenGenSceneController.lua
File metadata and controls
executable file
·4711 lines (4492 loc) · 194 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- GenGeneric Scene Controller Version 1.23d
-- Supports Evolve LCD1, Cooper RFWC5 and Nexia One Touch Controllers
--
-- Copyright (C) 2017, 2018 Gustavo A Fernandez
-- Thanks to Ron Luna and Ctrlable for contributing for RFWC5 support
--
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License
-- as published by the Free Software Foundation; either version 2
-- of the License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You can access the terms of this license at
-- https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
-- Supports Evolve LCD1, Cooper RFWC5 and Nexia One Touch Controller
-- VerboseLogging == 0: important logs and errors: ELog, log
-- VerboseLogging == 1: Includes information logs: ELog, ILog, log
-- VerboseLogging == 2: Includes debug logs: ELog, ILog, log, DLog, DEntry
-- VerboseLogging == 4: Includes verbose logs: ELog, ILog, log, DLog, DEntry, VLog, VEntry
VerboseLogging = 4
posix = require "posix"
socket = require "socket"
zwint = require "zwint"
require "L_GenGenSceneControllerShared"
DEVTYPE_EVOLVELCD1 = "urn:schemas-gengen_mcv-org:device:SceneControllerEvolveLCD:1"
DEVTYPE_COOPEREFWC5 = "urn:schemas-gengen_mcv-org:device:SceneControllerCooperRFWC5:1"
DEVTYPE_NEXIAONETOUCH = "urn:schemas-gengen_mcv-org:device:SceneControllerNexiaOneTouch:1"
--
-- Globals
--
-- IndicatorLocks is indexed by peer_dev_num
-- 0 (or nil) no lock
-- 1 Short term lock with timeout
-- 2 long term lock without timeout. Should be disabled if unexpected event occurred.
-- 3 Indicator change bypassed due to lock
local IndicatorLocks = {}
local ZWaveSceneIdCacheList = {}
local param = {}
local lastChangedModes = {}
local temperatureAutoChoices = {}
local wakeUpIntervals = {}
local SCObj
Devices = {
-- Evolve LCD1-specific
[DEVTYPE_EVOLVELCD1] = {
Name = "Evolve LCD1",
HasScreen = true,
MaxLabelSize = 16,
HasMultipleScreens = true,
SceneBases = {
C = 1, -- Custom screen scenes start at base 1
T = 31, -- Temperature screen scenes start at base C + 5 buttons * 6 custom screens
W = 61, -- Welcome screen scenes start at base T + 5 buttons * 6 temperature screens
P = 66 -- Preset screen scenes start at base W + 5 buttons * 1 welcome screen
-- 271-300 - Unused start at base P + 5 buttons * 41 preset screens
-- 301-330 - Lines 6-10 for Custom screens 1-6
-- 331-660 - Long press for above scenes (Central scene capable devices only)
-- 661-990 - Double Click for above scenes (Central scene V2 capable devices only)
-- 991-1000 - Unused
-- 1001-1030 - State 2 for multi-state custom screens. (1031-2000 - Unused)
-- ...
-- 8001-8030 - State 9 for multi-state custom screens. (8031 and above - Unused)
-- 9000, 9005, 9010, ... - Timeout scene for C1, C2, C3, etc.
},
HasPresetLanguages = true,
HasThremostatControl = true,
HasBattery = false,
NumButtons = 5,
LastFixedSceneId = 10,
MaxDirectAssociations = 30,
HasOffScenes = true,
HasIndicator = true,
HasButtonModes = true,
HasCooperConfiguration = false,
HasCentralScene = false,
DefaultScreen = "C1",
DefaultModeString = "M",
DevType = DEVTYPE_EVOLVELCD1,
DeviceXml = "D_EvolveLCD1.xml",
OldServiceId = "urn:gengen_mcv-org:serviceId:EvolveLCD1",
OldParamPrefix = "LCD",
ScreenList = {C=9,T=9,P=41},
NumTemperatureScreens = 3, -- Preset Pages 8, 16, and 40
-- The "Large" font is actually narrower than the small font and can thus fit more characters per line.
-- However two lines of the small font can fit in one line of the large font.
LargeFontWidths = {
3,5,7,9,9,15,11,4,6,7,8,9,4,6,4,8,
9,9,10,9,9,9,9,9,9,9,4,4,9,8,9,7,
11,9,9,9,9,8,8,10,10,6,6,9,9,11,10,11,
9,11,10,9,9,10,9,14,9,10,8,6,8,6,10,11,
6,8,8,8,8,8,6,8,8,4,5,8,4,12,8,8,
8,8,7,7,6,8,8,12,8,8,7,8,5,9,10,11},
SmallFontWidths = {
3,4,7,11,10,16,13,3,7,7,9,11,5,6,4,10,
10,9,10,10,11,10,10,10,10,10,5,6,11,11,11,9,
13,11,11,11,11,10,9,11,11,8,8,11,11,13,12,12,
10,12,12,10,10,11,11,16,11,11,10,7,9,6,10,11,
7,9,10,9,10,9,7,10,10,4,6,9,4,14,10,10,
10,10,8,8,7,10,9,14,9,9,8,10,6,10,12,13},
ScreenWidth = 65,
RightJustifyScreenWidth = 67,
SetTuningParameters = function(zwave_dev_num, peer_dev_num)
VEntry()
local versionString
local retry = 0
while retry < 10 do
versionString = luup.variable_get(SID_ZWDEVICE, "VersionInfo", zwave_dev_num)
if versionString == nil then
log("waiting for VersionInfo for device #", zwave_dev_num, ": ", luup.devices[zwave_dev_num].description)
luup.sleep(1000)
retry = retry + 1;
else
break
end
end
if not versionString then
versionString = "1,3,20,0,39";
log("Could not get versionInfo. Defaulting to ", versionString);
end
-- "VersionInfo" returns a string sunch as "1,3,20,0,37" which corresponds to firmware rev 0.37
local version = tonumber(versionString:match("%d+,%d+,%d+,%d+,(%d+)"))
if version == nil then
version = 39
end
if version >= 39 then
-- This works OK for firmware version 00.00.39
GetTuningParameter("BaseDelay" , 300 , zwave_dev_num)
GetTuningParameter("ClearDelay" , 700 , zwave_dev_num)
GetTuningParameter("ScrollDelay" , 1000 , zwave_dev_num)
GetTuningParameter("LineDelay" , 35 , zwave_dev_num)
GetTuningParameter("CharDelay" , 8 , zwave_dev_num)
GetTuningParameter("ResponseDelay" , 30 , zwave_dev_num)
GetTuningParameter("BackoffDelay" , 50 , zwave_dev_num)
GetTuningParameter("MaxParts" , 2 , zwave_dev_num)
GetTuningParameter("UseClearScreen" , 1 , zwave_dev_num)
GetTuningParameter("Retries" , 0 , zwave_dev_num)
elseif version >= 37 then
-- This works OK for firmware version 00.00.37
GetTuningParameter("BaseDelay" , 100 , zwave_dev_num)
GetTuningParameter("ClearDelay" , 700 , zwave_dev_num)
GetTuningParameter("ScrollDelay" , 1000 , zwave_dev_num)
GetTuningParameter("LineDelay" , 100 , zwave_dev_num)
GetTuningParameter("CharDelay" , 10 , zwave_dev_num)
GetTuningParameter("ResponseDelay" , 30 , zwave_dev_num)
GetTuningParameter("BackoffDelay" , 50 , zwave_dev_num)
GetTuningParameter("MaxParts" , 2 , zwave_dev_num)
GetTuningParameter("UseClearScreen" , 1 , zwave_dev_num)
GetTuningParameter("Retries" , 10 , zwave_dev_num)
else
-- From Sig's feedback on forum.micasaverde.com
-- for version 00.00.31
-- "I tried a bunch of different settings - none of them, including these, really resulted
-- in perfectly stable operation - the device still reboots almost every time I do a screen
-- change. But as I mentioned in my prior note, the controllers are now set to how I use
-- them, and I'm not re-drawing screens during normal operation, so they're working just fine."
GetTuningParameter("BaseDelay" , 3000, zwave_dev_num)
GetTuningParameter("ClearDelay" , 5 , zwave_dev_num)
GetTuningParameter("ScrollDelay" , 1000 , zwave_dev_num)
GetTuningParameter("LineDelay" , 5 , zwave_dev_num)
GetTuningParameter("CharDelay" , 5 , zwave_dev_num)
GetTuningParameter("ResponseDelay" , 30 , zwave_dev_num)
GetTuningParameter("BackoffDelay" , 50 , zwave_dev_num)
GetTuningParameter("MaxParts" , 1 , zwave_dev_num)
GetTuningParameter("UseClearScreen" , 0 , zwave_dev_num)
GetTuningParameter("Retries" , 10 , zwave_dev_num)
end
GetTuningParameter("SwitchScreenDelay" , 50 , zwave_dev_num)
GetTuningParameter("InitStaggerSeconds" , 15 , zwave_dev_num)
GetTuningParameter("MinReinitSeconds" , 60 * 60 * 24 , zwave_dev_num)
GetTuningParameter("ReturnRouteDelay" , 500 , zwave_dev_num)
GetTuningParameter("UseWithSlaveController" , 0 , zwave_dev_num)
GetTuningParameter("AssociationDelay" , 0 , zwave_dev_num)
GetTuningParameter("SceneControllerConfDelay", 375 , zwave_dev_num)
GetTuningParameter("UnassociateDelay" , 0 , zwave_dev_num)
GetTuningParameter("IndicatorDelay" , 200 , zwave_dev_num)
GetTuningParameter("CentralSceneTimeout" , 750 , zwave_dev_num)
end,
DoDeviceConfiguration = function(peer_dev_num, node_id, zwave_dev_num)
-- Enable fan mode control on button 3.
SetConfigurationOption("FanModeControl", peer_dev_num, node_id, 36, 1)
end,
SetDefaultLabels = function(peer_dev_num)
local labels = {"One", "Two", "Three", "Four", "Five",
"Six", "Seven", "Eight", "Nine", "Ten",
"Eleven", "Twelve", "Thir-teen", "Four-teen", "Fifteen",
"Sixteen", "Seven-teen", "Eight-teen", "Nine-teen", "Twenty",
"Twenty one", "Twenty two", "Twenty three", "Twenty four", "Twenty five",
"Twenty six", "Twenty seven", "Twenty eight", "Twenty nine", "Thirty"}
for screen = 1,6 do
for i = 1,5 do
luup.variable_set(SID_SCENECONTROLLER, "Label_C" .. screen .. "_" .. i, labels[i + (screen - 1) * 5], peer_dev_num)
luup.variable_set(SID_SCENECONTROLLER, "Mode_C" .. screen .. "_" .. i, "M", peer_dev_num)
end
end
local labels2 = {"Forty-one", "Forty-five", "Forty-six", "Fifty",
"Fifty-one", "Fifty-five", "Fifty-six", "Sixty"}
for screen = 1, 4 do
luup.variable_set(SID_SCENECONTROLLER, "Label_T" .. screen+2 .. "_" .. 1, labels2[1 + (screen - 1) * 2], peer_dev_num)
luup.variable_set(SID_SCENECONTROLLER, "Mode_T" .. screen+2 .. "_" .. 1, "M", peer_dev_num)
luup.variable_set(SID_SCENECONTROLLER, "Label_T" .. screen+2 .. "_" .. 5, labels2[2 + (screen - 1) * 2], peer_dev_num)
luup.variable_set(SID_SCENECONTROLLER, "Mode_T" .. screen+2 .. "_" .. 5, "M", peer_dev_num)
end
end,
PhysicalButtonToIndicator = function(button, on)
-- Bits 0 and 1 are used for "Do Not Disturb" and "Housekeeping"
-- Bits 2-6 are buttons 1-5
if on then
return bit.lshift(2, button)
else
return bit.bxor(bit.lshift(2 ,button), 0x7C)
end
end,
PhysicalButtonToGroupIds = function(button, mode)
return button, button + 5, button, button + 5
end,
SetButtonType = function(peer_dev_num, node_id, physicalButton, newType, force, oldType)
local delay = 0
if physicalButton >= 2 and physicalButton <= 4 and (newType == 3 or oldType == 3 or force) then -- Thermostat mode
delay = 500
end
if force or oldType ~= newType then
SetConfigurationOption("SetButtonType", peer_dev_num, node_id, physicalButton, newType, delay)
end
end,
ScreenPage = function(screen)
local prefix = screen:sub(1,1)
local suffix = screen:sub(2)
if prefix == "C" then
return 17
elseif prefix == "T" then
if suffix == "1" then
return 8
elseif suffix == "2" then
return 16
elseif suffix == "3" then
return 40
else
return 17
end
elseif prefix == "P" then
return tonumber(suffix)
else
ELog("ScreenPage: Unknown screen: ", screen);
return 17
end
end,
SetDeviceScreen = function(peer_dev_num, screen)
local node_id = GetZWaveNode(peer_dev_num)
SetConfigurationOption("SetScreen", peer_dev_num, node_id, 17, SCObj.ScreenPage(screen))
end,
SetLanguage = function(peer_dev_num, language)
local node_id = GetZWaveNode(peer_dev_num)
SetConfigurationOption("SetPresetLanguage", peer_dev_num, node_id, 16, language)
end,
SetBacklight = function(peer_dev_num, blackLightOn)
DEntry("SetBacklight")
local node_id = GetZWaveNode(peer_dev_num)
local level = 0
if blackLightOn then
level = 15
end
-- Set backlight off level (range 0-20)
SetConfigurationOption("Backlight_on", peer_dev_num, node_id, 22, level)
-- Set buttons off level (range 0-20)
SetConfigurationOption("Buttons_on", peer_dev_num, node_id, 24, level)
end,
-- Evolve LCD1 button mode types:
-- 0=Scene control momentary
-- 1=Scen control toggle
-- 2=basic set toggle
-- 3=Temperature (buttons 2, 3, 4 only)
-- 4=Privacy
-- 5=Housekeeping
-- 6=Scen Control toggle on, Basic set toggle off
ModeMap = { M=0, -- Momentary
D=0, -- Direct (Deprecated)
T=1, -- Toggle
["2"]=0, -- Two-state
["3"]=0, -- Three-state
["4"]=0, -- Four-state
["5"]=0, -- Five-state
["6"]=0, -- Six-state
["7"]=0, -- Seven-state
["8"]=0, -- Eight-state
["9"]=0, -- Nine-state
S=1, -- Direct Toggle (Deprecated)
X=1, -- Exclusive
N=0, -- Switch Screen
H=3, -- Temperature
W=0, -- Welcome
P=0, -- Thermostat Operating mode
E=0, -- Thermostat Energy mode
L=0, -- scroLL
},
-- Convert a mode object to a mode type.
ModeType = function(mode)
local result = SCObj.ModeMap[mode.prefix];
if result == nil then
result = 0
elseif result == 1 and #mode > 0 and not mode.sceneControllable then
-- There are non-scene-capable direct associations, so we need to use basic set rather than scene activate/deactivate messages.
result = 2
end
return result
end,
}, -- DEVTYPE_EVOLVELCD1
-- Cooper RFWC5-Specific
[DEVTYPE_COOPEREFWC5] = {
Name = "Cooper RFWC5",
HasScreen = false,
MaxLabelSize = 16, -- dummy
HasMultipleScreens = false,
SceneBases = {P=1},
HasPresetLanguages = false,
HasThremostatControl = false,
HasBattery = false,
NumButtons = 5,
LastFixedSceneId = 5,
MaxDirectAssociations = 5,
HasOffScenes = false,
HasIndicator = true,
HasButtonModes = false,
HasCooperConfiguration = true,
HasCentralScene = false,
DefaultScreen = "P1",
DefaultModeString = "T",
DevType = DEVTYPE_COOPEREFWC5,
OldServiceId = "urn:gengen_mcv-org:serviceId:CooperRFWC5",
OldParamPrefix = "RFWC5",
DeviceXml = "D_CooperRFWC5.xml",
ScreenList = {P=1},
NumTemperatureScreens = 0,
LargeFontWidths = {}, -- Empty if not HasScreen
SmallFontWidths = {}, -- Empty if not HasScreen
screenWidth = 1, -- Dummy if not HasScreen
rightJustifyScreenWidth = 1,
SetTuningParameters = function(zwave_dev_num, peer_dev_num)
VEntry()
GetTuningParameter("InitStaggerSeconds" , 30 , zwave_dev_num)
GetTuningParameter("MinReinitSeconds" , 60 * 60 * 24 , zwave_dev_num)
GetTuningParameter("ReturnRouteDelay" , 500 , zwave_dev_num)
GetTuningParameter("UseWithSlaveController" , 0 , zwave_dev_num)
GetTuningParameter("Retries" , 0 , zwave_dev_num)
GetTuningParameter("AssociationDelay" , 5000 , zwave_dev_num)
GetTuningParameter("SceneControllerConfDelay", 0 , zwave_dev_num)
GetTuningParameter("UnassociateDelay" , 0 , zwave_dev_num)
GetTuningParameter("IndicatorDelay" , 0 , zwave_dev_num)
GetTuningParameter("CentralSceneTimeout" , 750 , zwave_dev_num)
end,
DoDeviceConfiguration = function(peer_dev_num, node_id, zwave_dev_num)
end,
SetDefaultLabels = function(peer_dev_num)
-- Empty if not HasScreen
end,
PhysicalButtonToIndicator = function(button, on)
if on then
return bit.lshift(1, button - 1)
else
return bit.bxor(bit.lshift(1, button - 1), 0x1F)
end
end,
PhysicalButtonToGroupIds = function(button, mode)
return button, nil, button, nil
end,
SetButtonType = function(peer_dev_num, node_id, physicalButton, newType, force, oldType)
-- TODO: Can we switch between momentary and toggle?
end,
ScreenPage = function(screen)
-- stub if not HasMultipleScreens
return 0
end,
SetDeviceScreen = function(peer_dev_num, screen)
-- No screen-type support
end,
SetLanguage = function(peer_dev_num, language)
-- empty if not HasPresetLanguages
end,
SetBacklight = function(peer_dev_num, blackLightOn)
-- empty if no backlight
end,
-- These modes are bogus. Same as the LCD1 for now.
ModeMap = { M=0, -- Momentary
D=0, -- Direct (Deprecated)
T=1, -- Toggle
["2"]=0, -- Two-state
["3"]=0, -- Three-state
["4"]=0, -- Four-state
["5"]=0, -- Five-state
["6"]=0, -- Six-state
["7"]=0, -- Seven-state
["8"]=0, -- Eight-state
["9"]=0, -- Nine-state
S=1, -- Direct Toggle (Deprecated)
X=1, -- Exclusive
N=0, -- Switch Screen
H=3, -- Temperature
W=0, -- Welcome
P=0, -- Thermostat Operating mode
E=0, -- Thermostat Energy mode
L=0, -- scroLL
},
-- Convert a mode object to a mode type.
ModeType = function (mode)
local result = SCObj.ModeMap[mode.prefix];
if result == nil then
result = 0
end
return result
end,
}, -- DEVTYPE_COOPEREFWC5
-- Nexia One-Touch-Specific
[DEVTYPE_NEXIAONETOUCH] = {
Name = "Nexia One Touch",
HasScreen = true,
MaxLabelSize = 17,
HasMultipleScreens = false,
SceneBases = {C=1},
HasPresetLanguages = false,
HasThremostatControl = true,
HasBattery = true,
NumButtons = 15,
LastFixedSceneId = 15,
MaxDirectAssociations = 2,
HasOffScenes = false,
HasIndicator = false,
HasButtonModes = true,
HasCooperConfiguration = false,
HasCentralScene = true,
DefaultScreen = "C1",
DefaultModeString = "M",
DevType = DEVTYPE_NEXIAONETOUCH,
OldServiceId = "urn:gengen_mcv-org:serviceId:NexiaOneTouch",
OldParamPrefix = "NEXIA",
DeviceXml = "D_NexiaOneTouch.xml",
ScreenList = {C=1},
NumTemperatureScreens = 0,
-- The "Large" font is actually narrower than the small font and can thus fit more characters per line.
-- However two lines of the small font can fit in one line of the large font.
LargeFontWidths = {
3,3,5,11,9,13,11,2,5,5,7,9,2,5,2,6,
8,6,8,7,9,8,8,8,8,8,3,3,8,6,8,7,
16,10,10,11,11,10,10,11,10,2,7,10,8,12,10,11,
10,11,10,10,10,10,10,16,12,10,10,4,5,4,8,9,
3,8,8,7,8,8,5,8,7,2,3,8,2,12,7,8,
8,8,5,6,5,7,8,12,8,8,8,6,3,6,8,3},
SmallFontWidths = {
3,2,4,7,6,8,7,2,6,5,4,6,3,4,2,4,
6,4,6,6,6,6,6,6,6,6,2,3,6,6,6,6,
9,6,6,6,6,6,5,6,6,2,5,6,5,8,6,7,
6,7,7,6,6,6,6,10,6,8,6,3,4,3,5,6,
3,5,5,4,6,5,4,5,5,2,3,5,2,8,5,5,
5,5,3,4,4,5,6,8,6,6,4,4,2,4,6,3},
ScreenWidth = 65,
RightJustifyScreenWidth = 67,
SetTuningParameters = function(zwave_dev_num, peer_dev_num)
VEntry()
GetTuningParameter("BaseDelay" , 300 , zwave_dev_num)
GetTuningParameter("ClearDelay" , 700 , zwave_dev_num)
GetTuningParameter("ScrollDelay" , 1000 , zwave_dev_num)
GetTuningParameter("LineDelay" , 35 , zwave_dev_num)
GetTuningParameter("CharDelay" , 8 , zwave_dev_num)
GetTuningParameter("ResponseDelay" , 30 , zwave_dev_num)
GetTuningParameter("BackoffDelay" , 50 , zwave_dev_num)
GetTuningParameter("MaxParts" , 2 , zwave_dev_num)
GetTuningParameter("UseClearScreen" , 1 , zwave_dev_num)
GetTuningParameter("Retries" , 0 , zwave_dev_num)
GetTuningParameter("SwitchScreenDelay" , 50 , zwave_dev_num)
GetTuningParameter("InitStaggerSeconds" , 15 , zwave_dev_num)
GetTuningParameter("MinReinitSeconds" , 60 * 60 * 24 , zwave_dev_num)
GetTuningParameter("ReturnRouteDelay" , 500 , zwave_dev_num)
GetTuningParameter("UseWithSlaveController" , 0 , zwave_dev_num)
GetTuningParameter("AssociationDelay" , 0 , zwave_dev_num)
GetTuningParameter("SceneControllerConfDelay", 0 , zwave_dev_num)
GetTuningParameter("UnassociateDelay" , 0 , zwave_dev_num)
GetTuningParameter("IndicatorDelay" , 0 , zwave_dev_num)
GetTuningParameter("CentralSceneTimeout" , 750 , zwave_dev_num)
local node_id = GetZWaveNode(zwave_dev_num)
-- Here we set up kluges to avoid problems with UI7 with the Nexia One-Touch
-- LuaUPnP does not handle the ASSOCIATION_GROUP_INFO_GET command in list mode
-- correctly. The device is allowed to send all of its associations in one list
-- or as several reports. The Nexia one-touch sends 46 such reports and this
-- seriously confuses LuaUPnP which is trying to get other information from the
-- device.
-- Vera should use the results of ASSOCIATION_GROUPTINGS_GET to decide how much
-- data to expect from the device.
-- Our work around is return 1 association (the lifeline) to vera (we know better)
-- and then to fake-out the call to ASSOCIATION_GROUP_INFO_GET to return only one
-- info packet.
-- The nexia 1-touch for its part is sending the wrong profile for group 1
-- It should be 0x0001 (lifeline) rather 0x0000 (N/A) but this is relatively minor
-- and we fix that here too.
MonitorZWaveData( true, -- outgoing
peer_dev_num,
nil, -- No arm data
--[==[
C1 C2
41 12/29/16 18:40:07.189 0x1 0x9 0x0 0x13 0xf 0x2 0x85 0x5 0x5 0x6 0x6b (##########k)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
length = 9 ------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
FUNC_ID_ZW_SEND_DATA ---------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Device 45=Nexia One Touch Scene Controller Z-Wave -+ ¦ ¦ ¦ ¦ ¦ ¦
Data length = 2 -----------------------+ ¦ ¦ ¦ ¦ ¦
COMMAND_CLASS_ASSOCIATION ----------------------------+ ¦ ¦ ¦ ¦
ASSOCIATION_GROUPINGS_GET --------------------------------+ ¦ ¦ ¦
Xmit options = ACK | AUTO_ROUTE ------------------------------------+ ¦ ¦
Callback = 6 ----------------------------------------+ ¦
Checksum OK ---------------------------------------------+
--]==]
"^01 .. 00 (..) " .. string.format("%02X", node_id) .. " .. 85 05 .* (..) ..$",
--[==[
42 12/29/16 18:40:07.221 0x6 0x1 0x4 0x1 0x13 0x1 0xe8 (#######)
ACK - Acknowledge --+ ¦ ¦ ¦ ¦ ¦ ¦
SOF - Start Of Frame ------+ ¦ ¦ ¦ ¦ ¦
length = 4 ----------+ ¦ ¦ ¦ ¦
Response --------------+ ¦ ¦ ¦
FUNC_ID_ZW_SEND_DATA -------------------+ ¦ ¦
RetVal: OK -----------------------+ ¦
Checksum OK ----------------------------+
42 12/29/16 18:40:07.222 got expected ACK
41 12/29/16 18:40:07.222 ACK: 0x6 (#)
42 12/29/16 18:40:07.261 0x1 0x5 0x0 0x13 0x6 0x0 0xef (#######)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦
length = 5 ------+ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦
FUNC_ID_ZW_SEND_DATA ---------------+ ¦ ¦ ¦
Callback = 6 -------------------+ ¦ ¦
TRANSMIT_COMPLETE_OK -----------------------+ ¦
Checksum OK ----------------------------+
41 12/29/16 18:40:07.261 ACK: 0x6 (#)
42 12/29/16 18:40:07.361 0x1 0x9 0x0 0x4 0x0 0xf 0x3 0x85 0x6 0x2e 0x53 (#########.S)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
length = 9 ------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
FUNC_ID_APPLICATION_COMMAND_HANDLER ----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Receive Status SINGLE ------------------+ ¦ ¦ ¦ ¦ ¦ ¦
Device 45=Nexia One Touch Scene Controller Z-Wave ----+ ¦ ¦ ¦ ¦ ¦
Data length = 3 --------------------------+ ¦ ¦ ¦ ¦
COMMAND_CLASS_ASSOCIATION -------------------------------+ ¦ ¦ ¦
ASSOCIATION_GROUPINGS_REPORT -----------------------------------+ ¦ ¦
Supported Groupings = 46 ----------------------------------------+ ¦
Checksum OK ---------------------------------------------+
--]==]
"06 01 04 01 \\1 01 XX 01 05 00 \\1 \\2 00 XX 01 09 00 04 00 " .. string.format("%02X", node_id) .. " 03 85 06 01 XX",
DummyCallback,
false, -- not oneShot
0, -- no timeout
"NexiaBypass1");
MonitorZWaveData( true, -- outgoing
peer_dev_num,
nil, -- No arm data
--[==[
C1 C2
41 12/29/16 19:20:35.302 0x1 0xb 0x0 0x13 0xf 0x4 0x59 0x3 0x40 0x0 0x5 0x2b 0xd8 (######Y#@##+#)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
length = 11 ------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
FUNC_ID_ZW_SEND_DATA ---------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Device 45=Nexia One Touch Scene Controller Z-Wave -+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Data length = 4 -----------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦
COMMAND_CLASS_ASSOCIATION_GRP_INFO -------------------------+ ¦ ¦ ¦ ¦ ¦ ¦
ASSOCIATION_GROUP_INFO_GET --------------------------------+ ¦ ¦ ¦ ¦ ¦
Flags = List Mode -------------------------------------+ ¦ ¦ ¦ ¦
Grouping Identifier = 0 -----------------------------------------+ ¦ ¦ ¦
Xmit options = ACK | AUTO_ROUTE ---------------------------------------------+ ¦ ¦
Callback = 43 --------------------------------------------------+ ¦
Checksum OK -------------------------------------------------------+
--]==]
"^01 .. 00 (..) " .. string.format("%02X", node_id) .. " .. 59 03 40 00 .* (..) ..$",
--[==[
42 12/29/16 19:20:35.321 0x6 0x1 0x4 0x1 0x13 0x1 0xe8 (#######)
ACK - Acknowledge --+ ¦ ¦ ¦ ¦ ¦ ¦
SOF - Start Of Frame ------+ ¦ ¦ ¦ ¦ ¦
length = 4 ----------+ ¦ ¦ ¦ ¦
Response --------------+ ¦ ¦ ¦
FUNC_ID_ZW_SEND_DATA -------------------+ ¦ ¦
RetVal: OK -----------------------+ ¦
Checksum OK ----------------------------+
41 12/29/16 19:20:35.321 ACK: 0x6 (#)
42 12/29/16 19:20:35.353 0x1 0x5 0x0 0x13 0x2b 0x0 0xc2 (####+##)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦
length = 5 ------+ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦
FUNC_ID_ZW_SEND_DATA ---------------+ ¦ ¦ ¦
Callback = 43 --------------------+ ¦ ¦
TRANSMIT_COMPLETE_OK ------------------------+ ¦
Checksum OK -----------------------------+
41 12/29/16 19:20:35.354 ACK: 0x6 (#)
42 12/29/16 19:20:35.387 0x1 0x10 0x0 0x4 0x0 0xf 0xa 0x59 0x4 0x81 0x1 0x0 0x0 0x0 0x0 0x0 0x0 0x33 (######\nY#########3)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ +-----+ ¦ +-----+ ¦
length = 16 -------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Request -----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
FUNC_ID_APPLICATION_COMMAND_HANDLER -----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Receive Status SINGLE -------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Device 45=Nexia One Touch Scene Controller Z-Wave -----+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Data length = 10 ---------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
COMMAND_CLASS_ASSOCIATION_GRP_INFO -----------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
ASSOCIATION_GROUP_INFO_REPORT ------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Flags = List Mode | Group Count=1 ---------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦
Grouping Identifier = 1 ---------------------------------------------+ ¦ ¦ ¦ ¦ ¦
Mode = 0 -------------------------------------------------+ ¦ ¦ ¦ ¦
Profile = AGI_GENERAL_NA ------------------------------------------------------+ ¦ ¦ ¦
Reserved = 0 -------------------------------------------------------------+ ¦ ¦
Event Code = 0 ------------------------------------------------------------------+ ¦
Checksum OK --------------------------------------------------------------------------+
end,
--]==]
"06 01 04 01 \\1 01 XX 01 05 00 \\1 \\2 00 XX 01 10 00 04 00 " .. string.format("%02X", node_id) .. " 0A 59 04 81 01 00 00 01 00 00 00 XX",
DummyCallback,
false, -- not oneShot,
0, -- no timeout
"NexiaBypass2");
-- The Nexisa One-Touch seems to think that getting a WAKE_UP_INTERVAL_SET command is an excuse to go back
-- to sleep even though there is more work to do. This is not Vera's fault. This is a problem with the
-- Nexia firmware. We do the intercept to prevent the device from receiving this command until we are done
-- configuring it.
function WakeUpIntervalSetCallback(peer_dev_num, captures)
DEntry()
if captures and captures.C2 and captures.C3 then
wakeUpIntervals[peer_dev_num] = "0x84 0x04 0x" .. string.gsub(captures.C2 .. " " .. captures.C3, " ", " 0x")
DLog("WakeUpIntervalSetCallback: wakeUpIntervals[", peer_dev_num,"] set to", wakeUpIntervals[peer_dev_num])
end
end
MonitorZWaveData( true, -- outgoing
peer_dev_num,
nil, -- No arm data
--[==[
C1 ------C2----- C3 C4
41 11/25/17 8:48:44.793 0x1 0xd 0x0 0x13 0xdf 0x6 0x84 0x4 0x0 0x10 0x68 0x1 0x5 0x12 0xd6 (#\r########h####)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ +-----------+ ¦ ¦ ¦ ¦
length = 13 ------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
FUNC_ID_ZW_SEND_DATA ---------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Device 900=Nexia One Touch Scene Controller Z-Wave -+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Data length = 6 ------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦
COMMAND_CLASS_WAKE_UP -----------------------------+ ¦ ¦ ¦ ¦ ¦ ¦
WAKE_UP_INTERVAL_SET ---------------------------------+ ¦ ¦ ¦ ¦ ¦
Seconds = 4200 -----------------------------------------+ ¦ ¦ ¦ ¦
nodeid: 1 Device 2=_Scene Controller ----------------------------------------------+ ¦ ¦ ¦
Xmit options = ACK | AUTO_ROUTE -------------------------------------------------------+ ¦ ¦
Callback = 18 ------------------------------------------------------------+ ¦
Checksum OK -----------------------------------------------------------------+
--]==]
"^01 .. 00 (..) " .. string.format("%02X", node_id) .. " 06 84 04 (.. .. ..) (..) .. (..) ..",
--[==[
42 11/25/17 8:48:44.814 0x6 0x1 0x4 0x1 0x13 0x1 0xe8 (#######)
ACK - Acknowledge --+ ¦ ¦ ¦ ¦ ¦ ¦
SOF - Start Of Frame ------+ ¦ ¦ ¦ ¦ ¦
length = 4 ----------+ ¦ ¦ ¦ ¦
Response --------------+ ¦ ¦ ¦
FUNC_ID_ZW_SEND_DATA -------------------+ ¦ ¦
RetVal: OK -----------------------+ ¦
Checksum OK ----------------------------+
42 11/25/17 8:48:44.814 got expected ACK
41 11/25/17 8:48:44.815 ACK: 0x6 (#)
42 11/25/17 8:48:44.892 0x1 0x5 0x0 0x13 0x12 0x0 0xfb (#######)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦
length = 5 ------+ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦
FUNC_ID_ZW_SEND_DATA ---------------+ ¦ ¦ ¦
Callback = 18 --------------------+ ¦ ¦
TRANSMIT_COMPLETE_OK ------------------------+ ¦
Checksum OK -----------------------------+
41 11/25/17 8:48:44.892 ACK: 0x6 (#)
--]==]
"06 01 04 01 \\1 01 XX 01 05 00 \\1 \\4 00 XX",
WakeUpIntervalSetCallback,
false, -- not oneShot,
0, -- no timeout
"NexiaWakeupIntervalSet");
end,
DoDeviceConfiguration = function(peer_dev_num, node_id, zwave_dev_num)
local veraZWaveNode, ZWaveNetworkDeviceId = GetVeraIDs()
local associateList = {[ZWaveNetworkDeviceId] = {level=255, dimmingDuration=255}}
UnassociateDevice(zwave_dev_num, nil, 1, 1, 1, 0) -- Clear central scene association
AssociateDevice(zwave_dev_num, associateList, 1, 1, 1, 0) -- Associate central scene with Vera
end,
SetDefaultLabels = function(peer_dev_num)
local labels = {"One", "Two", "Three", "Four", "Five",
"Six", "Seven", "Eight", "Nine", "Ten",
"Eleven", "Twelve", "Thir-teen", "Four-teen", "Fifteen",
"Sixteen", "Seven-teen", "Eight-teen", "Nine-teen", "Twenty",
"Twenty one", "Twenty two", "Twenty three", "Twenty four", "Twenty five",
"Twenty six", "Twenty seven", "Twenty eight", "Twenty nine", "Thirty"}
for i = 1,15 do
luup.variable_set(SID_SCENECONTROLLER, "Label_C1_" .. i, labels[i], peer_dev_num)
luup.variable_set(SID_SCENECONTROLLER, "Mode_C1_" .. i, "M", peer_dev_num)
end
end,
PhysicalButtonToIndicator = function(button, on)
-- Nexia One Touch does not support the indicator command class
return 0
end,
-- Returns:
-- Association On Group ID
-- Association Off Group ID (or nil)
-- Scene Controller Configuration On Group ID
-- Scene Controller Configuration Off Group ID (or nil)
PhysicalButtonToGroupIds = function(button, mode)
if mode.prefix == 'H' then
-- Thermostat
return button + 31, nil, button, nil
elseif mode.sceneControllable then -- Scene activation
if mode.prefix == "T" then
-- For scene controllable toggle we need to associate with both the scene and the basic set groups.
return button + 16, button + 1, button, nil
else
-- Scene compatible momentary
return button + 16, nil, button, nil
end
else
if mode.prefix == "T" then
-- Basic set
return button + 1, nil, button, nil
else
-- Send Scene control message back to the central controller for momentary scenes.
return button + 16, nil, button, nil
end
end
end,
SetButtonType = function(peer_dev_num, node_id, physicalButton, newType, force, oldType)
DEntry("SetButtonType")
if force or oldType ~= newType then
SetConfigurationOption("SetButtonType", peer_dev_num, node_id, physicalButton + 1, newType)
end
end,
ScreenPage = function(screen)
-- Stub if device does not support multiple screens
return 0
end,
SetDeviceScreen = function(peer_dev_num, screen)
-- No screen-type support
end,
SetLanguage = function(peer_dev_num, language)
-- No language support
end,
SetBacklight = function(peer_dev_num, blackLightOn)
-- No backlight control
end,
-- Nexia One-Touch button mode types:
-- 0=Central Scene
-- 1=Scene Control Momentary
-- 2=BASIC SET Toggle
-- 3=Scene Control/BASIC SET toggle
-- 4=Thermostat
ModeMap = { M=1, -- Momentary
D=1, -- Direct (Deprecated)
T=3, -- Toggle
["2"]=1, -- Two-state
["3"]=1, -- Three-state
["4"]=1, -- Four-state
["5"]=1, -- Five-state
["6"]=1, -- Six-state
["7"]=1, -- Seven-state
["8"]=1, -- Eight-state
["9"]=1, -- Nine-state
S=3, -- Direct Toggle (Deprecated)
X=3, -- Exclusive
N=1, -- Switch Screen
H=4, -- Temperature
W=1, -- Welcome
P=1, -- Thermostat Operating mode
E=1, -- Thermostat Energy mode
C=0, -- Central Scene
L=1, -- scroLL
},
-- Convert a mode object to a mode type.
ModeType = function (mode)
local result = SCObj.ModeMap[mode.prefix];
if result == nil then
return 1
end
if result == 3 and not mode.sceneControllable then
-- There are non-scene-capable direct associations, so we need to use basic set rather than scene activate/deactivate messages.
result = 2
end
return result
end,
}, -- DEVTYPE_NEXIAONETOUCH
} -- Devices
DEVTYPE_ZWN = "urn:schemas-micasaverde-com:device:ZWaveNetwork:1"
DEVTYPE_BINARY = "urn:schemas-upnp-org:device:BinaryLight:1"
DEVTYPE_DIMMABLE = "urn:schemas-upnp-org:device:DimmableLight:1"
DEVTYPE_THERMOSTAT = "urn:schemas-upnp-org:device:HVAC_ZoneThermostat:1"
DEVTYPE_WINDOWCOVERING = "urn:schemas-micasaverde-com:device:WindowCovering:1"
SID_HADEVICE = "urn:micasaverde-com:serviceId:HaDevice1"
SID_HAG = "urn:micasaverde-com:serviceId:HomeAutomationGateway1"
SID_SCTRL = "urn:micasaverde-com:serviceId:SceneController1"
SID_ZWDEVICE = "urn:micasaverde-com:serviceId:ZWaveDevice1"
SID_DIMMING = "urn:upnp-org:serviceId:Dimming1"
SID_FANMODE = "urn:upnp-org:serviceId:HVAC_FanOperatingMode1"
SID_USERMODE = "urn:upnp-org:serviceId:HVAC_UserOperatingMode1"
SID_SECURITYSENSOR = "urn:micasaverde-com:serviceId:SecuritySensor1"
SID_SWITCHPOWER = "urn:upnp-org:serviceId:SwitchPower1"
SID_TEMPSENSOR = "urn:upnp-org:serviceId:TemperatureSensor1"
SID_TEMPSETPOINT = "urn:upnp-org:serviceId:TemperatureSetpoint1"
SID_COOLSETPOINT = "urn:upnp-org:serviceId:TemperatureSetpoint1_Cool"
SID_HEATSETPOINT = "urn:upnp-org:serviceId:TemperatureSetpoint1_Heat"
SID_HVACOPSTATE = "urn:micasaverde-com:serviceId:HVAC_OperatingState1"
HVACOPSTATE_VAR = "ModeState"
HVACOPSTATE_IDLE = "Idle"
HVACOPSTATE_HEATING = "Heating"
HVACOPSTATE_COOLING = "Cooling"
ACTUATOR_CONF = "SceneActuatorConf"
CURRENT_INDICATOR = "CurrentIndicator"
CURRENT_SCREEN = "CurrentScreen"
FANMODE_AUTO = "Auto"
FANMODE_ON = "ContinuousOn"
FANMODE_CYCLE = "PeriodicOn"
FANMODE_VAR = "Mode"
NUMLINES_VAR = "NumLines"
PRESET_LANGUAGE = "PresetLanguage"
RETURN_ROUTES = "ReturnRoutes"
SCROLLOFFSET_VAR = "ScrollOffset"
SETPOINT_TARG = "SetpointTarget"
SETPOINT_VAR = "CurrentSetpoint"
ALLSETPOINTS_VAR = "AllSetpoints"
TEMPSENSOR_VAR = "CurrentTemperature"
USERMODE_VAR = "ModeStatus"
USERMODE_AUTO = "AutoChangeOver"
USERMODE_COOL = "CoolOn"
USERMODE_HEAT = "HeatOn"
USERMODE_OFF = "Off"
ENERGYMODE_VAR = "EnergyModeStatus"
ENERGYMODE_NORMAL = "Normal"
ENERGYMODE_SAVING = "EnergySavingsMode"
SIGUSR2 = 17 -- Vera posix library does not define this - MIPS-specific value
SCREEN_MD = {
-- Screen flags
ClearScreen = 0x00,
ScrollDown = 0x08,
ScrollUp = 0x10,
NoChange = 0x38,
ScreenMask = 0x38,
MoreData = 0x80,
-- Line Flags
StdFont = 0x00,
Highlighted = 0x20,
LargeFont = 0x40,
LargeFontHighlighted = 0x60,
StdFontNoScroll = 0x80,
HighlightedNoScroll = 0xA0,
LargeFontNoScroll = 0xC0,
LargeFontHighlightedNoScroll = 0xE0,
NoClearLine = 0x00,
ClearLine = 0x10,
Line1 = 0x00,
Line2 = 0x01,
Line3 = 0x02,
Line4 = 0x03,
Line5 = 0x04
}
-- Make sure tha all of the log functions work before even the SCObj global is set.
function GetDeviceName()
local name = "Scene Controller"
if SCObj then
name = SCObj.Name
end
return name
end
--
-- Start benchmark code
--
function findBestDelay(labels, node_id, zwave_dev_num, first, last, screenFlags)
local save_retries = param.SCENE_CTRL_Retries
param.SCENE_CTRL_Retries = 1
local low = 1
local high = 1000
while high > low do
local test = math.floor((high + low) / 2)
local count = 0
local bad = 0
for i = 1,10 do
log("Benchmark Testing ", labels, "delay=", test, " iteration=", i)
if EVLCDWrapStrings(labels, {}, {}, node_id, zwave_dev_num, screenFlags, test) then
count = count + 1
else
bad = bad + 1
if bad > 1 then
break
end
end
end
if count >= 9 then
log("Benchmark test ", labels, " delay=", test, " passed")
high = test
else
log("Benchmark test ", labels, " delay=", test, " failed")
low = test+1
end
end
log ("Benchmark test ", labels, " Best value is ", high)
param.SCENE_CTRL_Retries = save_retries
return high
end
tests = {}
function test(labels)
tests[labels] = findBestDelay(labels, test_node_id, test_zwave_dev_num, 1, #labels, test_clear)
end
function Benchmark(peer_dev_num, screen)
test_node_id, test_zwave_dev_num = GetZWaveNode(peer_dev_num)
EVLCDWrapStrings({""}, {}, {}, test_node_id, test_zwave_dev_num, true, 1000)
if screen == 1 then
test_clear = SCREEN_MD.ClearScreen
else
test_clear = SCREEN_MD.NoChange
end
test {"1"}
test {"22"}
test {"333"}
test {"4444"}
test {"55555"}
test {"666666"}
test {"7777777"}
test {"88888888"}
test {"999999999"}
printTable(tests,"Benchmark: ")
test {"1","2"}
test {"1","2","3"}
test {"1","2","3","4"}
test {"1","2","3","4","5"}
test {"1\r1"}
test {"1\r1","2\r2"}
test {"1\r1","2\r2","3\r3"}
test {"1\r1","2\r2","3\r3","4\r4"}
test {"1\r1","2\r2","3\r3","4\r4","5\r5"}
printTable(tests,"Benchmark: ")