node-red-contrib-octopus-intelligent 1.0.5 → 1.1.1

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,45 @@ 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.1.1] - 2026-04-26
9
+
10
+ ### Security
11
+ - **Removed `axios` dependency** — replaced with Node.js built-in `https` module; eliminates 13 transitive packages and all associated supply chain risk
12
+ - **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
13
+ - **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
14
+
15
+ ### Changed
16
+ - Package size reduced from 369 kB → 27 kB (93% reduction)
17
+ - Zero production dependencies (was: `axios ^1.6.0`)
18
+
19
+ ---
20
+
21
+ ## [1.1.0] - 2026-04-24
22
+
23
+ ### Added
24
+ - **Locale Timestamps** — new `*_locale` fields in every payload, always in server auto-detected timezone
25
+ - `slot1_start_locale`, `slot1_end_locale`, `slot2_start_locale`, `slot2_end_locale`
26
+ - `slot3_start_locale`, `slot3_end_locale`, `window_start_locale`, `window_end_locale`
27
+ - `next_start_locale`
28
+ - **Timezone Metadata** — `timezone_detected` (server auto-detect) and `timezone_applied` (active TZ for display fields)
29
+ - **HA Timezone Select Entity** — `select.octopus_timezone` with 15 curated IANA timezones covering all Octopus operating countries (UK, AU, DE, ES, NZ, US)
30
+ - Selection persists across Node-RED restarts via node context storage
31
+ - State republished to HA on Node-RED startup
32
+ - **`set_timezone` Input Command** — `msg.payload = { set_timezone: "Europe/London" }`, same pattern as `set_limit`/`set_time`
33
+ - **`timezoneOverride` Node Config Field** — optional IANA timezone in node editor, leave blank for auto-detect
34
+ - **Timezone Diagnostic Sensors** — `sensor.octopus_timezone_detected` and `sensor.octopus_timezone_applied`
35
+
36
+ ### Changed
37
+ - **Display timestamp fields now output resolved timezone** instead of raw UTC
38
+ - Affected fields: `slot1_start`, `slot1_end`, `slot2_start`, `slot2_end`, `slot3_start`, `slot3_end`, `window_start`, `window_end`, `next_start`
39
+ - Resolution order: HA-persisted selection → `timezoneOverride` config → server auto-detected
40
+ - **Raw fields (`*_raw`) remain unchanged** — always exact UTC strings from the API
41
+
42
+ ### Technical
43
+ - Zero new npm dependencies — native `Intl.DateTimeFormat` API (Node 14 compatible)
44
+ - `convertToTimezone(dateStr, tz)` — handles DST correctly, falls back to original string on error
45
+ - `resolveTimezone(node)` — reads node context storage, config field, or server auto-detect
46
+
8
47
  ## [1.0.5] - 2025-12-31
9
48
 
10
49
  ### Fixed
package/README.md CHANGED
@@ -77,6 +77,13 @@ 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
+ ### 🌍 Timezone Support
81
+ - **Locale Timestamps** (`*_locale` fields) — always in server auto-detected timezone
82
+ - **Resolved Display Fields** — slot and window times in your configured timezone
83
+ - **HA Timezone Select** — change timezone from Home Assistant without redeploying
84
+ - **Node Config Override** — set IANA timezone directly in the node editor
85
+ - **Zero Dependencies** — native `Intl` API, no new packages
86
+
80
87
  ---
81
88
 
82
89
  ## 📸 Screenshots
@@ -84,7 +91,7 @@ If this project has helped you!
84
91
  ### Node-RED Flow Examples
85
92
 
86
93
  #### Basic Monitoring & Control
