-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathL_GenGenSceneControllerInstaller.lua
More file actions
executable file
·2187 lines (2113 loc) · 141 KB
/
L_GenGenSceneControllerInstaller.lua
File metadata and controls
executable file
·2187 lines (2113 loc) · 141 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
-- Installer for GenGeneric Scene Controller Version 1.23d
--
-- 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
-- Includes installation files for
-- Evolve LCD1
-- Cooper RFWC5
-- Nexia One Touch NX1000
-- Also installs improved support for
-- Kichler 12387 undercabinet light controller
-- Aeotec Siren
-- Shlage BE469 lock
-- Evolve T100R Thermostat (UI5 Only)
-- This installs zwave_products_user.xml for UI5 and modifies KitDevice.json for UI7.
-- It also installs the custom icon in the appropriate places for UI5 or UI7
-- VerboseLogging == 0: important logs and errors: ELog, log
-- VerboseLogging == 1: Includes Info logs: ELog, log, ILog,
-- VerboseLogging == 2: Includes debug logs: ELog, log, ILog, DLog, DEntry
-- VerboseLogging == 3: Include extended ZWave Queue ELog, log, ILog, DLog, DEntry
-- VerboseLogging == 4: Includes verbose logs: ELog, log, ILog, DLog, DEntry, VLog, VEntry
VerboseLogging = 4
-- Set UseDebugZWaveInterceptor to true to enable zwint log messages to log.LuaUPnP (Do not confuse with LuaUPnP.log)
local UseDebugZWaveInterceptor = false
local GenGenInstaller_Version = 123 -- Update this each time we update the installer.
local bit = require 'bit'
local nixio = require "nixio"
local socket = require "socket"
require "L_GenGenSceneControllerShared"
local HAG_SID = "urn:micasaverde-com:serviceId:HomeAutomationGateway1"
local ZWN_SID = "urn:micasaverde-com:serviceId:ZWaveNetwork1"
local GENGENINSTALLER_SID = "urn:gengen_mcv-org:serviceId:SceneControllerInstaller1"
local GENGENINSTALLER_DEVTYPE = "urn:schemas-gengen_mcv-org:device:SceneControllerInstaller:1"
local SID_SCENECONTROLLER = "urn:gengen_mcv-org:serviceId:SceneController1"
-- Make sure tha all of the log functions work before even the SCObj global is set.
function GetDeviceName()
return "GenGeneric Scene Controller"
end
local reload_needed = false
-- Update file with the given content if the previous version does not exist or is different.
function UpdateFileWithContent(filename, content, permissions, version, force)
local update = false
local backup = false
local oldVersion
if not content then
ELog("Missing content for ", filename)
return false
end
local stat = nixio.fs.stat(filename)
local oldName = filename .. ".old"
local backupName = filename .. ".save"
oldversion = luup.variable_get(GENGENINSTALLER_SID, filename .. "_version", lul_device)
if oldversion then
oldversion = tonumber(oldversion)
else
oldversion = 0
end
if not version then
version = 0
end
if stat then
if version > oldversion or (version == oldversion and stat.size ~= #content) or force then
log("Backing up ", filename, " to ", backupName, " and replacing with new version.")
VLog("Old ", filename, " size was ", stat.size, " bytes. new size is ", #content, " bytes.")
nixio.fs.rename(backupName, oldName)
local result, errno, errmsg = nixio.fs.rename(filename, backupName)
if result then
update = true
backup = true
else
ELog("could not rename ", filename, " to", backupName, ": ", errmsg)
end
else
if oldversion > version then
VLog("Not updating ", filename, " because the old version is ", oldversion, " and the new version is ", version)
else
VLog("Not updating ", filename, " because the new content is ", #content, " bytes and the old is ", stat.size, " bytes.")
end
end
else
VLog("updating ", filename, " because a previous version does not exist")
update = true
end
if update then
local f, errno, errmsg = nixio.open(filename, "w", permissions)
if f then
local result, errno, errmsg, bytesWritten = f:write(content)
if result then
f:close()
if backup then
nixio.fs.remove(oldName)
end
VLog("Wrote ", filename, " successfully (", #content, " bytes)")
if version > 0 then
luup.variable_set(GENGENINSTALLER_SID, filename .. "_version", tostring(version), lul_device)
end
reload_needed = filename
return true
else
ELog("could not write ", #content, " bytes into ", filename, ". only ", bytesWritten, " bytes written: ", errmsg)
f:close()
if backup then
nixio.fs.rename(backupName, filename)
nixio.fs.rename(oldName, backupName)
end
end
else
ELog("could not open ", filename, " for writing: ", errmsg)
if backup then
nixio.fs.rename(backupName, filename)
nixio.fs.rename(oldName, backupName)
end
end
end
return false
end
-- Prepares a file to be updated.
-- Returns nixio read and write file handles if update is needed.
-- Returns nil if no update required or error occurred. (base not modified)
-- <base.old - previous base.modified (for error handling)
-- <base>.save - previous base
-- <base>.modified - new file
-- <base> - Symlink to <base>.modified
function PrepFileForUpdate(base, force)
local base_modified = base .. ".modified"
local base_save = base .. ".save"
local base_old = base .. ".old"
local base_temp = base .. ".temp"
local base_lstat, errno, errmsg = nixio.fs.lstat(base)
local why = nil
if not base_lstat then
ELog("could not lstat ", base, ": ", errmsg)
return nil
end
local base_save_stat = nixio.fs.stat(base_save)
if base_save_stat and base_lstat.type == "lnk" then
local base_linkname, errno, errmsg = nixio.fs.readlink(base)
if not base_linkname then
ELog("Could not readlink ", base": ", errmsg)
return nil
end
if base_linkname ~= base_save then
why = base .. " now symlinks to " .. base_linkname .. " instead of " .. base_save .. ". Perhaps the Vera software has been updated. Removing old " .. base_save
nixio.fs.remove(base_save)
base_save_stat = nil
end
end
local base_modified_stat = nixio.fs.stat(base_modified)
if not why then
if force then
why = "Installer has been updated"
elseif not base_modified_stat then
why = "the file has never been modified by the installer"
end
end
if why then
if base_modified_stat then
nixio.fs.rename(base_modified, base_old)
end
if not base_save_stat then
local result, errno, errmsg = nixio.fs.rename(base, base_save)
if not result then
ELog("could not rename ", base, " to", base_save, ": ", errmsg)
if base_modified_stat then
nixio.fs.rename(base_old, base_modified)
end
return nil
end
end
local read_file, errmsg, errno = io.open(base_save, "r")
if not read_file then
ELog("could not open ", base_save, " for reading: ", errmsg)
if not base_save_stat then
nixio.fs.rename(base_save, base)
end
if base_modified_stat then
nixio.fs.rename(base_old, base_modified)
end
return nil
end
local write_file, errmsg, errno = io.open(base_modified, "w", 644)
if not write_file then
ELog("could not open ", base_modified, " for writing: ", errmsg)
read_file:close()
if not base_save_stat then
nixio.fs.rename(base_save, base)
end
if base_modified_stat then
nixio.fs.rename(base_old, base_modified)
end
return nil
end
if base_save_stat then
local result, errno, errmsg = nixio.fs.remove(base)
if not result then
ELog("could not delete old symlink ", base, ": ", errmsg)
write_file:close()
read_file:close()
nixio.fs.remove(base_modified)
if base_modified_stat then
nixio.fs.rename(base_old, base_modified)
end
return nil
end
end
local result, errno, errmsg = nixio.fs.symlink(base_modified, base)
if not result then
ELog("could not symlink ", base_modified, " to", base, ": ", errmsg)
write_file:close()
read_file:close()
if not base_save_stat then
nixio.fs.rename(base_save, base)
end
nixio.fs.remove(base_modified)
if base_modified_stat then
nixio.fs.rename(base_old, base_modified)
end
return nil
end
nixio.fs.remove(base_old)
return read_file, write_file, why
end
return nil
end
function updateJson(filename, update_func, updated)
read_file, write_file, why = PrepFileForUpdate(filename, updated)
if read_file then
log("Updating ", filename, " because ", why)
local str = read_file:read("*a")
read_file:close()
local obj=json.decode(str);
update_func(obj)
local state = { indent = true }
local str2 = json.encode (obj, state)
write_file:write(str2)
write_file:close()
reload_needed = filename
else
VLog("Not updating ", filename)
end
end
ScannedDeviceList = {}
function ScanForNewDevices()
DEntry()
local function AdoptEvolveLCD1(device_num)
DEntry()
luup.attr_set("device_type", "urn:schemas-gengen_mcv-org:device:SceneControllerEvolveLCD:1", device_num)
luup.attr_set("device_file", "D_EvolveLCD1.xml", device_num)
luup.attr_set("impl_file", "I_GenGenSceneController.xml", device_num)
luup.attr_set("name", "Evolve LCD1 Z-Wave", device_num)
luup.attr_set("manufacturer", "Evolve Guest Controls", device_num)
luup.attr_set("device_json", "D_EvolveLCD1.json", device_num)
luup.attr_set("category_num", "14", device_num)
luup.attr_set("subcategory_num", "0", device_num)
luup.attr_set("model", "EVLCD1", device_num)
luup.attr_set("invisible", "1", device_num)
luup.variable_set("urn:micasaverde-com:serviceId:SceneController1", "NumButtons", "5", device_num)
luup.variable_set("urn:micasaverde-com:serviceId:SceneController1", "FiresOffEvents", "1", device_num)
luup.variable_set("urn:micasaverde-com:serviceId:SceneController1", "ActivationMethod", "0", device_num)
luup.variable_set("urn:micasaverde-com:serviceId:ZWaveDevice1", "VariablesSet", "20-Display Timeout (seconds),m,,"..
"21-Backlight ON level (1-20),m,,"..
"22-Backlight OFF level (0-20),m,,"..
"23-Button ON level (1-20),m,,"..
"24-Button OFF level (0-20),m,,"..
"25-LCD Contrast (5-20),m,,"..
"26-Orientation(1=rotate 180 0=normal),m,,"..
"27-Network Update (seconds),m,,"..
"29-backlight level (0-100),m,,"..
"32-Backlight Demo mode (0-1),m,", device_num)
luup.variable_set("urn:micasaverde-com:serviceId:HaDevice1", "Documentation", "http://code.mios.com/trac/mios_evolve-lcd1", device_num)
luup.variable_set("urn:micasaverde-com:serviceId:ZWaveDevice1", "Documentation", "http://code.mios.com/trac/mios_evolve-lcd1", device_num)
end
local function AdoptCooperRFWC5(device_num)
DEntry()
luup.attr_set("device_type", "urn:schemas-gengen_mcv-org:device:SceneControllerCooperRFWC5:1", device_num)
luup.attr_set("device_file", "D_CooperRFWC5.xml", device_num)
luup.attr_set("impl_file", "I_GenGenSceneController.xml", device_num)
luup.attr_set("manufacturer", "Cooper Industries", device_num)
luup.attr_set("name", "Cooper RFWC5 Z-Wave", device_num)
luup.attr_set("dev ice_json", "D_CooperRFWC5.json", device_num)
luup.attr_set("category_num", "14", device_num)
luup.attr_set("subcategory_num", "0", device_num)
luup.attr_set("model", "RFWC5", device_num)
luup.attr_set("invisible", "1", device_num)
luup.variable_set("urn:micasaverde-com:serviceId:SceneController1", "NumButtons", "5", device_num)
luup.variable_set("urn:micasaverde-com:serviceId:SceneController1", "FiresOffEvents", "1", device_num)
luup.variable_set("urn:micasaverde-com:serviceId:SceneController1", "ActivationMethod", "0", device_num)
end
local function AdoptNexiaOneTouch(device_num)
DEntry()
luup.attr_set("device_type", "urn:schemas-gengen_mcv-org:device:SceneControllerNexiaOneTouch:1", device_num)
luup.attr_set("device_file", "D_NexiaOneTouch.xml", device_num)
luup.attr_set("impl_file", "I_GenGenSceneController.xml", device_num)
luup.attr_set("manufacturer", "Ingersoll Rand", device_num)
luup.attr_set("name", "Nexia One Touch Z-Wave", device_num)
luup.attr_set("device_json", "D_NexiaOneTouch.json", device_num)
luup.attr_set("category_num", "14", device_num)
luup.attr_set("subcategory_num", "0", device_num)
luup.attr_set("model", "NX1000", device_num)
luup.attr_set("invisible", "1", device_num)
luup.variable_set("urn:micasaverde-com:serviceId:SceneController1", "NumButtons", "5", device_num)
luup.variable_set("urn:micasaverde-com:serviceId:SceneController1", "FiresOffEvents", "1", device_num)
luup.variable_set("urn:micasaverde-com:serviceId:SceneController1", "ActivationMethod", "0", device_num)
luup.variable_set("urn:micasaverde-com:serviceId:ZWaveDevice1", "VariablesSet", "20-Touch Calibration (1-10),m,,"..
"21-Screen Contrast (1-10),m,,"..
"23-Button LED Level (1-10),m,,"..
"24-Backlight Level (1-10),m,,"..
"25-Scene Button Press Backlight Timeout (10-15),m,,"..
"26-Page Button Press Backlight Timeout (5-15),m,,"..
"28-Screen Timeout (1-240),m,,"..
"29-Screen Timeout Primary Page (0-3),m,,"..
"30-Battery Stat Shutdown Threshold % (0-20),m,,"..
"31-Battery Radio Cutoff Threshold % (0-40),m,,"..
"32-Battery LOWBATT Indicator Threshold % (5-50),m,,"..
"33-Battery Threshold Value for Midlevel % (30-80),m,",device_num)
luup.variable_set("urn:micasaverde-com:serviceId:HaDevice1", "Documentation", "http://products.z-wavealliance.org/products/1344", device_num)
luup.variable_set("urn:micasaverde-com:serviceId:ZWaveDevice1", "Documentation", "http://products.z-wavealliance.org/products/1344", device_num)
end
-- This is a hack for the Aeotec Siren which includes "COMMAND_CLASS_SECURITY" in its node info but never actually responds to a Security Nonce Get command
local function ApplyAeotecSirenHack()
DEntry()
local function AeotecSirenCallback(dev_num, result)
DLog("Aeotec Siren node info intercept: peer_dev_num num=", dev_num," result=",result);
end
MonitorZWaveData(false, -- incoming
luup.device, -- peer_dev_num
nil, -- No arm_regex
--[==[
C1
42 12/02/17 21:44:16.481 0x1 0x18 0x0 0x49 0x84 0x27 0x12 0x4 0x10 0x5 0x5e 0x25 0x70 0x85 0x59 0x72 0x2b 0x2c 0x86 0x7a 0x73 0x98 0xef 0x5a 0x82 0x8c
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
length = 24 -------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Request -----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
FUNC_ID_ZW_APPLICATION_UPDATE ----------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Update state = Node Info received -------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Node ID: 39 Unknown node ID: 39 --------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Node info length = 18 -------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Basic type = Routing slave -----------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Generic type = switch binary ----------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Specific type = Siren --------------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[1] = COMMAND_CLASS_ZWAVEPLUS_INFO ---------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[2] = COMMAND_CLASS_SWITCH_BINARY ---------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[3] = COMMAND_CLASS_CONFIGURATION --------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[4] = COMMAND_CLASS_ASSOCIATION ---------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[5] = COMMAND_CLASS_ASSOCIATION_GRP_INFO -----------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[6] = COMMAND_CLASS_MANUFACTURER_SPECIFIC ---------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[7] = COMMAND_CLASS_SCENE_ACTIVATION -------------------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[8] = COMMAND_CLASS_SCENE_ACTUATOR_CONF ---------------------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[9] = COMMAND_CLASS_VERSION --------------------------------------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[10] = COMMAND_CLASS_FIRMWARE_UPDATE_MD -------------------------------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[11] = COMMAND_CLASS_POWERLEVEL --------------------------------------------------------------------------+ ¦ ¦ ¦ ¦ ¦
Can receive command class[12] = COMMAND_CLASS_SECURITY ---------------------------------------------------------------------------------+ ¦ ¦ ¦ ¦
Marker -------------------------------------------------------------------------------------------------------------+ ¦ ¦ ¦
Can send command class[1] = COMMAND_CLASS_DEVICE_RESET_LOCALLY -----------------------------------------------------------------------------------+ ¦ ¦
Can send command class[2] = COMMAND_CLASS_HAIL --------------------------------------------------------------------------------------------------------+ ¦
Checksum OK ----------------------------------------------------------------------------------------------------------------------------+
--]==]
"^01 18 00 49 84 (..) 12 04 10 05 5e 25 70 85 59 72 2b 2c 86 7a 73 98 ef 5a 82 ..", -- Main RegEx
--[==[
42 12/02/17 21:44:16.481 0x1 0x17 0x0 0x49 0x84 0x27 0x11 0x4 0x10 0x5 0x5e 0x25 0x70 0x85 0x59 0x72 0x2b 0x2c 0x86 0x7a 0x73 0xef 0x5a 0x82 0x8c
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
length = 23 -------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Request -----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
FUNC_ID_ZW_APPLICATION_UPDATE ----------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Update state = Node Info received -------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Node ID: 39 Unknown node ID: 39 --------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Node info length = 17 -------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Basic type = Routing slave -----------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Generic type = switch binary ----------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Specific type = Siren --------------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[1] = COMMAND_CLASS_ZWAVEPLUS_INFO ---------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[2] = COMMAND_CLASS_SWITCH_BINARY ---------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[3] = COMMAND_CLASS_CONFIGURATION --------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[4] = COMMAND_CLASS_ASSOCIATION ---------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[5] = COMMAND_CLASS_ASSOCIATION_GRP_INFO -----------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[6] = COMMAND_CLASS_MANUFACTURER_SPECIFIC ---------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[7] = COMMAND_CLASS_SCENE_ACTIVATION -------------------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[8] = COMMAND_CLASS_SCENE_ACTUATOR_CONF ---------------------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[9] = COMMAND_CLASS_VERSION --------------------------------------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦
Can receive command class[10] = COMMAND_CLASS_FIRMWARE_UPDATE_MD -------------------------------------------------------------+ ¦ ¦ ¦ ¦ ¦
Can receive command class[11] = COMMAND_CLASS_POWERLEVEL --------------------------------------------------------------------------+ ¦ ¦ ¦ ¦
Marker --------------------------------------------------------------------------------------------------------+ ¦ ¦ ¦
Can send command class[1] = COMMAND_CLASS_DEVICE_RESET_LOCALLY ------------------------------------------------------------------------------+ ¦ ¦
Can send command class[2] = COMMAND_CLASS_HAIL ---------------------------------------------------------------------------------------------------+ ¦
Checksum OK -----------------------------------------------------------------------------------------------------------------------+
--]==]
"01 17 00 49 84 \\1 11 04 10 05 5e 25 70 85 59 72 2b 2c 86 7a 73 ef 5a 82 XX", -- Response
AeotecSirenCallback,
false, -- Not OneShot
0, -- no timeout
"AeotecSirenNodeInfo", -- label
true) -- forward
end
-- This is a hack for UI7 1.7.2608 getting confused by inconsistent node info reports from the Kichler 12387 undercabinet light controller.
-- Vera also does not like devices that don't support COMMAND_CLASS_VERSION so we add it to the command class list and intercept the expected
-- version and command class version queries.
local function ApplyKichler12387Hack(device_num, node_id)
DEntry()
local function Kichler12387NodeInfoCallback(peer_dev_num, result)
DLog("Kichler 12387 node info intercept: device num=".. device_num.." node_id="..node_id.. "result=".. tableToString(result));
end
local function Kichler12387VersionCallback(peer_dev_num, result)
DLog("Kichler 12387 Version intercept: device num=".. device_num.." node_id="..node_id.. "result=".. tableToString(result));
end
local function Kichler12387CommandClassVersionCallback(peer_dev_num, result)
DLog("Kichler 12387 Version intercept: device num=".. device_num.." node_id="..node_id.. "result=".. tableToString(result));
end
MonitorZWaveData(true, -- outgoing,
luup.device, -- peer_dev_num
nil, -- No arm_regex
--[==[
41 04/02/17 23:01:39.675 0x1 0x4 0x0 0x60 0x60 0xfb (###``#)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦
length = 4 ------+ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦
FUNC_ID_ZW_REQUEST_NODE_INFO ---------------+ ¦ ¦
Node: 96 Device 204=UD17F Breakfast undercabinet lights + ¦
Checksum OK -------------------------+--]==]
"^01 04 00 60 " .. string.format("%02X", node_id) .. " ..", -- Main RegEx
--[==[
42 04/02/17 23:01:39.700 0x6 0x1 0x4 0x1 0x60 0x1 0x9b (####`##)
ACK - Acknowledge --+ ¦ ¦ ¦ ¦ ¦ ¦
SOF - Start Of Frame ------+ ¦ ¦ ¦ ¦ ¦
length = 4 ----------+ ¦ ¦ ¦ ¦
Response --------------+ ¦ ¦ ¦
FUNC_ID_ZW_REQUEST_NODE_INFO -------------------+ ¦ ¦
Result = Success -----------------------+ ¦
Checksum OK ----------------------------+
42 04/02/17 23:01:39.700 got expected ACK
41 04/02/17 23:01:39.700 ACK: 0x6 (#)
42 04/02/17 23:01:39.737 0x1 0xc 0x0 0x49 0x84 0x60 0x7 0x2 0x11 0x0 0x72 0x85 0x26 0x86 0x99 (###I#`####r#&#)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
length = 12 ------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
FUNC_ID_ZW_APPLICATION_UPDATE ---------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Update state = Node Info received --------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Node ID: 96 Device 204=UD17F Breakfast undercabinet lights + ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Node info length = 6 -----------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Basic type = Static Controller ---------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Generic type = switch multilevel --------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦
Specific type = Not used ------------------------------------------+ ¦ ¦ ¦ ¦ ¦
Can receive command class[1] = COMMAND_CLASS_MANUFACTURER_SPECIFIC --------------+ ¦ ¦ ¦ ¦
Can receive command class[2] = COMMAND_CLASS_ASSOCIATION -----------------------------+ ¦ ¦ ¦
Can receive command class[3] = COMMAND_CLASS_SWITCH_MULTILEVEL ----------------------------+ ¦ ¦
Can receive command class[3] = COMMAND_CLASS_VERSION (fake) ------------------------------------+ ¦
Checksum OK -------------------------------------------------------------------+
--]==]
"06 01 04 01 60 01 XX 01 0C 00 49 84 " .. string.format("%02X", node_id) .. " 07 02 11 00 72 85 26 86 XX", -- Autoresponse,
Kichler12387NodeInfoCallback,
false, -- Not OneShot
0, -- no timeout
"Kichler12387NodeInfo", -- label
false) -- no forward
MonitorZWaveData(true, -- outgoing,
luup.device, -- peer_dev_num
nil, -- No arm_regex
--[==[
41 07/17/17 7:52:58.995 0x1 0x9 0x0 0x13 0x40 0x2 0x86 0x11 0x25 0x5 0x10 (####@###%##)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
length = 9 ------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
FUNC_ID_ZW_SEND_DATA ---------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Device 175=SD17-2 Breakfast workspace light --------+ ¦ ¦ ¦ ¦ ¦ ¦
Data length = 2 ------------------------+ ¦ ¦ ¦ ¦ ¦
COMMAND_CLASS_VERSION -----------------------------+ ¦ ¦ ¦ ¦
VERSION_GET ----------------------------------+ ¦ ¦ ¦
Xmit options = ACK | AUTO_ROUTE | Reserved bits : 0x20 ----------------+ ¦ ¦
Callback = 5 -------------------------------------------+ ¦
Checksum OK ------------------------------------------------+
--]==]
"^01 09 00 13 " .. string.format("%02X", node_id) .. " 02 86 11 .. (..)", -- Main RegEx
--[==[
42 07/17/17 7:52:59.027 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 07/17/17 23:51:36.201 0x1 0x5 0x0 0x13 0x05 0x0 0x9d (####t##)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦
length = 5 ------+ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦
FUNC_ID_ZW_SEND_DATA ---------------+ ¦ ¦ ¦
Callback = 5 --------------------+ ¦ ¦
TRANSMIT_COMPLETE_OK ------------------------+ ¦
Checksum OK -----------------------------+
41 07/17/17 23:51:36.201 ACK: 0x6 (#)
42 07/17/17 7:52:59.060 0x1 0xd 0x0 0x4 0x0 0x40 0x7 0x86 0x12 0x6 0x3 0x2a 0x5 0x29 0x26 (#\r###@#####*#)&)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
length = 13 ------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
FUNC_ID_APPLICATION_COMMAND_HANDLER ----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Receive Status SINGLE ------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Device 175=SD17-2 Breakfast workspace light -----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Data length = 7 ---------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
COMMAND_CLASS_VERSION --------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦
VERSION_REPORT -------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦
Z-Wave Library Type = SLAVE_ROUTING -------------------------------------+ ¦ ¦ ¦ ¦ ¦
Z-Wave Protocol Version = 3 -------------------------------------------------+ ¦ ¦ ¦ ¦
Z-Wave Protocol Sub-Version = 42 -------------------------------------------------+ ¦ ¦ ¦
Application Version = 5 ------------------------------------------------------+ ¦ ¦
Application Sub-Version = 41 -----------------------------------------------------------+ ¦
Checksum OK ----------------------------------------------------------------+
41 07/17/17 7:52:59.061 ACK: 0x6 (#)
--]==]
"06 01 04 01 13 01 XX 01 04 00 13 \\1 00 XX 01 0D 00 04 00 " .. string.format("%02X", node_id) .. " 07 86 12 06 03 2A 99 99 XX", -- Autoresponse,
Kichler12387VersionCallback,
false, -- Not OneShot
0, -- no timeout
"Kichler12387Version", -- label
false) -- no forward
MonitorZWaveData(true, -- outgoing,
luup.device, -- peer_dev_num
nil, -- No arm_regex
--[==[
41 07/17/17 7:52:59.260 0x1 0xa 0x0 0x13 0x40 0x3 0x86 0x13 0x26 0x5 0x6 0x15 (#\n##@###&###)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
length = 10 ------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
FUNC_ID_ZW_SEND_DATA ---------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Device 175=SD17-2 Breakfast workspace light --------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Data length = 3 ------------------------+ ¦ ¦ ¦ ¦ ¦ ¦
COMMAND_CLASS_VERSION -----------------------------+ ¦ ¦ ¦ ¦ ¦
VERSION_COMMAND_CLASS_GET ----------------------------------+ ¦ ¦ ¦ ¦
Requested Command Class = COMMAND_CLASS_SWITCH_MULTILEVEL -------------+ ¦ ¦ ¦
Xmit options = ACK | AUTO_ROUTE -------------------------------------------+ ¦ ¦
Callback = 6 -----------------------------------------------+ ¦
Checksum OK ----------------------------------------------------+
--]==]
"^01 0A 00 13 " .. string.format("%02X", node_id) .. " 03 86 13 (..) .. (..) ..", -- Main RegEx
--[==[
42 07/17/17 7:52:59.306 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 07/17/17 7:52:59.307 ACK: 0x6 (#)
42 07/17/17 23:51:36.660 0x1 0x5 0x0 0x13 0x06 0x0 0x9c (####u##)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦
length = 5 ------+ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦
FUNC_ID_ZW_SEND_DATA ---------------+ ¦ ¦ ¦
Callback = 6 --------------------+ ¦ ¦
TRANSMIT_COMPLETE_OK ------------------------+ ¦
Checksum OK -----------------------------+
41 07/17/17 23:51:36.660 ACK: 0x6 (#) 42
07/17/17 7:52:59.339 0x1 0xa 0x0 0x4 0x0 0x40 0x4 0x86 0x14 0x26 0x1 0x0 (#\n###@###&##)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
length = 10 ------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
FUNC_ID_APPLICATION_COMMAND_HANDLER ----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Receive Status SINGLE ------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Device 175=SD17-2 Breakfast workspace light -----------+ ¦ ¦ ¦ ¦ ¦ ¦
Data length = 4 ---------------------------+ ¦ ¦ ¦ ¦ ¦
COMMAND_CLASS_VERSION --------------------------------+ ¦ ¦ ¦ ¦
VERSION_COMMAND_CLASS_REPORT -------------------------------------+ ¦ ¦ ¦
Requested Command Class = COMMAND_CLASS_SWITCH_MULTILEVEL ----------------+ ¦ ¦
Command CLass Version = 1 ----------------------------------------------+ ¦
Checksum OK --------------------------------------------------+
41 07/17/17 7:52:59.340 ACK: 0x6 (#)
--]==]
"06 01 04 01 13 01 XX 01 05 00 13 \\2 00 XX 01 0A 00 04 00 " .. string.format("%02X", node_id) .. " 04 86 14 \\1 01 XX", -- Autoresponse,
Kichler12387CommandClassVersionCallback,
false, -- Not OneShot
0, -- no timeout
"Kichler12387CommandClassVersion", -- label
false) -- no forward
end
-- This is a hack for UI7 1.7.2608 mishandling of the Shlage BE469 lock. It is incorrectly sending a Command Cleass Version, Version Command Class Get in non-secure mode.
local function ApplySchageLockHack(device_num, node_id)
DEntry()
local function ShlageLockVersionCallback(peer_dev_num, result)
DLog("Shlage lock version intercept: device num=".. device_num.." node_id="..node_id.. "result=".. tableToString(result));
end
MonitorZWaveData(true, -- outgoing,
luup.device, -- peer_dev_num
nil, -- No arm_regex
--[==[
C1 C2
41 04/02/17 15:21:37.647 0x1 0xa 0x0 0x13 0xba 0x3 0x86 0x13 0x71 0x5 0xc7 0x79 (#\n######q##y)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
length = 10 ------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
FUNC_ID_ZW_SEND_DATA ---------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Device 548=Front Door Lock --------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Data length = 3 ------------------------+ ¦ ¦ ¦ ¦ ¦ ¦
COMMAND_CLASS_VERSION -----------------------------+ ¦ ¦ ¦ ¦ ¦
VERSION_COMMAND_CLASS_GET ----------------------------------+ ¦ ¦ ¦ ¦
Requested Command Class = COMMAND_CLASS_ALARM -------------------------+ ¦ ¦ ¦
Xmit options = ACK | AUTO_ROUTE -------------------------------------------+ ¦ ¦
Callback = 199 ------------------------------------------------+ ¦
Checksum OK -----------------------------------------------------+
--]==]
"^01 .. 00 (..) " .. string.format("%02X", node_id) .. " 03 86 13 71 .. (..) ..", -- Main RegEx
--[==[
42 04/02/17 15:21:37.331 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 04/02/17 15:21:37.331 got expected ACK
41 04/02/17 15:21:37.332 ACK: 0x6 (#)
42 04/02/17 15:21:37.409 0x1 0x5 0x0 0x13 0xc6 0x0 0x2f (######/)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦
length = 5 ------+ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦
FUNC_ID_ZW_SEND_DATA ---------------+ ¦ ¦ ¦
Callback = 198 --------------------+ ¦ ¦
TRANSMIT_COMPLETE_OK ------------------------+ ¦
Checksum OK -----------------------------+
41 04/02/17 15:21:37.410 ACK: 0x6 (#)
42 04/02/17 15:21:37.631 0x1 0xa 0x0 0x4 0x0 0xba 0x4 0x86 0x14 0x71 0x1 0xbd
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
length = 10 ------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
FUNC_ID_APPLICATION_COMMAND_HANDLER ----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Receive Status SINGLE ------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Device 548=Front Door Lock -----------------------+ ¦ ¦ ¦ ¦ ¦ ¦
Data length = 4 ---------------------------+ ¦ ¦ ¦ ¦ ¦
COMMAND_CLASS_VERSION --------------------------------+ ¦ ¦ ¦ ¦
VERSION_COMMAND_CLASS_REPORT -------------------------------------+ ¦ ¦ ¦
Requested Command Class = COMMAND_CLASS_ALARM ---------------------------+ ¦ ¦
Version = 1 ----------------------------------------------+ ¦
Checksum OK ---------------------------------------------------+
--]==]
"06 01 04 01 \\1 01 XX 01 05 00 \\1 \\2 00 XX 01 0A 00 04 00 " .. string.format("%02X", node_id) .. " 04 86 14 71 01 XX", -- Autoresponse,
ShlageLockVersionCallback,
false, -- Not OneShot
0, -- no timeout
"ShlageLockVersion", -- label
false) -- no forward
end
local function ApplyLuaUPnPAutoRouteNoACKFix()
local function AutoRoutNoAckCallback(peer_dev_num, result)
DLog("AutoRouteNoAckk Callback: peer_dev_num=".. peer_dev_num.." result=".. tableToString(result));
end
MonitorZWaveData(true, -- outgoing,
luup.device, -- peer_dev_num
nil, -- No arm_regex
--[==[
41 11/24/17 21:25:33.043 0x1 0xa 0x0 0x13 0xc 0x3 0x25 0x1 0x0 0x4 0x37 0xfe (#\n####%###7#)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
length = 10 ------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
FUNC_ID_ZW_SEND_DATA ---------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Device 5=Leviton Combo Switch -------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Data length = 3 -----------------------+ ¦ ¦ ¦ ¦ ¦ ¦
COMMAND_CLASS_SWITCH_BINARY ----------------------------+ ¦ ¦ ¦ ¦ ¦
SWITCH_BINARY_SET --------------------------------+ ¦ ¦ ¦ ¦
Value = OFF ------------------------------------+ ¦ ¦ ¦
Xmit options = AUTO_ROUTE ----------------------------------------+ ¦ ¦
Callback = 55 ---------------------------------------------+ ¦
Checksum OK --------------------------------------------------+
--]==]
"^01 .. 00 13 .+ 04 (..) ..$", -- Main RegEx
--[==[
42 11/24/17 21:25:33.086 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/24/17 21:25:33.087 got expected ACK
41 11/24/17 21:25:33.087 ACK: 0x6 (#)
42 11/24/17 21:25:33.127 0x1 0x7 0x0 0x13 0x37 0x0 0x0 0x1 0xdd (####7####)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ +-----+ ¦
length = 7 ------+ ¦ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦ ¦
FUNC_ID_ZW_SEND_DATA ---------------+ ¦ ¦ ¦ ¦
Callback = 55 --------------------+ ¦ ¦ ¦
TRANSMIT_COMPLETE_OK ------------------------+ ¦ ¦
Tx Time = 1 ms -----------------------------+ ¦
Checksum OK -------------------------------------+
41 11/24/17 21:25:33.128 ACK: 0x6 (#)
--]==]
"06 01 04 01 13 01 XX 01 07 00 13 \\1 00 00 00 XX", -- Autoresponse,
nil, -- AutoRoutNoAckCallback,
false, -- Not OneShot
0, -- no timeout
"AutoRouteNoAck", -- label
false) -- no forward
end
for device_num, device in pairs(luup.devices) do
if device.device_type == "urn:schemas-gengen_mcv-org:device:SceneControllerEvolveLCD:1" then
local impl = luup.attr_get("impl_file", device_num)
if impl == "I_EvolveLCD1.xml" then
reload_needed = "I_EvolveLCD1.xml"
log("Updating the implementation file of the existing Evolve LCD1 peer device: ", device_num)
luup.attr_set("impl_file", "I_GenGenSceneController.xml", device_num);
end
elseif device.device_type == "urn:schemas-gengen_mcv-org:device:SceneControllerCooperRFWC5:1" then
local impl = luup.attr_get("impl_file", device_num)
if impl == "I_CooperRFWC5.xml" then
reload_needed = "I_CooperRFWC5.xml"
log("Updating the implementation file of the existing Cooper RFWC5 peer device: ", device_num)
luup.attr_set("impl_file", "I_GenGenSceneController.xml", device_num);
end
elseif device.device_num_parent and
luup.devices[device.device_num_parent] and
luup.devices[device.device_num_parent].device_type == "urn:schemas-micasaverde-com:device:ZWaveNetwork:1" then
local manufacturer_info = luup.variable_get("urn:micasaverde-com:serviceId:ZWaveDevice1", "ManufacturerInfo", device_num)
local capabilities = luup.variable_get("urn:micasaverde-com:serviceId:ZWaveDevice1", "Capabilities", device_num)
DLog("device_num=",device_num," name=",device.description," manufacturer_info=",manufacturer_info," capabilities=",capabilities);
if manufacturer_info == "275,17750,19506" then
if device.device_type ~= 'urn:schemas-gengen_mcv-org:device:SceneControllerEvolveLCD:1' then
AdoptEvolveLCD1(device_num)
reload_needed = "Evolve LCD1 adopted"
end
elseif manufacturer_info == "26,22349,0" then
if device.device_type ~= "urn:schemas-gengen_mcv-org:device:SceneControllerCooperRFWC5:1" then
AdoptCooperRFWC5(device_num)
reload_needed = "Cooper RFWC5 adopted"
end
elseif manufacturer_info == "376,21315,18229" then
if device.device_type ~="urn:schemas-gengen_mcv-org:device:SceneControllerNexiaOneTouch:1" then
AdoptNexiaOneTouch(device_num)
reload_needed = "Nexia One Touch adopted"
end
elseif manufacturer_info == "59,25409,20548" or capabilities == "83,220,0,4,64,3,R,B,RS,W1,|32S,34,93S,98S,99S,112S,113S,114,122,128S,133S,134,152," then
ApplySchageLockHack(device_num, device.id)
elseif capabilities == "146,150,0,2,17,0,L,B,|38,114,133," then
ApplyKichler12387Hack(device_num, device.id)
end
end
end -- for device_num
local function NexiaManufacturerCallback(peer_dev_num, result)
DEntry()
local time = tonumber(result.time)
local receiveStatus = tonumber(result.C1, 16)
local node_id = tonumber(result.C2, 16)
local device_num = NodeIdToDeviceNumber(node_id)
DEntry("NexiaManufacturerCallback")
if device_num and CheckDups(device_num, time, receiveStatus, "72050178534347359e"..result.C2) then
local device = luup.devices[device_num]
if device and device.device_type ~= "urn:schemas-gengen_mcv-org:device:SceneControllerNexiaOneTouch:1" then
AdoptNexiaOneTouch(device_num)
log("Nexia One Touch adopted. Reloading LuaUPnP.")
luup.call_action(HAG_SID, "Reload", {}, 0)
end
end
end
-- The Nexia One Touch may show up as a "Generic IO" device if it was included before the plug-in was installed
-- because UI7 gets confused by the devices's response to the COMMAND_CLASS_ASSOCIATION_GRP_INFO/ASSOCIATION_GROUP_INFO_GET command
--[==[
C1 C2
42 02/25/17 15:55:45.857 0x1 0xe 0x0 0x4 0x0 0xf 0x8 0x72 0x5 0x1 0x78 0x53 0x43 0x47 0x35 0x9e (#######r##xSCG5#)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ +------+ +-------+ +-------+ ¦
length = 14 ------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Request ----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
FUNC_ID_APPLICATION_COMMAND_HANDLER ----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Receive Status SINGLE ------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Device 10=_Generic IO ----------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Data length = 8 --------------------------+ ¦ ¦ ¦ ¦ ¦ ¦
COMMAND_CLASS_MANUFACTURER_SPECIFIC ---------------------------+ ¦ ¦ ¦ ¦ ¦
MANUFACTURER_SPECIFIC_REPORT -----------------------------------+ ¦ ¦ ¦ ¦
Manufacturer Id = Nexia (376) ----------------------------------------+ ¦ ¦ ¦
Product Type Id = 0x5343 --------------------------------------------------+ ¦ ¦
Procuct Id = 0x4735 ------------------------------------------------------------+ ¦
Checksum OK ---------------------------------------------------------------------+
--]==]
MonitorZWaveData(false, -- incoming,
luup.device, -- peer_dev_num
nil, -- No arm_regex
"^01 .. 00 04 (..) (..) .. 72 05 01 78 53 43 47 35", -- Main RegEx
nil, -- no response,
NexiaManufacturerCallback,
false, -- Not OneShot
0, -- no timeout
"NexiaManufacturer", -- label
false ) -- not forward
if luup.version_major < 7 then -- UI5 only.
-- In response to a Version Get command, the Nexisa One-Touch returns a Z-Wave protocol version 4, sub-version 32
-- which is not even in the official Z-Wave version list and certainly confuses UI5. We create a forwarding monitor
-- which returns a (false) version which at least UI5 can handle.
--[==[ C1 C2 C3 C4 C5 C6 C7
42 03/04/17 14:19:17.494 0x1 0x11 0x0 0x4 0x0 0xf 0xb 0x86 0x12 0x6 0x4 0x20 0x1 0x0 0x1 0x1 0x1 0x1a 0x42 (########### ######B)
SOF - Start Of Frame --+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ +--------------+ ¦
length = 17 -------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Request -----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
FUNC_ID_APPLICATION_COMMAND_HANDLER -----------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Receive Status SINGLE -------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Device 49=_Generic IO -----------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Data length = 11 ---------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
COMMAND_CLASS_VERSION --------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
VERSION_REPORT -------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦ ¦
Z-Wave Library Type = SLAVE_ROUTING -------------------------------------+ ¦ ¦ ¦ ¦ ¦ ¦
Z-Wave Protocol Version = 4 -------------------------------------------------+ ¦ ¦ ¦ ¦ ¦
Z-Wave Protocol Sub-Version = 32 -------------------------------------------------+ ¦ ¦ ¦ ¦
Application Version = 1 ------------------------------------------------------+ ¦ ¦ ¦
Application Sub-Version = 0 ----------------------------------------------------------+ ¦ ¦
?data? -------------------------------------------------------------------+ ¦
Checksum OK --------------------------------------------------------------------------------+
convert version 4, subversion 32 to version 3, subversion 28 (Z-Wave 5.03.00)
--]==]
local function NexiaVersionCallback(peer_dev_num, result)
DEntry("NexiaVersionCallback")
end
MonitorZWaveData(false, -- incoming,
luup.device, -- peer_dev_num
nil, -- No arm_regex
"^01 (..) 00 04 (..) (..) (..) 86 12 06 04 (..) (..) (..)", -- Main RegEx
"01 0D 00 04 \\2 \\3 07 86 12 06 03 1C \\6 \\7 XX", -- Forwarded response,
NexiaVersionCallback,
false, -- Not OneShot
0, -- no timeout
"NexiaVersion", -- label
true) -- forward
end
-- Apply the Aeotec Siren hack to anything that responds with that exact node info.
ApplyAeotecSirenHack()
-- UI7 sometimes sends Z-Wave commands twice with xmit option AUTO_ROUTE and then again with ACK | AURO_ROUTE
-- Only the second of these is valid.
ApplyLuaUPnPAutoRouteNoACKFix()
end
-- returns first, updated
-- First is true if we are the lowest device number installer
-- updated is true if the installer has been updated since the last execution.
function IsFirstAndLatestInstallerVersion(our_dev_num, our_version)
DEntry()
local version = 0;
local count = 0;
local our_index = 0;
local sorted = {}
local ourVerStr = luup.variable_get(GENGENINSTALLER_SID, "Version", our_dev_num)
local updated = not ourVerStr or tonumber(ourVerStr) ~= our_version
if updated then
luup.variable_set(GENGENINSTALLER_SID, "Version", our_version, our_dev_num)
end
for dev_num, v in pairs(luup.devices) do
table.insert(sorted,dev_num)
end
table.sort(sorted)
for i = 1, #sorted do
local dev_num = sorted[i];
if dev_num == our_dev_num then
our_index = i
end
if luup.devices[dev_num].device_type == GENGENINSTALLER_DEVTYPE then
local verStr = luup.variable_get(GENGENINSTALLER_SID, "Version", dev_num)
local ver = tonumber(verStr)
if ver then
if our_index == 0 then
return false, false -- We found another installer device before we found us.
end
end
end
end
return true, updated
end
function DeleteOldInstallers(our_dev_num)
DEntry()
for dev_num, v in pairs(luup.devices) do
if dev_num ~= our_dev_num and
(v.device_type == "urn:schemas-gengen_mcv-org:device:SceneControllerEvolveLCD1Installer:1" or
v.device_type == "urn:schemas-gengen_mcv-org:device:SceneControllerEvolveLCDFinder:1" or
v.device_type == "urn:schemas-gengen_mcv-org:device:SceneControllerCooperRFWC5Installer:1") then
log("Removing older installer: device ID ", dev_num)
luup.call_action(HAG_SID,"DeleteDevice", {DeviceNum = dev_num}, 0);
-- Delete only one at a time. We will reload the luup engine for more.
return true
end
end
return false
end
local nixio = require("nixio")
function SceneControllerInstaller_Init(lul_device)
-- First, delete any stale global lock. Note that there may be a race condition
-- here if another device just took it but we will live with that.
give_global_lock()
-- Now, make sure that we are the latest version of this installer
-- And if there is more than one of us, that we are the lowest numbered device.
-- Otherwise delete ourselves.
local first, updated = IsFirstAndLatestInstallerVersion(lul_device, GenGenInstaller_Version)
if not first then
log("Removing superfluous installer: device ID ", lul_device)
luup.call_action(HAG_SID,"DeleteDevice", {DeviceNum = lul_device}, 0);
return
end
-- Now look for older installers with different names and delete them one at a time
if DeleteOldInstallers(lul_device) then
log("Older installer deleted. Reloading LuaUPnP.")
luup.call_action(HAG_SID, "Reload", {}, 0)
return
end
luup.attr_set("invisible","1",lul_device)
if luup.job_watch then
luup.job_watch("SceneController_JobWatchCallBack") -- Watch jobs on all devices.
else
DLog("luup.job_watch does not exist")
end
function b642bin(str)
return nixio.bin.b64decode(string.gsub(str, "%s+", ""))
end
-- The custom icons gets written to different places depending on UI5 or UI7
local EvolveLCD1Icon = b642bin([[
iVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAYAAAA6oTAqAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
jwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAsBJREFU
aEPtmr9LG2EYx+MQcBSyZnB0lC6uDgr+DV20i3Mnl4LGQQKCZGnToUOGzmKhUB3EBAKJBSFOPapD
CA5XqBDokKhp+PZ9bAPXu/d673vvj7ymeeEhkNy993zueZ7v8957mclwRjabxerqSmZp6Rnv57F+
53lXmcPDD5nBYDAj5Mj6+nOcnLyG71dwe/vRGfP99zg7e4PNzRcQAqGDSqV99HqfAPxk5tbo9U5B
/knBPDx8dYvijzfk1xTGxdBMIzOtGQt5qSXNhsMhut2ustE8KkMLTKfTQf28jsZlI7XR+TSPytAC
0263cf79Ghf4kdqa376A5lEZ2mA+d28YCFIb3YwITL8PrK2BtfS/bWeHy2wEplAoPEIlfQbhuTDV
KrC8HHWc4DjDCIwIyAh0BOQsTFJEwiAExIVhConFxWialUp2IyNbP1wYSTUwlmbaYHwfoNoJGgmD
jZoRTTGhmiEQSjMSgaCRwpmGkQUJAjkpALJAqdRsfv4JRoZc3tiIqtnRkXkY2aJPbJoTp2atFkDL
l6BR/zEtAME7nVQ74ShyBYAWnqRmYRj6zibMv5Y0vHR0Us1GjmqJTLP5OzLhpmlDzcJ3PA5IODKU
SsVitGkSnO00k1G3/2NtVqlEI0MKZzMySTUjtDYjp3k1MzdnD0YWJPZ5ZqKeND0PWFiI9plxqJkW
AaDohJtmzC6O+w9nEuszIzDaaiauzxwf2xMAbbszcSuA2Vl7MNoiM1FqRoVOyhXeAxjHqlmLmhFQ
eKFp+nmmfsneArTZW4CURuc7sXHeZ/tY5Iiq0TwqQ4s0qzig89wpzES+oK3Vao9ZEvepM4VE5lJO
M5eAlGFE7pitY1LB3N01bPkndZ37+5bcH4G2tl7C896yi5wyk+nxpo+tsj73Dru7r8T/opXL5bC3
t41yueycHRwUkc/nuTC/AJpOW5HRBwJ9AAAAAElFTkSuQmCC
]])
local CooperRFWC5Icon = b642bin([[
iVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAIAAAC1w6d9AAAAAXNSR0IArs4c
6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUw
AADqYAAAOpgAABdwnLpRPAAAA0ZJREFUWEfNmU1PGlEUhu3GH4D8ja6aELf+
ADfuunHZxDUJanTXNSQmFGsHW7EjDFId0Fqd8v1hIxYC2EZrCLY2MV1oTNqm
0TYm01ennVjRK1wO5Z5MWDBzh4dzzz3nvPfe0XW962b7fmGMB7hvdXd3W61W
1nCQ3WRbW1t2u91ms91tg42NjWmaxvj1LsY9SZIsFouqqklqi0ajbrd7eHiY