node-red-contrib-homebridge-automation 0.3.0-beta.10 → 0.3.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-homebridge-automation",
3
- "version": "0.3.0-beta.10",
3
+ "version": "0.3.0-beta.12",
4
4
  "description": "NodeRED Automation for HomeBridge",
5
5
  "main": "src/HAP-NodeRed.js",
6
6
  "scripts": {
@@ -17,12 +17,12 @@ class HbControlNode extends hbBaseNode {
17
17
  const isCamera = this.hbDevice.type === 'CameraRTPStreamManagement';
18
18
  const payloadType = typeof message.payload;
19
19
 
20
- // Validate payload
20
+ // Is the payload a valid JSON object?
21
+
21
22
  if (!isCamera && payloadType !== 'object') {
22
23
  const validNames = Object.keys(this.hbDevice.values)
23
24
  .filter(key => key !== 'ConfiguredName')
24
25
  .join(', ');
25
-
26
26
  this.error(
27
27
  `Invalid payload. Expected JSON object, e.g., {"On":false, "Brightness":0}. Valid values: ${validNames}`
28
28
  );
@@ -30,6 +30,16 @@ class HbControlNode extends hbBaseNode {
30
30
  return;
31
31
  }
32
32
 
33
+ // Validate payload
34
+ let keysToKeep = Object.keys(this.hbDevice.values);
35
+
36
+ Object.keys(message.payload).forEach(key => {
37
+ if (!keysToKeep.includes(key)) {
38
+ this.handleWarning(`Unhandled Characteristic '${key}'`);
39
+ delete message.payload[key];
40
+ }
41
+ });
42
+
33
43
  const results = [];
34
44
  let fill = 'green';
35
45
 
@@ -50,11 +60,13 @@ class HbControlNode extends hbBaseNode {
50
60
  } else {
51
61
  // Handle other characteristics
52
62
  try {
63
+ // debug('Setting value for', message.payload);
53
64
  const result = await this.hbDevice.setCharacteristicsByTypes(filterIfOff(message.payload));
65
+ // debug('Result', result.values);
54
66
  results.push(result.values);
55
67
  } catch (error) {
56
- this.error(`Failed to set value for "${JSON.stringify(message.payload)}": ${error.message}`);
57
- results.push({ 'Error': `Error: ${error.message}` });
68
+ this.error(`${error.message} for ${JSON.stringify(message.payload)}`);
69
+ results.push({ Error: `${error.message} for ${JSON.stringify(message.payload)}` });
58
70
  fill = 'red';
59
71
  this.hbConfigNode.disconnectClientNodes(this.hbDevice.instance);
60
72
  }
@@ -35,7 +35,7 @@
35
35
  "id": "4138921fd7b9a926",
36
36
  "type": "tab",
37
37
  "label": "Flow 5",
38
- "disabled": true,
38
+ "disabled": false,
39
39
  "info": "",
40
40
  "env": []
41
41
  },
@@ -43,7 +43,7 @@
43
43
  "id": "92f59d974b9c8a86",
44
44
  "type": "tab",
45
45
  "label": "Camera Test",
46
- "disabled": false,
46
+ "disabled": true,
47
47
  "info": "",
48
48
  "env": []
49
49
  },
@@ -54,37 +54,6 @@
54
54
  "macAddress": "",
55
55
  "debug": true
56
56
  },
57
- {
58
- "id": "df5dd49178c517fa",
59
- "type": "mqtt-broker",
60
- "name": "",
61
- "broker": "mqtt.local",
62
- "port": "1883",
63
- "clientid": "",
64
- "autoConnect": true,
65
- "usetls": false,
66
- "protocolVersion": "4",
67
- "keepalive": "60",
68
- "cleansession": true,
69
- "autoUnsubscribe": true,
70
- "birthTopic": "",
71
- "birthQos": "0",
72
- "birthRetain": "false",
73
- "birthPayload": "",
74
- "birthMsg": {},
75
- "closeTopic": "",
76
- "closeQos": "0",
77
- "closeRetain": "false",
78
- "closePayload": "",
79
- "closeMsg": {},
80
- "willTopic": "",
81
- "willQos": "0",
82
- "willRetain": "false",
83
- "willPayload": "",
84
- "willMsg": {},
85
- "userProps": "",
86
- "sessionExpiry": ""
87
- },
88
57
  {
89
58
  "id": "902c5887b6877df6",
90
59
  "type": "debug",
@@ -2629,28 +2598,41 @@
2629
2598
  ]
2630
2599
  },