87
- ![Node-RED Flow Examples](images/examples/basic-monitoring-flow.png)
94
+ ![Node-RED Flow Examples](https://raw.githubusercontent.com/ASomerN/node-red-contrib-octopus-intelligent/master/images/examples/basic-monitoring-flow.png)
88
95
 
89
96
  This example flow demonstrates three key usage patterns:
90
97
 
@@ -101,7 +108,7 @@ This example flow demonstrates three key usage patterns:
101
108
  **How to use:** Import any of these flows, configure your Account Number and API Key in the Octopus Intelligent node, and deploy!
102
109
 
103
110
  #### MQTT Integration with Home Assistant
104
- ![MQTT Integration Flow](images/examples/mqtt-integration-flow.png)
111
+ ![MQTT Integration Flow](https://raw.githubusercontent.com/ASomerN/node-red-contrib-octopus-intelligent/master/images/examples/mqtt-integration-flow.png)
105
112
 
106
113
  This flow shows the complete MQTT setup:
107
114
 
@@ -114,7 +121,7 @@ This flow shows the complete MQTT setup:
114
121
 
115
122
  ### Home Assistant Auto-Configured Entities
116
123
 
117
- ![Home Assistant Device](images/examples/homeassistant-device-v1.0.4.png)
124
+ ![Home Assistant Device](https://raw.githubusercontent.com/ASomerN/node-red-contrib-octopus-intelligent/master/images/examples/homeassistant-device-v1.0.4.png)
118
125
 
119
126
  After enabling MQTT in the Node-RED node, Home Assistant automatically creates:
120
127
 
@@ -123,6 +130,7 @@ After enabling MQTT in the Node-RED node, Home Assistant automatically creates:
123
130
  - **Ready Time** - Dropdown selector (04:00-11:00) for when car needs to be ready
124
131
  - **Apply Changes** - Button to submit new settings (prevents API spam while adjusting)
125
132
  - **Refresh API** - Button to force manual refresh (30-second cooldown prevents spam)
133
+ - **Timezone** — Select entity for choosing display timezone (15 IANA options, persists across restarts)
126
134
 
127
135
  #### Sensors (Main Section)
128
136
  - **Confirmed Charge Limit** - Current API-validated charge limit
@@ -132,6 +140,9 @@ After enabling MQTT in the Node-RED node, Home Assistant automatically creates:
132
140
  - **Total Planned Energy** - Total kWh across all upcoming slots
133
141
  - **Slot 1, 2, 3 Start/End** - Individual charging slot times
134
142
  - **Overall Window Start/End** - First slot start to last slot end
143
+ - **Slot 1, 2, 3 Start/End (Locale)** — Same slots in server auto-detected timezone
144
+ - **Overall Window Start/End (Locale)** — Window times in server auto-detected timezone
145
+ - **Next Charge Time (Locale)** — Next charge start in server auto-detected timezone
135
146
  - **Charging Now** - Binary sensor (ON/OFF) showing if actively charging
136
147
 
137
148
  #### Diagnostics (Raw timestamps and monitoring)
@@ -139,6 +150,8 @@ After enabling MQTT in the Node-RED node, Home Assistant automatically creates:
139
150
  - **API Requests (Last Hour)** - Number of API calls in the last 60 minutes
140
151
  - **API Complexity (Last Hour)** - Total complexity used (max 50,000/hour)
141
152
  - **API Complexity Usage** - Percentage of hourly API limit used
153
+ - **Timezone Detected** — Server's auto-detected timezone (e.g. `Europe/London`)
154
+ - **Timezone Applied** — Active timezone used for display fields
142
155
  - **Raw timestamp sensors** - Exact API responses for all sensors
143
156
  - Useful for debugging, advanced automations, and monitoring API usage
144
157
 
@@ -201,6 +214,7 @@ number.octopus_target_charge Battery charge limit (50-100%)
201
214
  select.octopus_ready_time Ready by time (04:00-11:00)
202
215
  button.octopus_apply_changes Submit changes to API
203
216
  button.octopus_refresh_api Manual refresh (30s cooldown)
217
+ select.octopus_timezone Display timezone (15 IANA options)
204
218
  ```
205
219
 
206
220
  ### Main Sensors
@@ -216,6 +230,11 @@ sensor.octopus_slot_[1-3]_start Individual slot starts
216
230
  sensor.octopus_slot_[1-3]_end Individual slot ends
217
231
  sensor.octopus_overall_window_start First slot start
218
232
  sensor.octopus_overall_window_end Last slot end
233
+ sensor.octopus_next_charge_locale Next charge start (server TZ)
234
+ sensor.octopus_slot_[1-3]_start_locale Individual slot starts (server TZ)
235
+ sensor.octopus_slot_[1-3]_end_locale Individual slot ends (server TZ)
236
+ sensor.octopus_overall_window_start_locale Window start (server TZ)
237
+ sensor.octopus_overall_window_end_locale Window end (server TZ)
219
238
  ```
220
239
 
221
240
  ### Diagnostics (Raw Timestamps & Monitoring)
@@ -235,10 +254,51 @@ sensor.octopus_slot_[1-3]_start_raw Raw slot start times
235
254
  sensor.octopus_slot_[1-3]_end_raw Raw slot end times
236
255
  sensor.octopus_overall_window_start_raw Raw window start
237
256
  sensor.octopus_overall_window_end_raw Raw window end
257
+
258
+ # Timezone Diagnostics
259
+ sensor.octopus_timezone_detected Server auto-detected timezone
260
+ sensor.octopus_timezone_applied Active timezone used for display fields
238
261
  ```
239
262
 
240
263
  ---
241
264
 
265
+ ## 🌍 Timezone Configuration
266
+
267
+ By default, slot and window times are converted to the **server's auto-detected timezone** (wherever Node-RED is running). Three ways to configure:
268
+
269
+ ### Option 1: Node Config (static)
270
+ Set a fixed IANA timezone in the node editor:
271
+ - Open node → **Timezone** field → type `Australia/Sydney`
272
+ - Applies to all display fields (`slot1_start`, `window_start`, etc.)
273
+ - Leave blank to use server auto-detect
274
+
275
+ ### Option 2: Home Assistant Select (dynamic, persists across restarts)
276
+ Use the **Timezone** select entity in Home Assistant:
277
+ - Home Assistant → Octopus Intelligent device → Timezone
278
+ - Change takes effect on next poll
279
+ - Persists across Node-RED restarts
280
+
281
+ ### Option 3: `set_timezone` Input Command
282
+ ```javascript
283
+ msg.payload = { set_timezone: "Europe/London" };
284
+ // Send to Octopus Intelligent node input
285
+ ```
286
+ Saved to node context, applies on next poll.
287
+
288
+ ### Timestamp Tiers
289
+ | Field suffix | Timezone | Configurable? |
290
+ |-------------|----------|---------------|
291
+ | `*_raw` | Always UTC (exact API string) | Never |
292
+ | `*_locale` | Server auto-detected | Never (always server TZ) |
293
+ | Display fields (`slot1_start`, `window_start`, etc.) | Resolved TZ | Yes — via HA, config, or command |
294
+
295
+ ### Supported Timezones (HA select)
296
+ `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`
297
+
298
+ Any valid IANA timezone works in the node config field or `set_timezone` command.
299
+
300
+ ---
301
+
242
302
  ## 💡 Node-RED Usage
243
303
 
244
304
  ### Basic Monitoring
@@ -257,12 +317,21 @@ msg.payload = {
257
317
  return msg;
258
318
  ```
259
319
 
320
+ ### Set Timezone from Flow
321
+
322
+ ```javascript
323
+ msg.payload = { set_timezone: "Australia/Sydney" };
324
+ return msg;
325
+ ```
326
+
327
+ Valid values: any IANA timezone string (e.g. `Europe/London`, `UTC`, `America/New_York`).
328
+
260
329
  ### Output Format
261
330
 
262
331
  ```json
263
332
  {
264
333
  "payload": {
265
- "next_start": "2025-11-29T01:30:00Z",
334
+ "next_start": "2025-11-29 01:30:00+00:00",
266
335
  "total_energy": 42.5,
267
336
  "next_kwh": "15.20",
268
337
  "next_source": "smart-charge",
@@ -276,8 +345,15 @@ return msg;
276
345
  "api_requests_hour": 12,
277
346
  "api_complexity_hour": 3600,
278
347
  "api_complexity_percent": 7.2,
279
- "slot1_start": "2025-11-29T01:30:00Z",
280
- "slot1_end": "2025-11-29T05:30:00Z"
348
+ "slot1_start": "2025-11-29 01:30:00+00:00",
349
+ "slot1_end": "2025-11-29 05:30:00+00:00",
350
+ "timezone_detected": "Europe/London",
351
+ "timezone_applied": "Europe/London",
352
+ "next_start_locale": "2025-11-29 01:30:00+00:00",
353
+ "slot1_start_locale": "2025-11-29 01:30:00+00:00",
354
+ "slot1_end_locale": "2025-11-29 05:30:00+00:00",
355
+ "window_start_locale": "2025-11-29 01:30:00+00:00",
356
+ "window_end_locale": "2025-11-29 05:30:00+00:00"
281
357
  },
282
358
  "debug": {
283
359
  "success": true,
@@ -459,7 +535,12 @@ Use at your own risk. The Octopus Energy name and logo are trademarks of Octopus
459
535
 
460
536
  See [CHANGELOG.md](CHANGELOG.md) for detailed version history and release notes.
461
537
 
462
- ### Latest Release: v1.0.5 (2025-12-31)
538
+ ### Latest Release: v1.1.1 (2026-04-26)
539
+ - **Timezone Support** - Locale timestamps, HA timezone select entity, `set_timezone` command
540
+ - **`*_locale` Sensors** - All slot/window times in server auto-detected timezone
541
+ - **Configurable Display Timezone** - Override via node config, HA select, or flow command
542
+
543
+ ### Previous Release: v1.0.5 (2025-12-31)
463
544
  - **Documentation Fix** - Corrected misleading "branded device cards" claim in README
464
545
 
465
546
  ### 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>