node-red-contrib-octopus-intelligent 1.0.5 → 1.2.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/CHANGELOG.md CHANGED
@@ -5,6 +5,62 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.2.0] - 2026-04-26
9
+
10
+ ### Added
11
+ - **Smart Charging Toggle** — suspend or unsuspend Octopus intelligent charging from Node-RED or Home Assistant
12
+ - `msg.payload = { set_smart_charging: true }` — enable (unsuspend)
13
+ - `msg.payload = { set_smart_charging: false }` — disable (suspend)
14
+ - **HA MQTT Switch** — "Smart Charging" switch entity in Home Assistant (auto-discovered)
15
+ - **`smart_charging` payload field** — `true` = active, `false` = suspended, `null` = unknown (startup fetch pending or failed)
16
+ - **Device ID startup fetch** — `krakenflexDeviceId` fetched once at startup via `registeredKrakenflexDevice` query; cached permanently
17
+
18
+ ### Technical
19
+ - Mirrors `setPreferences` pattern: auth → mutation → optimistic update → exponential backoff verification (15s/30s/60s/120s)
20
+ - Verification re-fetches `registeredKrakenflexDevice.suspended` to confirm state change
21
+ - Zero new npm dependencies
22
+
23
+ ---
24
+
25
+ ## [1.1.1] - 2026-04-26
26
+
27
+ ### Security
28
+ - **Removed `axios` dependency** — replaced with Node.js built-in `https` module; eliminates 13 transitive packages and all associated supply chain risk
29
+ - **Removed test/mock files from npm package** — `__tests__/` and `test-mocks.js` no longer published; removes 139 kB of dev artefacts from end-user installs
30
+ - **Removed images from npm package** — 364 kB of images no longer bundled; README images now reference GitHub raw URLs and render correctly on npmjs.com
31
+
32
+ ### Changed
33
+ - Package size reduced from 369 kB → 27 kB (93% reduction)
34
+ - Zero production dependencies (was: `axios ^1.6.0`)
35
+
36
+ ---
37
+
38
+ ## [1.1.0] - 2026-04-24
39
+
40
+ ### Added
41
+ - **Locale Timestamps** — new `*_locale` fields in every payload, always in server auto-detected timezone
42
+ - `slot1_start_locale`, `slot1_end_locale`, `slot2_start_locale`, `slot2_end_locale`
43
+ - `slot3_start_locale`, `slot3_end_locale`, `window_start_locale`, `window_end_locale`
44
+ - `next_start_locale`
45
+ - **Timezone Metadata** — `timezone_detected` (server auto-detect) and `timezone_applied` (active TZ for display fields)
46
+ - **HA Timezone Select Entity** — `select.octopus_timezone` with 15 curated IANA timezones covering all Octopus operating countries (UK, AU, DE, ES, NZ, US)
47
+ - Selection persists across Node-RED restarts via node context storage
48
+ - State republished to HA on Node-RED startup
49
+ - **`set_timezone` Input Command** — `msg.payload = { set_timezone: "Europe/London" }`, same pattern as `set_limit`/`set_time`
50
+ - **`timezoneOverride` Node Config Field** — optional IANA timezone in node editor, leave blank for auto-detect
51
+ - **Timezone Diagnostic Sensors** — `sensor.octopus_timezone_detected` and `sensor.octopus_timezone_applied`
52
+
53
+ ### Changed
54
+ - **Display timestamp fields now output resolved timezone** instead of raw UTC
55
+ - Affected fields: `slot1_start`, `slot1_end`, `slot2_start`, `slot2_end`, `slot3_start`, `slot3_end`, `window_start`, `window_end`, `next_start`
56
+ - Resolution order: HA-persisted selection → `timezoneOverride` config → server auto-detected
57
+ - **Raw fields (`*_raw`) remain unchanged** — always exact UTC strings from the API
58
+
59
+ ### Technical
60
+ - Zero new npm dependencies — native `Intl.DateTimeFormat` API (Node 14 compatible)
61
+ - `convertToTimezone(dateStr, tz)` — handles DST correctly, falls back to original string on error
62
+ - `resolveTimezone(node)` — reads node context storage, config field, or server auto-detect
63
+
8
64
  ## [1.0.5] - 2025-12-31
9
65
 
10
66
  ### Fixed
package/README.md CHANGED
@@ -77,6 +77,18 @@ If this project has helped you!
77
77
  - **Professional Layout** - Organized entity categories in device card
