node-red-contrib-samsung-smartthings 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,189 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean any work of authorship, including
48
+ the original version of the Work and any modifications or additions
49
+ to that Work or Derivative Works thereof, that is intentionally
50
+ submitted to the Licensor for inclusion in the Work by the copyright owner
51
+ or by an individual or Legal Entity authorized to submit on behalf of
52
+ the copyright owner. For the purposes of this definition, "submitted"
53
+ means any form of electronic, verbal, or written communication sent
54
+ to the Licensor or its representatives, including but not limited to
55
+ communication on electronic mailing lists, source code control systems,
56
+ and issue tracking systems that are managed by, or on behalf of, the
57
+ Licensor for the purpose of discussing and improving the Work, but
58
+ excluding communication that is conspicuously marked or otherwise
59
+ designated in writing by the copyright owner as "Not a Contribution."
60
+
61
+ "Contributor" shall mean Licensor and any individual or Legal Entity
62
+ on behalf of whom a Contribution has been received by the Licensor and
63
+ subsequently incorporated within the Work.
64
+
65
+ 2. Grant of Copyright License. Subject to the terms and conditions of
66
+ this License, each Contributor hereby grants to You a perpetual,
67
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
68
+ copyright license to reproduce, prepare Derivative Works of,
69
+ publicly display, publicly perform, sublicense, and distribute the
70
+ Work and such Derivative Works in Source or Object form.
71
+
72
+ 3. Grant of Patent License. Subject to the terms and conditions of
73
+ this License, each Contributor hereby grants to You a perpetual,
74
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
75
+ (except as stated in this section) patent license to make, have made,
76
+ use, offer to sell, sell, import, and otherwise transfer the Work,
77
+ where such license applies only to those patent claims licensable
78
+ by such Contributor that are necessarily infringed by their
79
+ Contribution(s) alone or by combination of their Contribution(s)
80
+ with the Work to which such Contribution(s) was submitted. If You
81
+ institute patent litigation against any entity (including a
82
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
83
+ or a Contribution incorporated within the Work constitutes direct
84
+ or contributory patent infringement, then any patent licenses
85
+ granted to You under this License for that Work shall terminate
86
+ as of the date such litigation is filed.
87
+
88
+ 4. Redistribution. You may reproduce and distribute copies of the
89
+ Work or Derivative Works thereof in any medium, with or without
90
+ modifications, and in Source or Object form, provided that You
91
+ meet the following conditions:
92
+
93
+ (a) You must give any other recipients of the Work or
94
+ Derivative Works a copy of this License; and
95
+
96
+ (b) You must cause any modified files to carry prominent notices
97
+ stating that You changed the files; and
98
+
99
+ (c) You must retain, in the Source form of any Derivative Works
100
+ that You distribute, all copyright, patent, trademark, and
101
+ attribution notices from the Source form of the Work,
102
+ excluding those notices that do not pertain to any part of
103
+ the Derivative Works; and
104
+
105
+ (d) If the Work includes a "NOTICE" text file as part of its
106
+ distribution, then any Derivative Works that You distribute must
107
+ include a readable copy of the attribution notices contained
108
+ within such NOTICE file, excluding any notices that do not
109
+ pertain to any part of the Derivative Works, in at least one
110
+ of the following places: within a NOTICE text file distributed
111
+ as part of the Derivative Works; within the Source form or
112
+ documentation, if provided along with the Derivative Works; or,
113
+ within a display generated by the Derivative Works, if and
114
+ wherever such third-party notices normally appear. The contents
115
+ of the NOTICE file are for informational purposes only and
116
+ do not modify the License. You may add Your own attribution
117
+ notices within Derivative Works that You distribute, alongside
118
+ or as an addendum to the NOTICE text from the Work, provided
119
+ that such additional attribution notices cannot be construed
120
+ as modifying the License.
121
+
122
+ You may add Your own copyright statement to Your modifications and
123
+ may provide additional or different license terms and conditions
124
+ for use, reproduction, or distribution of Your modifications, or
125
+ for any such Derivative Works as a whole, provided Your use,
126
+ reproduction, and distribution of the Work otherwise complies with
127
+ the conditions stated in this License.
128
+
129
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
130
+ any Contribution intentionally submitted for inclusion in the Work
131
+ by You to the Licensor shall be under the terms and conditions of
132
+ this License, without any additional terms or conditions.
133
+ Notwithstanding the above, nothing herein shall supersede or modify
134
+ the terms of any separate license agreement you may have executed
135
+ with Licensor regarding such Contributions.
136
+
137
+ 6. Trademarks. This License does not grant permission to use the trade
138
+ names, trademarks, service marks, or product names of the Licensor,
139
+ except as required for reasonable and customary use in describing the
140
+ origin of the Work and reproducing the content of the NOTICE file.
141
+
142
+ 7. Disclaimer of Warranty. Unless required by applicable law or
143
+ agreed to in writing, Licensor provides the Work (and each
144
+ Contributor provides its Contributions) on an "AS IS" BASIS,
145
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
146
+ implied, including, without limitation, any warranties or conditions
147
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
148
+ PARTICULAR PURPOSE. You are solely responsible for determining the
149
+ appropriateness of using or redistributing the Work and assume any
150
+ risks associated with Your exercise of permissions under this License.
151
+
152
+ 8. Limitation of Liability. In no event and under no legal theory,
153
+ whether in tort (including negligence), contract, or otherwise,
154
+ unless required by applicable law (such as deliberate and grossly
155
+ negligent acts) or agreed to in writing, shall any Contributor be
156
+ liable to You for damages, including any direct, indirect, special,
157
+ incidental, or consequential damages of any character arising as a
158
+ result of this License or out of the use or inability to use the
159
+ Work (including but not limited to damages for loss of goodwill,
160
+ work stoppage, computer failure or malfunction, or any and all
161
+ other commercial damages or losses), even if such Contributor
162
+ has been advised of the possibility of such damages.
163
+
164
+ 9. Accepting Warranty or Additional Liability. While redistributing
165
+ the Work or Derivative Works thereof, You may choose to offer,
166
+ and charge a fee for, acceptance of support, warranty, indemnity,
167
+ or other liability obligations and/or rights consistent with this
168
+ License. However, in accepting such obligations, You may act only
169
+ on Your own behalf and on Your sole responsibility, not on behalf
170
+ of any other Contributor, and only if You agree to indemnify,
171
+ defend, and hold each Contributor harmless for any liability
172
+ incurred by, or claims asserted against, such Contributor by reason
173
+ of your accepting any such warranty or additional liability.
174
+
175
+ END OF TERMS AND CONDITIONS
176
+
177
+ Copyright 2026 Layer-IT
178
+
179
+ Licensed under the Apache License, Version 2.0 (the "License");
180
+ you may not use this file except in compliance with the License.
181
+ You may obtain a copy of the License at
182
+
183
+ http://www.apache.org/licenses/LICENSE-2.0
184
+
185
+ Unless required by applicable law or agreed to in writing, software
186
+ distributed under the License is distributed on an "AS IS" BASIS,
187
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
188
+ See the License for the specific language governing permissions and
189
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,108 @@
1
+ # node-red-contrib-samsung-smartthings
2
+
3
+ Professional Node-RED nodes for Samsung SmartThings device control and automation.
4
+
5
+ This package provides a complete set of nodes to interact with the [SmartThings REST API](https://developer.smartthings.com/docs/api/public), enabling you to manage locations, rooms, devices, scenes, and execute device commands directly from Node-RED flows.
6
+
7
+ ## Features
8
+
9
+ - **Full SmartThings API coverage** — Locations, Rooms, Devices, Status, Commands, Scenes, and Events
10
+ - **Real-time event monitoring** — Polling-based change detection that outputs messages only when device values change
11
+ - **Dynamic & static configuration** — Use editor dropdowns for quick setup, or override any parameter via `msg` properties at runtime
12
+ - **Shared configuration** — A single config node securely stores your API token and is shared across all SmartThings nodes
13
+ - **Energy monitoring** — Read energy and power meter data from compatible devices
14
+ - **Cascading dropdowns** — Device, capability, and command selectors populate dynamically based on your SmartThings account
15
+ - **Professional error handling** — Rate limiting, retry logic, and visual node status indicators
16
+
17
+ ## Installation
18
+
19
+ Install via the Node-RED Palette Manager, or run:
20
+
21
+ ```bash
22
+ cd ~/.node-red
23
+ npm install node-red-contrib-samsung-smartthings
24
+ ```
25
+
26
+ ## Prerequisites
27
+
28
+ You need a SmartThings Personal Access Token (PAT) for authentication:
29
+
30
+ 1. Navigate to [https://account.smartthings.com/tokens](https://account.smartthings.com/tokens)
31
+ 2. Sign in with your Samsung account
32
+ 3. Generate a new token with the required scopes (Devices, Locations, Scenes)
33
+ 4. Copy the token — you will need it for the configuration node
34
+
35
+ > **Note:** For production integrations, use OAuth 2.0. PATs are intended for testing and personal use.
36
+
37
+ ## Nodes
38
+
39
+ | Node | Description |
40
+ |------|-------------|
41
+ | **smartthings-config** | Configuration node — stores API token and base URL (shared by all nodes) |
42
+ | **smartthings-locations** | Retrieve SmartThings locations |
43
+ | **smartthings-rooms** | Retrieve rooms within a location |
44
+ | **smartthings-devices** | List and filter devices by location, room, or capability |
45
+ | **smartthings-status** | Get device status including energy/power meter readings |
46
+ | **smartthings-command** | Execute commands on devices (switch, dim, color, lock, etc.) |
47
+ | **smartthings-scenes** | List and execute SmartThings scenes |
48
+ | **smartthings-events** | Monitor device changes in real-time via intelligent polling |
49
+
50
+ ## Quick Start
51
+
52
+ 1. Drag a **smartthings-devices** node onto your flow
53
+ 2. Double-click and create a new **SmartThings Config** — enter your API token
54
+ 3. Select a location filter (optional) and deploy
55
+ 4. Connect an **inject** node to trigger it and a **debug** node to see the output
56
+ 5. Deploy and click the inject button to retrieve your devices
57
+
58
+ ## Dynamic Usage
59
+
60
+ Every node supports dynamic override via `msg` properties. Static dropdown values serve as defaults; `msg` values always take priority.
61
+
62
+ **Example: Dynamic device command**
63
+
64
+ ```json
65
+ {
66
+ "deviceId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
67
+ "component": "main",
68
+ "capability": "switch",
69
+ "command": "on",
70
+ "arguments": []
71
+ }
72
+ ```
73
+
74
+ Send this as the `msg` object to a **smartthings-command** node (with no static configuration) and it will execute the command dynamically.
75
+
76
+ ## Event Monitoring
77
+
78
+ The **smartthings-events** node monitors a device and outputs a message only when its status changes. This provides a subscription-like experience using intelligent polling.
79
+
80
+ **Setup:**
81
+ 1. Select a device, optionally filter by component/capability
82
+ 2. Set the polling interval (default: 10 seconds)
83
+ 3. Connect to a debug node or downstream flow
84
+
85
+ **Dynamic control via input:**
86
+
87
+ ```json
88
+ {
89
+ "action": "start",
90
+ "deviceId": "your-device-id",
91
+ "capability": "energyMeter",
92
+ "interval": 5
93
+ }
94
+ ```
95
+
96
+ Send `{ "action": "stop" }` to pause monitoring.
97
+
98
+ ## API Reference
99
+
100
+ This package communicates with the SmartThings REST API v1:
101
+
102
+ - Base URL: `https://api.smartthings.com`
103
+ - [API Documentation](https://developer.smartthings.com/docs/api/public)
104
+ - [Capabilities Reference](https://developer.smartthings.com/docs/devices/capabilities/capabilities-reference)
105
+
106
+ ## License
107
+
108
+ Apache-2.0 — Copyright 2026 Layer-IT
@@ -0,0 +1,15 @@
1
+ services:
2
+ nodered:
3
+ image: nodered/node-red:latest
4
+ container_name: smartthings-nodered
5
+ ports:
6
+ - "1880:1880"
7
+ volumes:
8
+ - nodered-data:/data
9
+ - ./:/opt/smartthings:ro
10
+ environment:
11
+ - TZ=Europe/Amsterdam
12
+ restart: unless-stopped
13
+
14
+ volumes:
15
+ nodered-data:
@@ -0,0 +1,182 @@
1
+ [
2
+ {
3
+ "id": "st-flow-basic",
4
+ "type": "tab",
5
+ "label": "SmartThings Basic Device Control",
6
+ "disabled": false,
7
+ "info": "Example flow demonstrating basic SmartThings device control.\n\n1. List all devices\n2. Turn a switch on/off dynamically\n3. Read device status"
8
+ },
9
+ {
10
+ "id": "st-inject-devices",
11
+ "type": "inject",
12
+ "z": "st-flow-basic",
13
+ "name": "Get All Devices",
14
+ "props": [],
15
+ "repeat": "",
16
+ "crontab": "",
17
+ "once": false,
18
+ "onceDelay": 0.1,
19
+ "topic": "",
20
+ "x": 150,
21
+ "y": 80,
22
+ "wires": [["st-devices-list"]]
23
+ },
24
+ {
25
+ "id": "st-devices-list",
26
+ "type": "smartthings-devices",
27
+ "z": "st-flow-basic",
28
+ "name": "List Devices",
29
+ "config": "",
30
+ "locationId": "",
31
+ "roomId": "",
32
+ "capability": "",
33
+ "deviceId": "",
34
+ "x": 370,
35
+ "y": 80,
36
+ "wires": [["st-debug-devices"]]
37
+ },
38
+ {
39
+ "id": "st-debug-devices",
40
+ "type": "debug",
41
+ "z": "st-flow-basic",
42
+ "name": "Device List",
43
+ "active": true,
44
+ "tosidebar": true,
45
+ "console": false,
46
+ "tostatus": true,
47
+ "complete": "payload",
48
+ "targetType": "msg",
49
+ "statusVal": "payload.length",
50
+ "statusType": "msg",
51
+ "x": 580,
52
+ "y": 80,
53
+ "wires": []
54
+ },
55
+ {
56
+ "id": "st-inject-on",
57
+ "type": "inject",
58
+ "z": "st-flow-basic",
59
+ "name": "Switch ON",
60
+ "props": [
61
+ { "p": "capability", "v": "switch", "vt": "str" },
62
+ { "p": "command", "v": "on", "vt": "str" }
63
+ ],
64
+ "repeat": "",
65
+ "crontab": "",
66
+ "once": false,
67
+ "onceDelay": 0.1,
68
+ "topic": "",
69
+ "x": 150,
70
+ "y": 200,
71
+ "wires": [["st-func-set-device"]]
72
+ },
73
+ {
74
+ "id": "st-inject-off",
75
+ "type": "inject",
76
+ "z": "st-flow-basic",
77
+ "name": "Switch OFF",
78
+ "props": [
79
+ { "p": "capability", "v": "switch", "vt": "str" },
80
+ { "p": "command", "v": "off", "vt": "str" }
81
+ ],
82
+ "repeat": "",
83
+ "crontab": "",
84
+ "once": false,
85
+ "onceDelay": 0.1,
86
+ "topic": "",
87
+ "x": 150,
88
+ "y": 260,
89
+ "wires": [["st-func-set-device"]]
90
+ },
91
+ {
92
+ "id": "st-func-set-device",
93
+ "type": "function",
94
+ "z": "st-flow-basic",
95
+ "name": "Set Device ID",
96
+ "func": "// Replace with your actual device ID\nmsg.deviceId = \"YOUR-DEVICE-ID-HERE\";\nreturn msg;",
97
+ "outputs": 1,
98
+ "timeout": "",
99
+ "noerr": 0,
100
+ "initialize": "",
101
+ "finalize": "",
102
+ "libs": [],
103
+ "x": 370,
104
+ "y": 230,
105
+ "wires": [["st-command-switch"]]
106
+ },
107
+ {
108
+ "id": "st-command-switch",
109
+ "type": "smartthings-command",
110
+ "z": "st-flow-basic",
111
+ "name": "Execute Command",
112
+ "config": "",
113
+ "deviceId": "",
114
+ "component": "main",
115
+ "capability": "",
116
+ "command": "",
117
+ "arguments": "",
118
+ "x": 580,
119
+ "y": 230,
120
+ "wires": [["st-debug-command"]]
121
+ },
122
+ {
123
+ "id": "st-debug-command",
124
+ "type": "debug",
125
+ "z": "st-flow-basic",
126
+ "name": "Command Result",
127
+ "active": true,
128
+ "tosidebar": true,
129
+ "console": false,
130
+ "tostatus": false,
131
+ "complete": "payload",
132
+ "targetType": "msg",
133
+ "x": 790,
134
+ "y": 230,
135
+ "wires": []
136
+ },
137
+ {
138
+ "id": "st-inject-status",
139
+ "type": "inject",
140
+ "z": "st-flow-basic",
141
+ "name": "Get Status",
142
+ "props": [
143
+ { "p": "deviceId", "v": "YOUR-DEVICE-ID-HERE", "vt": "str" }
144
+ ],
145
+ "repeat": "",
146
+ "crontab": "",
147
+ "once": false,
148
+ "onceDelay": 0.1,
149
+ "topic": "",
150
+ "x": 150,
151
+ "y": 360,
152
+ "wires": [["st-status-device"]]
153
+ },
154
+ {
155
+ "id": "st-status-device",
156
+ "type": "smartthings-status",
157
+ "z": "st-flow-basic",
158
+ "name": "Device Status",
159
+ "config": "",
160
+ "deviceId": "",
161
+ "component": "",
162
+ "capability": "",
163
+ "x": 370,
164
+ "y": 360,
165
+ "wires": [["st-debug-status"]]
166
+ },
167
+ {
168
+ "id": "st-debug-status",
169
+ "type": "debug",
170
+ "z": "st-flow-basic",
171
+ "name": "Status Output",
172
+ "active": true,
173
+ "tosidebar": true,
174
+ "console": false,
175
+ "tostatus": false,
176
+ "complete": "payload",
177
+ "targetType": "msg",
178
+ "x": 580,
179
+ "y": 360,
180
+ "wires": []
181
+ }
182
+ ]
@@ -0,0 +1,187 @@
1
+ [
2
+ {
3
+ "id": "st-flow-energy",
4
+ "type": "tab",
5
+ "label": "SmartThings Energy Monitoring",
6
+ "disabled": false,
7
+ "info": "Example flow for monitoring energy consumption.\n\n1. Discovers all energy meter devices\n2. Polls energy and power readings every 5 minutes\n3. Outputs structured energy data"
8
+ },
9
+ {
10
+ "id": "st-inject-energy-devices",
11
+ "type": "inject",
12
+ "z": "st-flow-energy",
13
+ "name": "Find Energy Meters",
14
+ "props": [
15
+ { "p": "capability", "v": "energyMeter", "vt": "str" }
16
+ ],
17
+ "repeat": "",
18
+ "crontab": "",
19
+ "once": false,
20
+ "onceDelay": 0.1,
21
+ "topic": "",
22
+ "x": 170,
23
+ "y": 80,
24
+ "wires": [["st-devices-energy"]]
25
+ },
26
+ {
27
+ "id": "st-devices-energy",
28
+ "type": "smartthings-devices",
29
+ "z": "st-flow-energy",
30
+ "name": "Energy Meter Devices",
31
+ "config": "",
32
+ "locationId": "",
33
+ "roomId": "",
34
+ "capability": "energyMeter",
35
+ "deviceId": "",
36
+ "x": 410,
37
+ "y": 80,
38
+ "wires": [["st-debug-energy-devices"]]
39
+ },
40
+ {
41
+ "id": "st-debug-energy-devices",
42
+ "type": "debug",
43
+ "z": "st-flow-energy",
44
+ "name": "Energy Devices",
45
+ "active": true,
46
+ "tosidebar": true,
47
+ "console": false,
48
+ "tostatus": true,
49
+ "complete": "payload",
50
+ "targetType": "msg",
51
+ "statusVal": "payload.length",
52
+ "statusType": "msg",
53
+ "x": 640,
54
+ "y": 80,
55
+ "wires": []
56
+ },
57
+ {
58
+ "id": "st-inject-poll",
59
+ "type": "inject",
60
+ "z": "st-flow-energy",
61
+ "name": "Every 5 minutes",
62
+ "props": [
63
+ { "p": "deviceId", "v": "YOUR-ENERGY-METER-DEVICE-ID", "vt": "str" },
64
+ { "p": "component", "v": "main", "vt": "str" },
65
+ { "p": "capability", "v": "energyMeter", "vt": "str" }
66
+ ],
67
+ "repeat": "300",
68
+ "crontab": "",
69
+ "once": false,
70
+ "onceDelay": 0.1,
71
+ "topic": "",
72
+ "x": 170,
73
+ "y": 220,
74
+ "wires": [["st-status-energy"]]
75
+ },
76
+ {
77
+ "id": "st-status-energy",
78
+ "type": "smartthings-status",
79
+ "z": "st-flow-energy",
80
+ "name": "Read Energy",
81
+ "config": "",
82
+ "deviceId": "",
83
+ "component": "",
84
+ "capability": "",
85
+ "x": 400,
86
+ "y": 220,
87
+ "wires": [["st-func-format-energy"]]
88
+ },
89
+ {
90
+ "id": "st-func-format-energy",
91
+ "type": "function",
92
+ "z": "st-flow-energy",
93
+ "name": "Format Energy Data",
94
+ "func": "var energy = msg.payload.energy || {};\nmsg.payload = {\n deviceId: msg.deviceId,\n energy_kWh: energy.value || 0,\n unit: energy.unit || 'kWh',\n timestamp: energy.timestamp || new Date().toISOString(),\n readAt: new Date().toISOString()\n};\nreturn msg;",
95
+ "outputs": 1,
96
+ "timeout": "",
97
+ "noerr": 0,
98
+ "initialize": "",
99
+ "finalize": "",
100
+ "libs": [],
101
+ "x": 630,
102
+ "y": 220,
103
+ "wires": [["st-debug-energy-output"]]
104
+ },
105
+ {
106
+ "id": "st-debug-energy-output",
107
+ "type": "debug",
108
+ "z": "st-flow-energy",
109
+ "name": "Energy Reading",
110
+ "active": true,
111
+ "tosidebar": true,
112
+ "console": false,
113
+ "tostatus": true,
114
+ "complete": "payload",
115
+ "targetType": "msg",
116
+ "statusVal": "payload.energy_kWh",
117
+ "statusType": "msg",
118
+ "x": 860,
119
+ "y": 220,
120
+ "wires": []
121
+ },
122
+ {
123
+ "id": "st-inject-power",
124
+ "type": "inject",
125
+ "z": "st-flow-energy",
126
+ "name": "Every 1 minute",
127
+ "props": [
128
+ { "p": "deviceId", "v": "YOUR-ENERGY-METER-DEVICE-ID", "vt": "str" },
129
+ { "p": "component", "v": "main", "vt": "str" },
130
+ { "p": "capability", "v": "powerMeter", "vt": "str" }
131
+ ],
132
+ "repeat": "60",
133
+ "crontab": "",
134
+ "once": false,
135
+ "onceDelay": 0.1,
136
+ "topic": "",
137
+ "x": 160,
138
+ "y": 360,
139
+ "wires": [["st-status-power"]]
140
+ },
141
+ {
142
+ "id": "st-status-power",
143
+ "type": "smartthings-status",
144
+ "z": "st-flow-energy",
145
+ "name": "Read Power",
146
+ "config": "",
147
+ "deviceId": "",
148
+ "component": "",
149
+ "capability": "",
150
+ "x": 400,
151
+ "y": 360,
152
+ "wires": [["st-func-format-power"]]
153
+ },
154
+ {
155
+ "id": "st-func-format-power",
156
+ "type": "function",
157
+ "z": "st-flow-energy",
158
+ "name": "Format Power Data",
159
+ "func": "var power = msg.payload.power || {};\nmsg.payload = {\n deviceId: msg.deviceId,\n power_W: power.value || 0,\n unit: power.unit || 'W',\n timestamp: power.timestamp || new Date().toISOString(),\n readAt: new Date().toISOString()\n};\nreturn msg;",
160
+ "outputs": 1,
161
+ "timeout": "",
162
+ "noerr": 0,
163
+ "initialize": "",
164
+ "finalize": "",
165
+ "libs": [],
166
+ "x": 630,
167
+ "y": 360,
168
+ "wires": [["st-debug-power-output"]]
169
+ },
170
+ {
171
+ "id": "st-debug-power-output",
172
+ "type": "debug",
173
+ "z": "st-flow-energy",
174
+ "name": "Power Reading",
175
+ "active": true,
176
+ "tosidebar": true,
177
+ "console": false,
178
+ "tostatus": true,
179
+ "complete": "payload",
180
+ "targetType": "msg",
181
+ "statusVal": "payload.power_W",
182
+ "statusType": "msg",
183
+ "x": 860,
184
+ "y": 360,
185
+ "wires": []
186
+ }
187
+ ]