2631
2600
  {
2632
- "id": "5a0779448d4dcdb3",
2633
- "type": "mqtt in",
2601
+ "id": "50af5bb963e4a186",
2602
+ "type": "hb-resume",
2634
2603
  "z": "4138921fd7b9a926",
2635
- "name": "",
2636
- "topic": "home/#",
2637
- "qos": "2",
2638
- "datatype": "auto-detect",
2639
- "broker": "df5dd49178c517fa",
2640
- "nl": false,
2641
- "rap": true,
2642
- "rh": 0,
2643
- "inputs": 0,
2644
- "x": 130,
2645
- "y": 180,
2604
+ "name": "Floor Lamp One",
2605
+ "Homebridge": "homebridge",
2606
+ "Manufacturer": "Signify Netherlands B.V.",
2607
+ "Service": "Lightbulb",
2608
+ "device": "homebridgeCC:22:3D:E3:CF:33Signify Netherlands B.V.Floor Lamp One00000043",
2609
+ "conf": "7e647d67.f33acc",
2610
+ "x": 500,
2611
+ "y": 80,
2646
2612
  "wires": [
2647
2613
  [
2648
- "4510eba830da4c9d"
2614
+ "8ba7a5a4aa28dc2f",
2615
+ "29580d01ef2e651d"
2649
2616
  ]
2650
2617
  ]
2651
2618
  },
2652
2619
  {
2653
- "id": "d82488396ae950bf",
2620
+ "id": "8ba7a5a4aa28dc2f",
2621
+ "type": "hb-control",
2622
+ "z": "4138921fd7b9a926",
2623
+ "name": "Floor Lamp One",
2624
+ "Homebridge": "homebridge",
2625
+ "Manufacturer": "Signify Netherlands B.V.",
2626
+ "Service": "Lightbulb",
2627
+ "device": "homebridgeCC:22:3D:E3:CF:33Signify Netherlands B.V.Floor Lamp One00000043",
2628
+ "conf": "7e647d67.f33acc",
2629
+ "outputs": 0,
2630
+ "x": 720,
2631
+ "y": 80,
2632
+ "wires": []
2633
+ },
2634
+ {
2635
+ "id": "29580d01ef2e651d",
2654
2636
  "type": "debug",
2655
2637
  "z": "4138921fd7b9a926",
2656
2638
  "name": "debug 17",
@@ -2660,129 +2642,243 @@
2660
2642
  "tostatus": true,
2661
2643
  "complete": "payload",
2662
2644
  "targetType": "msg",
2663
- "statusVal": "device",
2664
- "statusType": "msg",
2645
+ "statusVal": "payload",
2646
+ "statusType": "auto",
2665
2647
  "x": 720,
2666
2648
  "y": 140,
2667
2649
  "wires": []
2668
2650
  },