78
78
  - **Suggested Area** - Auto-suggests "Energy" area
79
79
 
80
+ ### ⚡ Smart Charging Control
81
+ - **Smart Charging Toggle** — suspend or resume Octopus intelligent charging from Node-RED or Home Assistant
82
+ - **HA MQTT Switch** — "Smart Charging" switch entity auto-discovered in Home Assistant
83
+ - **`smart_charging` field** — live state in every payload (`true` = active, `false` = suspended, `null` = unknown)
84
+
85
+ ### 🌍 Timezone Support
86
+ - **Locale Timestamps** (`*_locale` fields) — always in server auto-detected timezone
87
+ - **Resolved Display Fields** — slot and window times in your configured timezone
88
+ - **HA Timezone Select** — change timezone from Home Assistant without redeploying
89
+ - **Node Config Override** — set IANA timezone directly in the node editor
90
+ - **Zero Dependencies** — native `Intl` API, no new packages
91
+
80
92
  ---
81
93
 
82
94
  ## 📸 Screenshots
@@ -84,7 +96,7 @@ If this project has helped you!
84
96
  ### Node-RED Flow Examples
85
97
 
86
98
  #### Basic Monitoring & Control
87
- ![Node-RED Flow Examples](images/examples/basic-monitoring-flow.png)
99
+ ![Node-RED Flow Examples](https://raw.githubusercontent.com/ASomerN/node-red-contrib-octopus-intelligent/master/images/examples/basic-monitoring-flow.png)
88
100
 
89
101
  This example flow demonstrates three key usage patterns:
90
102
 
@@ -101,7 +113,7 @@ This example flow demonstrates three key usage patterns:
101
113
  **How to use:** Import any of these flows, configure your Account Number and API Key in the Octopus Intelligent node, and deploy!
102
114
 
103
115
  #### MQTT Integration with Home Assistant
104
- ![MQTT Integration Flow](images/examples/mqtt-integration-flow.png)
116
+ ![MQTT Integration Flow](https://raw.githubusercontent.com/ASomerN/node-red-contrib-octopus-intelligent/master/images/examples/mqtt-integration-flow.png)
105
117
 
106
118
  This flow shows the complete MQTT setup:
107
119
 
@@ -114,15 +126,23 @@ This flow shows the complete MQTT setup:
114
126
 
115
127
  ### Home Assistant Auto-Configured Entities
116
128
 
117
- ![Home Assistant Device](images/examples/homeassistant-device-v1.0.4.png)
129
+ ![Home Assistant Device](https://raw.githubusercontent.com/ASomerN/node-red-contrib-octopus-intelligent/master/images/examples/homeassistant-device-v1.0.4.png)
118
130
 
119
131
  After enabling MQTT in the Node-RED node, Home Assistant automatically creates:
120
132
 
133
+ ### Home Assistant Controls Configuration
134
+
135
+ ![Home Assistant Controls Configuration](https://raw.githubusercontent.com/ASomerN/node-red-contrib-octopus-intelligent/master/images/examples/configuration.png)
136
+
137
+ The Controls section of the device card includes the **Timezone** select and the new **Smart Charging** toggle, letting you suspend or resume intelligent charging directly from Home Assistant.
138
+
121
139
  #### Controls (Top Section)
122
140
  - **Target Charge** - Number slider (50-100%) to set desired battery level
123
141
  - **Ready Time** - Dropdown selector (04:00-11:00) for when car needs to be ready
124
142
  - **Apply Changes** - Button to submit new settings (prevents API spam while adjusting)
125
143
  - **Refresh API** - Button to force manual refresh (30-second cooldown prevents spam)
144
+ - **Timezone** — Select entity for choosing display timezone (15 IANA options, persists across restarts)
145
+ - **Smart Charging** — Switch to suspend or resume Octopus intelligent charging
126
146
 
127
147
  #### Sensors (Main Section)
128
148
  - **Confirmed Charge Limit** - Current API-validated charge limit
@@ -132,6 +152,9 @@ After enabling MQTT in the Node-RED node, Home Assistant automatically creates:
132
152
  - **Total Planned Energy** - Total kWh across all upcoming slots
133
153
  - **Slot 1, 2, 3 Start/End** - Individual charging slot times
134
154
  - **Overall Window Start/End** - First slot start to last slot end
155
+ - **Slot 1, 2, 3 Start/End (Locale)** — Same slots in server auto-detected timezone
156
+ - **Overall Window Start/End (Locale)** — Window times in server auto-detected timezone
157
+ - **Next Charge Time (Locale)** — Next charge start in server auto-detected timezone
135
158
  - **Charging Now** - Binary sensor (ON/OFF) showing if actively charging
136
159
 
137
160
  #### Diagnostics (Raw timestamps and monitoring)
@@ -139,6 +162,8 @@ After enabling MQTT in the Node-RED node, Home Assistant automatically creates:
139
162
  - **API Requests (Last Hour)** - Number of API calls in the last 60 minutes
140
163
  - **API Complexity (Last Hour)** - Total complexity used (max 50,000/hour)
141
164
  - **API Complexity Usage** - Percentage of hourly API limit used
165
+ - **Timezone Detected** — Server's auto-detected timezone (e.g. `Europe/London`)
166
+ - **Timezone Applied** — Active timezone used for display fields
142
167
  - **Raw timestamp sensors** - Exact API responses for all sensors
143
168
  - Useful for debugging, advanced automations, and monitoring API usage
144
169
 
@@ -201,6 +226,8 @@ number.octopus_target_charge Battery charge limit (50-100%)
201
226
  select.octopus_ready_time Ready by time (04:00-11:00)
202
227
  button.octopus_apply_changes Submit changes to API
203
228
  button.octopus_refresh_api Manual refresh (30s cooldown)
229
+ select.octopus_timezone Display timezone (15 IANA options)
230
+ switch.octopus_smart_charging Enable/disable smart charging
204
231
  ```
205
232
 
206
233
  ### Main Sensors
@@ -216,6 +243,11 @@ sensor.octopus_slot_[1-3]_start Individual slot starts
216
243
  sensor.octopus_slot_[1-3]_end Individual slot ends
217
244
  sensor.octopus_overall_window_start First slot start
218
245
  sensor.octopus_overall_window_end Last slot end
246
+ sensor.octopus_next_charge_locale Next charge start (server TZ)
247
+ sensor.octopus_slot_[1-3]_start_locale Individual slot starts (server TZ)
248
+ sensor.octopus_slot_[1-3]_end_locale Individual slot ends (server TZ)
249
+ sensor.octopus_overall_window_start_locale Window start (server TZ)
250
+ sensor.octopus_overall_window_end_locale Window end (server TZ)
219
251
  ```
220
252
 
221
253
  ### Diagnostics (Raw Timestamps & Monitoring)
@@ -235,10 +267,51 @@ sensor.octopus_slot_[1-3]_start_raw Raw slot start times
235
267
  sensor.octopus_slot_[1-3]_end_raw Raw slot end times
236
268
  sensor.octopus_overall_window_start_raw Raw window start
237
269
  sensor.octopus_overall_window_end_raw Raw window end
270
+
271
+ # Timezone Diagnostics
272
+ sensor.octopus_timezone_detected Server auto-detected timezone
273
+ sensor.octopus_timezone_applied Active timezone used for display fields
238
274
  ```
239
275
 
240
276
  ---
241
277
 
278
+ ## 🌍 Timezone Configuration
279
+
280
+ By default, slot and window times are converted to the **server's auto-detected timezone** (wherever Node-RED is running). Three ways to configure:
281
+
282
+ ### Option 1: Node Config (static)
283
+ Set a fixed IANA timezone in the node editor:
284
+ - Open node → **Timezone** field → type `Australia/Sydney`
285
+ - Applies to all display fields (`slot1_start`, `window_start`, etc.)
286
+ - Leave blank to use server auto-detect
287
+
288
+ ### Option 2: Home Assistant Select (dynamic, persists across restarts)
289
+ Use the **Timezone** select entity in Home Assistant:
290
+ - Home Assistant → Octopus Intelligent device → Timezone
291
+ - Change takes effect on next poll
292
+ - Persists across Node-RED restarts
293
+
294
+ ### Option 3: `set_timezone` Input Command
295
+ ```javascript
296
+ msg.payload = { set_timezone: "Europe/London" };
297
+ // Send to Octopus Intelligent node input
298
+ ```
299
+ Saved to node context, applies on next poll.
300
+
301
+ ### Timestamp Tiers
302
+ | Field suffix | Timezone | Configurable? |
303
+ |-------------|----------|---------------|
304
+ | `*_raw` | Always UTC (exact API string) | Never |
305
+ | `*_locale` | Server auto-detected | Never (always server TZ) |
306
+ | Display fields (`slot1_start`, `window_start`, etc.) | Resolved TZ | Yes — via HA, config, or command |
307
+
308
+ ### Supported Timezones (HA select)
309
+ `Europe/London`, `Europe/Berlin`, `Europe/Madrid`, `Australia/Sydney`, `Australia/Melbourne`, `Australia/Brisbane`, `Australia/Perth`, `Australia/Adelaide`, `Pacific/Auckland`, `America/New_York`, `America/Chicago`, `America/Denver`, `America/Los_Angeles`, `Asia/Tokyo`, `UTC`
310
+
311
+ Any valid IANA timezone works in the node config field or `set_timezone` command.
312
+
313
+ ---
314
+
242
315
  ## 💡 Node-RED Usage
243
316
 
244
317
  ### Basic Monitoring
@@ -257,12 +330,29 @@ msg.payload = {
257
330
  return msg;
258
331
  ```
259
332
 
333
+ ### Set Timezone from Flow
334
+
335
+ ```javascript
336
+ msg.payload = { set_timezone: "Australia/Sydney" };
337
+ return msg;
338
+ ```
339
+
340
+ ### Toggle Smart Charging from Flow
341
+
342
+ ```javascript
343
+ msg.payload = { set_smart_charging: true }; // enable (unsuspend)
344
+ msg.payload = { set_smart_charging: false }; // disable (suspend)
345
+ return msg;
346
+ ```
347
+
348
+ Valid values: any IANA timezone string (e.g. `Europe/London`, `UTC`, `America/New_York`).
349
+
260
350
  ### Output Format
261
351
 
262
352
  ```json
263
353
  {
264
354
  "payload": {
265
- "next_start": "2025-11-29T01:30:00Z",
355
+ "next_start": "2025-11-29 01:30:00+00:00",
266
356
  "total_energy": 42.5,
267
357
  "next_kwh": "15.20",
268
358
  "next_source": "smart-charge",
@@ -276,8 +366,16 @@ return msg;
276
366
  "api_requests_hour": 12,
277
367
  "api_complexity_hour": 3600,
278
368
  "api_complexity_percent": 7.2,
279
- "slot1_start": "2025-11-29T01:30:00Z",
280
- "slot1_end": "2025-11-29T05:30:00Z"
369
+ "slot1_start": "2025-11-29 01:30:00+00:00",
370
+ "slot1_end": "2025-11-29 05:30:00+00:00",
371
+ "timezone_detected": "Europe/London",
372
+ "timezone_applied": "Europe/London",
373
+ "smart_charging": true,
374
+ "next_start_locale": "2025-11-29 01:30:00+00:00",
375
+ "slot1_start_locale": "2025-11-29 01:30:00+00:00",
376
+ "slot1_end_locale": "2025-11-29 05:30:00+00:00",
377
+ "window_start_locale": "2025-11-29 01:30:00+00:00",
378
+ "window_end_locale": "2025-11-29 05:30:00+00:00"
281
379
  },
282
380
  "debug": {
283
381
  "success": true,
@@ -459,7 +557,12 @@ Use at your own risk. The Octopus Energy name and logo are trademarks of Octopus
459
557
 
460
558
  See [CHANGELOG.md](CHANGELOG.md) for detailed version history and release notes.
461
559
 
462
- ### Latest Release: v1.0.5 (2025-12-31)
560
+ ### Latest Release: v1.2.0 (2026-04-26)
561
+ - **Smart Charging Toggle** — suspend/resume Octopus intelligent charging from Node-RED or Home Assistant
562
+ - **HA MQTT Switch** — auto-discovered Smart Charging switch entity
563
+ - **`smart_charging` payload field** — live state in every message
564
+
565
+ ### Previous Release: v1.0.5 (2025-12-31)
463
566
  - **Documentation Fix** - Corrected misleading "branded device cards" claim in README
464
567
 
465
568
  ### Previous Release: v1.0.4 (2025-12-11)
@@ -1,127 +1,138 @@
1
- <script type="text/javascript">
2
- RED.nodes.registerType('octopus-intelligent', {
3
- category: 'Octopus',
4
- color: '#E8146F', // Octopus Energy brand pink
5
- defaults: {
6
- name: { value: "Octopus Intelligent" },
7
- accountNumber: { value: "", required: true },
8
- broker: { type: "mqtt-broker", required: false }, // Optional MQTT
9
- refreshInterval: { value: 5, validate: RED.validators.number() },
10
- enableMqtt: { value: true }
11
- },
12
- credentials: {
13
- apiKey: { type: "password" }
14
- },
15
- inputs: 1,
16
- outputs: 1,
17
- icon: "font-awesome/fa-bolt",
18
- label: function() {
19
- return this.name || "Octopus Intelligent";
20
- }
21
- });
22
- </script>
23
-
24
- <script type="text/html" data-template-name="octopus-intelligent">
25
- <div class="form-row">
26
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
27
- <input type="text" id="node-input-name" placeholder="Name">
28
- </div>
29
- <div class="form-row">
30
- <label for="node-input-accountNumber"><i class="fa fa-id-card"></i> Account No</label>
31
- <input type="text" id="node-input-accountNumber" placeholder="A-12345678">
32
- </div>
33
- <div class="form-row">
34
- <label for="node-input-apiKey"><i class="fa fa-key"></i> API Key</label>
35
- <input type="password" id="node-input-apiKey" placeholder="sk_live_...">
36
- </div>
37
-
38
- <hr>
39
-
40
- <div class="form-row">
41
- <label for="node-input-refreshInterval"><i class="fa fa-clock-o"></i> Refresh (Min)</label>
42
- <input type="number" id="node-input-refreshInterval" placeholder="5">
43
- </div>
44
-
45
- <div class="form-row">
46
- <label for="node-input-enableMqtt"><i class="fa fa-rss"></i> HA Discovery</label>
47
- <input type="checkbox" id="node-input-enableMqtt" style="display: inline-block; width: auto; vertical-align: top;">
48
- <label for="node-input-enableMqtt" style="width: 70%;">Enable Home Assistant MQTT</label>
49
- </div>
50
-
51
- <div class="form-row">
52
- <label for="node-input-broker"><i class="fa fa-globe"></i> MQTT Broker</label>
53
- <input type="text" id="node-input-broker">
54
- </div>
55
- </script>
56
-
57
- <script type="text/html" data-help-name="octopus-intelligent">
58
- <p>This node integrates with the <strong>Octopus Energy Intelligent Octopus Go</strong> API to retrieve planned charging slots and preferences.</p>
59
- <p>Configure your Account Number and API Key, then deploy the flow. The node will fetch data at regular intervals and output charging information.</p>
60
- <p>Enable MQTT to automatically configure Home Assistant entities via auto-discovery.</p>
61
-
62
- <h3>Examples</h3>
63
-
64
- <h4>1. Basic Monitoring</h4>
65
- <p>Monitor your charging slots every 5 minutes:</p>
66
- <pre>[{"id":"1","type":"inject","name":"Every 5 min","props":[{"p":"payload"}],"repeat":"300","crontab":"","once":true,"topic":"","payload":"","payloadType":"date","x":130,"y":80,"wires":[["2"]]},{"id":"2","type":"octopus-intelligent","name":"Octopus Intelligent","account":"A-XXXXXXXX","apiKey":"sk_live_...","refreshInterval":"5","enableMqtt":false,"x":340,"y":80,"wires":[["3"]]},{"id":"3","type":"debug","name":"Debug Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":570,"y":80,"wires":[]}]</pre>
67
-
68
- <h4>2. Set Preferences from Flow</h4>
69
- <p>Control charge limit and ready time programmatically:</p>
70
- <pre>[{"id":"1","type":"inject","name":"Set 85% by 07:30","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"topic":"","payload":"{\"set_limit\":85,\"set_time\":\"07:30\"}","payloadType":"json","x":150,"y":140,"wires":[["2"]]},{"id":"2","type":"octopus-intelligent","name":"Octopus Intelligent","account":"A-XXXXXXXX","apiKey":"sk_live_...","refreshInterval":"5","enableMqtt":true,"mqttBroker":"mqtt-broker","x":380,"y":140,"wires":[["3"]]},{"id":"3","type":"debug","name":"Confirmation","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":610,"y":140,"wires":[]}]</pre>
71
-
72
- <h4>3. Home Assistant MQTT Integration</h4>
73
- <p>Automatically create Home Assistant entities via MQTT discovery:</p>
74
- <pre>[{"id":"1","type":"inject","name":"Every 5 min","props":[{"p":"payload"}],"repeat":"300","crontab":"","once":true,"topic":"","payload":"","payloadType":"date","x":130,"y":200,"wires":[["2"]]},{"id":"2","type":"octopus-intelligent","name":"Octopus Intelligent","account":"A-XXXXXXXX","apiKey":"sk_live_...","refreshInterval":"5","enableMqtt":true,"mqttBroker":"mqtt-broker","x":340,"y":200,"wires":[["3"]]},{"id":"3","type":"debug","name":"Debug Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":570,"y":200,"wires":[]},{"id":"mqtt-broker","type":"mqtt-broker","name":"Home Assistant MQTT","broker":"localhost","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]</pre>
75
-
76
- <h3>Visual Examples</h3>
77
- <p><strong>Node-RED Flow Examples:</strong></p>
78
- <img src="https://raw.githubusercontent.com/ASomerN/node-red-contrib-octopus-intelligent/master/images/examples/basic-monitoring-flow.png" alt="Node-RED Flow Examples" style="max-width: 100%; border: 1px solid #ddd; border-radius: 4px;">
79
- <p style="margin-top: 8px;"><em>Reads by default, manually refreshable from a button, pass in commands to change charge time and percentage</em></p>
80
-
81
- <p style="margin-top: 16px;"><strong>MQTT Integration:</strong></p>
82
- <img src="https://raw.githubusercontent.com/ASomerN/node-red-contrib-octopus-intelligent/master/images/examples/mqtt-integration-flow.png" alt="MQTT Integration Flow" style="max-width: 100%; border: 1px solid #ddd; border-radius: 4px;">
83
- <p style="margin-top: 8px;"><em>Complete MQTT integration with Home Assistant</em></p>
84
-
85
- <p style="margin-top: 16px;"><strong>Home Assistant Device:</strong></p>
86
- <img src="https://raw.githubusercontent.com/ASomerN/node-red-contrib-octopus-intelligent/master/images/examples/homeassistant-device.png" alt="Home Assistant Device" style="max-width: 100%; border: 1px solid #ddd; border-radius: 4px;">
87
- <p style="margin-top: 8px;"><em>Octopus Intelligent device with all controls and sensors automatically configured</em></p>
88
-
89
- <h3>Output Format</h3>
90
- <p>The node outputs a message with the following structure:</p>
91
- <pre>{
92
- "payload": {
93
- "next_start": "2025-11-29T01:30:00Z",
94
- "total_energy": 42.5,
95
- "next_kwh": "15.20",
96
- "next_source": "smart-charge",
97
- "confirmed_limit": 80,
98
- "confirmed_time": "07:00",
99
- "charging_now": false,
100
- "slot1_start": "2025-11-29T01:30:00Z",
101
- "slot1_end": "2025-11-29T05:30:00Z"
102
- },
103
- "debug": {
104
- "success": true,
105
- "step": "complete",
106
- "apiCalls": [...]
107
- }
108
- }</pre>
109
-
110
- <h3>Home Assistant Integration</h3>
111
- <p>When MQTT is enabled, the node automatically creates:</p>
112
- <ul>
113
- <li><strong>Controls:</strong> Target charge slider, ready time selector, apply changes button</li>
114
- <li><strong>Sensors:</strong> Next charge time, total energy, charging status, individual slots</li>
115
- <li><strong>Binary Sensor:</strong> Charging now indicator (ON/OFF)</li>
116
- </ul>
117
- <p>All entities appear under a single "Octopus Intelligent" device in Home Assistant.</p>
118
-
119
- <h3>Requirements</h3>
120
- <ul>
121
- <li>Octopus Energy account with Intelligent Octopus Go tariff</li>
122
- <li>API key from <a href="https://octopus.energy/dashboard/new/accounts/personal-details/api-access" target="_blank">Octopus dashboard</a></li>
123
- <li>MQTT broker (optional, for Home Assistant integration)</li>
124
- </ul>
125
-
126
- <p>See the <a href="https://github.com/ASomerN/node-red-contrib-octopus-intelligent/blob/master/README.md" target="_blank">full documentation</a> for details.</p>
127
- </script>
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('octopus-intelligent', {
3
+ category: 'Octopus',
4
+ color: '#E8146F', // Octopus Energy brand pink
5
+ defaults: {
6
+ name: { value: "Octopus Intelligent" },
7
+ accountNumber: { value: "", required: true },
8
+ broker: { type: "mqtt-broker", required: false }, // Optional MQTT
9
+ refreshInterval: { value: 5, validate: RED.validators.number() },
10
+ enableMqtt: { value: true },
11
+ timezoneOverride: { value: "" }
12
+ },
13
+ credentials: {
14
+ apiKey: { type: "password" }
15
+ },
16
+ inputs: 1,
17
+ outputs: 1,
18
+ icon: "font-awesome/fa-bolt",
19
+ label: function() {
20
+ return this.name || "Octopus Intelligent";
21
+ }
22
+ });
23
+ </script>
24
+
25
+ <script type="text/html" data-template-name="octopus-intelligent">
26
+ <div class="form-row">
27
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
28
+ <input type="text" id="node-input-name" placeholder="Name">
29
+ </div>
30
+ <div class="form-row">
31
+ <label for="node-input-accountNumber"><i class="fa fa-id-card"></i> Account No</label>
32
+ <input type="text" id="node-input-accountNumber" placeholder="A-12345678">
33
+ </div>
34
+ <div class="form-row">
35
+ <label for="node-input-apiKey"><i class="fa fa-key"></i> API Key</label>
36
+ <input type="password" id="node-input-apiKey" placeholder="sk_live_...">
37
+ </div>
38
+
39
+ <hr>
40
+
41
+ <div class="form-row">
42
+ <label for="node-input-refreshInterval"><i class="fa fa-clock-o"></i> Refresh (Min)</label>
43
+ <input type="number" id="node-input-refreshInterval" placeholder="5">
44
+ </div>
45
+
46
+ <div class="form-row">
47
+ <label for="node-input-timezoneOverride"><i class="fa fa-globe"></i> Timezone</label>
48
+ <input type="text" id="node-input-timezoneOverride" placeholder="Europe/London">
49
+ </div>
50
+ <div class="form-row">
51
+ <div style="margin-left: 106px; font-size: 0.85em; color: #888;">
52
+ Leave blank to use server timezone (auto-detected)
53
+ </div>
54
+ </div>
55
+
56
+ <div class="form-row">
57
+ <label for="node-input-enableMqtt"><i class="fa fa-rss"></i> HA Discovery</label>
58
+ <input type="checkbox" id="node-input-enableMqtt" style="display: inline-block; width: auto; vertical-align: top;">
59
+ <label for="node-input-enableMqtt" style="width: 70%;">Enable Home Assistant MQTT</label>
60
+ </div>
61
+
62
+ <div class="form-row">
63
+ <label for="node-input-broker"><i class="fa fa-globe"></i> MQTT Broker</label>
64
+ <input type="text" id="node-input-broker">
65
+ </div>
66
+ </script>
67
+
68
+ <script type="text/html" data-help-name="octopus-intelligent">
69
+ <p>This node integrates with the <strong>Octopus Energy Intelligent Octopus Go</strong> API to retrieve planned charging slots and preferences.</p>
70
+ <p>Configure your Account Number and API Key, then deploy the flow. The node will fetch data at regular intervals and output charging information.</p>
71
+ <p>Enable MQTT to automatically configure Home Assistant entities via auto-discovery.</p>
72
+
73
+ <h3>Examples</h3>
74
+
75
+ <h4>1. Basic Monitoring</h4>
76
+ <p>Monitor your charging slots every 5 minutes:</p>
77
+ <pre>[{"id":"1","type":"inject","name":"Every 5 min","props":[{"p":"payload"}],"repeat":"300","crontab":"","once":true,"topic":"","payload":"","payloadType":"date","x":130,"y":80,"wires":[["2"]]},{"id":"2","type":"octopus-intelligent","name":"Octopus Intelligent","account":"A-XXXXXXXX","apiKey":"sk_live_...","refreshInterval":"5","enableMqtt":false,"x":340,"y":80,"wires":[["3"]]},{"id":"3","type":"debug","name":"Debug Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":570,"y":80,"wires":[]}]</pre>
78
+
79
+ <h4>2. Set Preferences from Flow</h4>
80
+ <p>Control charge limit and ready time programmatically:</p>
81
+ <pre>[{"id":"1","type":"inject","name":"Set 85% by 07:30","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"topic":"","payload":"{\"set_limit\":85,\"set_time\":\"07:30\"}","payloadType":"json","x":150,"y":140,"wires":[["2"]]},{"id":"2","type":"octopus-intelligent","name":"Octopus Intelligent","account":"A-XXXXXXXX","apiKey":"sk_live_...","refreshInterval":"5","enableMqtt":true,"mqttBroker":"mqtt-broker","x":380,"y":140,"wires":[["3"]]},{"id":"3","type":"debug","name":"Confirmation","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":610,"y":140,"wires":[]}]</pre>
82
+
83
+ <h4>3. Home Assistant MQTT Integration</h4>
84
+ <p>Automatically create Home Assistant entities via MQTT discovery:</p>
85
+ <pre>[{"id":"1","type":"inject","name":"Every 5 min","props":[{"p":"payload"}],"repeat":"300","crontab":"","once":true,"topic":"","payload":"","payloadType":"date","x":130,"y":200,"wires":[["2"]]},{"id":"2","type":"octopus-intelligent","name":"Octopus Intelligent","account":"A-XXXXXXXX","apiKey":"sk_live_...","refreshInterval":"5","enableMqtt":true,"mqttBroker":"mqtt-broker","x":340,"y":200,"wires":[["3"]]},{"id":"3","type":"debug","name":"Debug Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":570,"y":200,"wires":[]},{"id":"mqtt-broker","type":"mqtt-broker","name":"Home Assistant MQTT","broker":"localhost","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]</pre>
86
+
87
+ <h3>Visual Examples</h3>
88
+ <p><strong>Node-RED Flow Examples:</strong></p>
89
+ <img src="https://raw.githubusercontent.com/ASomerN/node-red-contrib-octopus-intelligent/master/images/examples/basic-monitoring-flow.png" alt="Node-RED Flow Examples" style="max-width: 100%; border: 1px solid #ddd; border-radius: 4px;">
90
+ <p style="margin-top: 8px;"><em>Reads by default, manually refreshable from a button, pass in commands to change charge time and percentage</em></p>
91
+
92
+ <p style="margin-top: 16px;"><strong>MQTT Integration:</strong></p>
93
+ <img src="https://raw.githubusercontent.com/ASomerN/node-red-contrib-octopus-intelligent/master/images/examples/mqtt-integration-flow.png" alt="MQTT Integration Flow" style="max-width: 100%; border: 1px solid #ddd; border-radius: 4px;">
94
+ <p style="margin-top: 8px;"><em>Complete MQTT integration with Home Assistant</em></p>
95
+
96
+ <p style="margin-top: 16px;"><strong>Home Assistant Device:</strong></p>
97
+ <img src="https://raw.githubusercontent.com/ASomerN/node-red-contrib-octopus-intelligent/master/images/examples/homeassistant-device.png" alt="Home Assistant Device" style="max-width: 100%; border: 1px solid #ddd; border-radius: 4px;">
98
+ <p style="margin-top: 8px;"><em>Octopus Intelligent device with all controls and sensors automatically configured</em></p>
99
+
100
+ <h3>Output Format</h3>
101
+ <p>The node outputs a message with the following structure:</p>
102
+ <pre>{
103
+ "payload": {
104
+ "next_start": "2025-11-29T01:30:00Z",
105
+ "total_energy": 42.5,
106
+ "next_kwh": "15.20",
107
+ "next_source": "smart-charge",
108
+ "confirmed_limit": 80,
109
+ "confirmed_time": "07:00",
110
+ "charging_now": false,
111
+ "slot1_start": "2025-11-29T01:30:00Z",
112
+ "slot1_end": "2025-11-29T05:30:00Z"
113
+ },
114
+ "debug": {
115
+ "success": true,
116
+ "step": "complete",
117
+ "apiCalls": [...]
118
+ }
119
+ }</pre>
120
+
121
+ <h3>Home Assistant Integration</h3>
122
+ <p>When MQTT is enabled, the node automatically creates:</p>
123
+ <ul>
124
+ <li><strong>Controls:</strong> Target charge slider, ready time selector, apply changes button</li>
125
+ <li><strong>Sensors:</strong> Next charge time, total energy, charging status, individual slots</li>
126
+ <li><strong>Binary Sensor:</strong> Charging now indicator (ON/OFF)</li>
127
+ </ul>
128
+ <p>All entities appear under a single "Octopus Intelligent" device in Home Assistant.</p>
129
+
130
+ <h3>Requirements</h3>
131
+ <ul>
132
+ <li>Octopus Energy account with Intelligent Octopus Go tariff</li>
133
+ <li>API key from <a href="https://octopus.energy/dashboard/new/accounts/personal-details/api-access" target="_blank">Octopus dashboard</a></li>
134
+ <li>MQTT broker (optional, for Home Assistant integration)</li>
135
+ </ul>
136
+
137
+ <p>See the <a href="https://github.com/ASomerN/node-red-contrib-octopus-intelligent/blob/master/README.md" target="_blank">full documentation</a> for details.</p>
138
+ </script>