2669
2651
  {
2670
- "id": "6f6d507ccce7460f",
2671
- "type": "switch",
2652
+ "id": "b3c8e4dcd5b62de4",
2653
+ "type": "inject",
2672
2654
  "z": "4138921fd7b9a926",
2673
2655
  "name": "",
2674
- "property": "shortTopic",
2675
- "propertyType": "msg",
2676
- "rules": [
2656
+ "props": [
2677
2657
  {
2678
- "t": "eq",
2679
- "v": "SYStoMQTT",
2680
- "vt": "str"
2658
+ "p": "payload"
2681
2659
  },
2682
2660
  {
2683
- "t": "eq",
2684
- "v": "version",
2661
+ "p": "topic",
2685
2662
  "vt": "str"
2663
+ }
2664
+ ],
2665
+ "repeat": "",
2666
+ "crontab": "",
2667
+ "once": false,
2668
+ "onceDelay": 0.1,
2669
+ "topic": "",
2670
+ "payload": "{\"On\": true}",
2671
+ "payloadType": "json",
2672
+ "x": 170,
2673
+ "y": 80,
2674
+ "wires": [
2675
+ [
2676
+ "50af5bb963e4a186"
2677
+ ]
2678
+ ]
2679
+ },
2680
+ {
2681
+ "id": "a74ef133a980c5f3",
2682
+ "type": "inject",
2683
+ "z": "4138921fd7b9a926",
2684
+ "name": "",
2685
+ "props": [
2686
+ {
2687
+ "p": "payload"
2686
2688
  },
2687
2689
  {
2688
- "t": "eq",
2689
- "v": "LWT",
2690
+ "p": "topic",
2690
2691
  "vt": "str"
2692
+ }
2693
+ ],
2694
+ "repeat": "",
2695
+ "crontab": "",
2696
+ "once": false,
2697
+ "onceDelay": 0.1,
2698
+ "topic": "",
2699
+ "payload": "{\"On\": false}",
2700
+ "payloadType": "json",
2701
+ "x": 170,
2702
+ "y": 140,
2703
+ "wires": [
2704
+ [
2705
+ "50af5bb963e4a186"
2706
+ ]
2707
+ ]
2708
+ },
2709
+ {
2710
+ "id": "1e6b8797f5279a1f",
2711
+ "type": "inject",
2712
+ "z": "4138921fd7b9a926",
2713
+ "name": "{\"Brightness\":40,\"On\":true,\"ColorTemperature\":242}",
2714
+ "props": [
2715
+ {
2716
+ "p": "payload"
2691
2717
  },
2692
2718
  {
2693
- "t": "else"
2719
+ "p": "topic",
2720
+ "vt": "str"
2694
2721
  }
2695
2722
  ],
2696
- "checkall": "false",
2697
- "repair": false,
2698
- "outputs": 4,
2699
- "x": 530,
2700
- "y": 180,
2723
+ "repeat": "",
2724
+ "crontab": "",
2725
+ "once": false,
2726
+ "onceDelay": 0.1,
2727
+ "topic": "",
2728
+ "payload": "{\"Brightness\":40,\"On\":true,\"ColorTemperature\":242}",
2729
+ "payloadType": "json",
2730
+ "x": 290,
2731
+ "y": 260,
2701
2732
  "wires": [
2702
2733
  [
2703
- "d82488396ae950bf"
2704
- ],
2705
- [],
2706
- [
2707
- "1649c3dc535b26f2"
2708
- ],
2734
+ "50af5bb963e4a186"
2735
+ ]
2736
+ ]
2737
+ },
2738
+ {
2739
+ "id": "4bb2bae9fe4ffbbb",
2740
+ "type": "hb-status",
2741
+ "z": "4138921fd7b9a926",
2742
+ "name": "Floor Lamp One",
2743
+ "Homebridge": "homebridge",
2744
+ "Manufacturer": "Signify Netherlands B.V.",
2745
+ "Service": "Lightbulb",
2746
+ "device": "homebridgeCC:22:3D:E3:CF:33Signify Netherlands B.V.Floor Lamp One00000043",
2747
+ "conf": "7e647d67.f33acc",
2748
+ "x": 300,
2749
+ "y": 440,
2750
+ "wires": [
2709
2751
  [
2710
- "d7a34617ef5e9f31"
2752
+ "96ad615138d1254e"
2711
2753
  ]
2712
2754
  ]
2713
2755
  },
2714
2756
  {
2715
- "id": "45cb1d621afc9b52",
2757
+ "id": "96ad615138d1254e",
2716
2758
  "type": "debug",
2717
2759
  "z": "4138921fd7b9a926",
2718
2760
  "name": "debug 18",
2719
- "active": false,
2761
+ "active": true,
2720
2762
  "tosidebar": true,
2721
2763
  "console": false,
2722
2764
  "tostatus": true,
2723
- "complete": "true",
2724
- "targetType": "full",
2725
- "statusVal": "topic",
2765
+ "complete": "payload",
2766
+ "targetType": "msg",
2767
+ "statusVal": "payload",
2726
2768
  "statusType": "auto",
2727
- "x": 320,
2728
- "y": 360,
2769
+ "x": 520,
2770
+ "y": 400,
2729
2771
  "wires": []
2730
2772
  },
2731
2773
  {
2732
- "id": "4510eba830da4c9d",
2733
- "type": "function",
2774
+ "id": "7b085aa32101811e",
2775
+ "type": "hb-event",
2734
2776
  "z": "4138921fd7b9a926",
2735
- "name": "function 3",
2736
- "func": "const [home, device, shortTopic] = msg.topic.split(\"/\");\nmsg.shortTopic = shortTopic;\nmsg.device = device;\nreturn msg;",
2737
- "outputs": 1,
2738
- "timeout": 0,
2739
- "noerr": 0,
2740
- "initialize": "",
2741
- "finalize": "",
2742
- "libs": [],
2743
- "x": 320,
2744
- "y": 180,
2777
+ "name": "Floor Lamp One",
2778
+ "Homebridge": "homebridge",
2779
+ "Manufacturer": "Signify Netherlands B.V.",
2780
+ "Service": "Lightbulb",
2781
+ "device": "homebridgeCC:22:3D:E3:CF:33Signify Netherlands B.V.Floor Lamp One00000043",
2782
+ "conf": "7e647d67.f33acc",
2783
+ "sendInitialState": true,
2784
+ "x": 300,
2785
+ "y": 360,
2745
2786
  "wires": [
2746
2787
  [
2747
- "6f6d507ccce7460f",
2748
- "45cb1d621afc9b52"
2788
+ "96ad615138d1254e"
2749
2789
  ]
2750
2790
  ]
2751
2791
  },
2752
2792
  {
2753
- "id": "d7a34617ef5e9f31",
2793
+ "id": "247bb4b9017d5ed3",
2794
+ "type": "catch",
2795
+ "z": "4138921fd7b9a926",
2796
+ "name": "",
2797
+ "scope": null,
2798
+ "uncaught": false,
2799
+ "x": 280,
2800
+ "y": 520,
2801
+ "wires": [
2802
+ [
2803
+ "ecfe37f30b4b452f"
2804
+ ]
2805
+ ]
2806
+ },
2807
+ {
2808
+ "id": "ecfe37f30b4b452f",
2754
2809
  "type": "debug",
2755
2810
  "z": "4138921fd7b9a926",
2756
2811
  "name": "debug 19",
2757
- "active": false,
2812
+ "active": true,
2758
2813
  "tosidebar": true,
2759
2814
  "console": false,
2760
2815
  "tostatus": true,
2761
2816
  "complete": "payload",
2762
2817
  "targetType": "msg",
2763
- "statusVal": "shortTopic",
2764
- "statusType": "msg",
2765
- "x": 720,
2766
- "y": 260,
2818
+ "statusVal": "payload",
2819
+ "statusType": "auto",
2820
+ "x": 540,
2821
+ "y": 520,
2767
2822
  "wires": []
2768
2823
  },
2769
2824
  {
2770
- "id": "1649c3dc535b26f2",
2825
+ "id": "f775ab948cea1532",
2826
+ "type": "status",
2827
+ "z": "4138921fd7b9a926",
2828
+ "name": "",
2829
+ "scope": null,
2830
+ "x": 280,
2831
+ "y": 580,
2832
+ "wires": [
2833
+ []
2834
+ ]
2835
+ },
2836
+ {
2837
+ "id": "dd3e9950ef4f1482",
2771
2838
  "type": "debug",
2772
2839
  "z": "4138921fd7b9a926",
2773
2840
  "name": "debug 20",
2774
- "active": false,
2841
+ "active": true,
2775
2842
  "tosidebar": true,
2776
2843
  "console": false,
2777
2844
  "tostatus": true,
2778
- "complete": "payload",
2779
- "targetType": "msg",
2780
- "statusVal": "device",
2781
- "statusType": "msg",
2782
- "x": 720,
2783
- "y": 200,
2845
+ "complete": "true",
2846
+ "targetType": "full",
2847
+ "statusVal": "payload",
2848
+ "statusType": "auto",
2849
+ "x": 540,
2850
+ "y": 580,
2784
2851
  "wires": []
2785
2852
  },
2853
+ {
2854
+ "id": "64d1e3d573689b65",
2855
+ "type": "inject",
2856
+ "z": "4138921fd7b9a926",
2857
+ "name": "",
2858
+ "props": [
2859
+ {
2860
+ "p": "payload"
2861
+ },
2862
+ {
2863
+ "p": "topic",
2864
+ "vt": "str"
2865
+ }
2866
+ ],
2867
+ "repeat": "",
2868
+ "crontab": "",
2869
+ "once": false,
2870
+ "onceDelay": 0.1,
2871
+ "topic": "",
2872
+ "payload": "{\"ColorTemperature\": false}",
2873
+ "payloadType": "json",
2874
+ "x": 150,
2875
+ "y": 200,
2876
+ "wires": [
2877
+ [
2878
+ "8ba7a5a4aa28dc2f"
2879
+ ]
2880
+ ]
2881
+ },
2786
2882
  {
2787
2883
  "id": "6df154716efd4949",
2788
2884
  "type": "hb-event",