node-red-contrib-octopus-intelligent 1.5.0 โ†’ 1.6.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +487 -442
  2. package/README.md +1004 -980
  3. package/examples/basic-monitoring.json +1 -1
  4. package/examples/ha-dashboard.yaml +602 -599
  5. package/examples/mqtt-integration.json +1 -1
  6. package/examples/node-red-dashboard-flow.json +1287 -1199
  7. package/examples/set-preferences.json +1 -1
  8. package/lib/api-metrics.js +31 -31
  9. package/lib/auth.js +20 -20
  10. package/lib/categories/account.js +32 -32
  11. package/lib/categories/applicable-rates.js +127 -127
  12. package/lib/categories/completed-dispatches.js +35 -35
  13. package/lib/categories/electricity.js +146 -146
  14. package/lib/categories/flex-planned-dispatches.js +36 -36
  15. package/lib/categories/free-electricity.js +61 -61
  16. package/lib/categories/gas.js +95 -95
  17. package/lib/categories/home-mini.js +37 -37
  18. package/lib/categories/intelligent.js +155 -124
  19. package/lib/categories/octoplus.js +32 -32
  20. package/lib/categories/saving-sessions.js +64 -64
  21. package/lib/categories/wheel-of-fortune.js +49 -49
  22. package/lib/commands.js +47 -0
  23. package/lib/discovery-retry.js +13 -0
  24. package/lib/discovery.js +92 -85
  25. package/lib/graphql-errors.js +18 -0
  26. package/lib/graphql.js +44 -44
  27. package/lib/http-get-json.js +22 -22
  28. package/lib/payload.js +89 -88
  29. package/lib/poll-tick.js +44 -44
  30. package/lib/preferences.js +32 -0
  31. package/lib/scheduler.js +47 -47
  32. package/lib/sensor-definitions.js +219 -0
  33. package/lib/timezone.js +49 -49
  34. package/lib/update-check.js +38 -38
  35. package/octopus-intelligent.html +218 -205
  36. package/octopus-intelligent.js +1687 -1807
  37. package/package.json +54 -54
package/README.md CHANGED
@@ -1,980 +1,1004 @@
1
- # node-red-contrib-octopus-intelligent
2
-
3
- > Node-RED integration for **Octopus Energy** with automatic Home Assistant MQTT discovery
4
-
5
- Monitor electricity and gas rates (import + export), EV charging schedules, real-time home energy usage, account balance, saving sessions, and Wheel of Fortune spins โ€” all automatically configured as Home Assistant entities via MQTT discovery.
6
-
7
- [![npm version](https://badge.fury.io/js/node-red-contrib-octopus-intelligent.svg)](https://www.npmjs.com/package/node-red-contrib-octopus-intelligent)
8
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
-
10
- ---
11
-
12
- ## ๐Ÿค Support This Project
13
-
14
- Found this useful? Support continued development:
15
-
16
- <table>
17
- <tr>
18
- <td width="33%" align="center">
19
-
20
- ### โญ GitHub Star
21
- Star the repository to show your support!
22
-
23
- [โญ Star on GitHub](https://github.com/ASomerN/node-red-contrib-octopus-intelligent)
24
-
25
- </td>
26
- <td width="33%" align="center">
27
-
28
- ### ๐Ÿ’– Sponsor
29
- Support ongoing development and maintenance
30
-
31
- [Become a Sponsor](https://github.com/sponsors/ASomerN)
32
-
33
- </td>
34
- <td width="33%" align="center">
35
-
36
- ### โ˜• Buy Me a Coffee
37
- If this project has helped you!
38
-
39
- [![Donate with PayPal](https://www.paypalobjects.com/en_GB/i/btn/btn_donate_LG.gif)](https://www.paypal.com/donate?hosted_button_id=A2B8ZFEJBE2S6)
40
-
41
- </td>
42
- </tr>
43
- </table>
44
-
45
- **Your support helps with:** Bug fixes and maintenance โ€ข New feature development โ€ข Documentation improvements โ€ข Community support โ€ข Feeding my children
46
-
47
- ---
48
-
49
- ## โœจ Features
50
-
51
- ### ๐ŸŽฎ EV Smart Controls
52
- - **Target Charge Slider** (50โ€“100%) โ€” Set your desired battery level
53
- - **Ready Time Dropdown** (04:00โ€“11:00) โ€” When your car needs to be ready
54
- - **Apply Changes Button** โ€” Prevents API spam while adjusting settings
55
- - **Confirmed Values** โ€” See your current API-validated settings
56
- - **Smart Charging Toggle** โ€” Suspend or resume Octopus intelligent charging from Node-RED or Home Assistant
57
-
58
- ### โšก Real-Time Charging Data
59
- - **Next Charge Time** โ€” When your next slot starts
60
- - **Total Planned Energy** โ€” Total kWh across all upcoming slots
61
- - **Individual Slot Times** โ€” Up to 3 slots with start/end times
62
- - **Charging Window** โ€” Overall window from first to last slot
63
- - **Charge Source** โ€” Smart-charge vs bump-charge indicator
64
- - **Completed Dispatches** โ€” History of completed intelligent charging sessions
65
- - **Flex Planned Dispatches** โ€” Upcoming flex dispatch schedule
66
-
67
- ### ๐Ÿ”Œ Electricity & Gas Rates
68
- - **Live Unit Rate** โ€” Current electricity rate (p/kWh) and gas rate (p/kWh)
69
- - **Standing Charges** โ€” Daily standing charges for electricity and gas
70
- - **Tariff Code** โ€” Your current tariff identifier and validity dates
71
- - **Recent Consumption** โ€” Previous day kWh for electricity (import + export) and gas
72
- - **Current Rate Slot** โ€” Live rate from your 24h applicable rates schedule
73
- - **Previous / Next Rate** โ€” Adjacent slot rates and transition timestamps
74
- - **Energy Dashboard Rate** โ€” Electricity rate in GBP/kWh, ready for HA's Energy Dashboard cost tracking
75
-
76
- ### ๐ŸŒž Electricity Export (Solar / Battery)
77
- - **Export Tariff** โ€” Tariff code, standing charge, validity dates for the OUTGOING agreement
78
- - **Export Half-Hourly Rates** โ€” Full 48-slot schedule for variable export tariffs (e.g. Agile Outgoing)
79
- - **Live Export Rate** โ€” Current p/kWh and GBP/kWh
80
- - **Previous / Next Export Rate** โ€” Adjacent slot rates and transition timestamps
81
- - **Export Consumption** โ€” Previous day kWh exported to the grid (read from the export meter point)
82
-
83
- ### ๐Ÿ  Home Energy (Octopus Home Mini)
84
- - **Live Demand** โ€” Real-time grid import in kW
85
- - **Period Consumption** โ€” Energy consumed in the last half-hour period (kWh)
86
- - Requires Octopus Home Mini device registered to your account (opt-in)
87
-
88
- ### ๐Ÿ’ฐ Account & Rewards
89
- - **Account Balance** โ€” Current credit/debit balance in ยฃ
90
- - **Saving Sessions** โ€” Next session availability, start/end times, joined status, and Octopus Points
91
- - **Free Electricity** โ€” Upcoming free electricity window detection (active Juneโ€“October)
92
- - **Wheel of Fortune** โ€” Remaining electricity and gas spins (opt-in)
93
- - **Octoplus** โ€” Enrollment status and loyalty points
94
-
95
- ### ๐Ÿ”ง Advanced Features
96
- - **Account Discovery** โ€” Automatic product detection at startup; categories auto-enable based on registered products
97
- - **Per-Category Polling** โ€” Each data category polls on its own configurable interval
98
- - **Manual Refresh Button** โ€” Force API refresh from Home Assistant (30s cooldown)
99
- - **Next Poll Timer** โ€” See when the next automatic refresh will occur
100
- - **API Usage Tracking** โ€” Monitor requests and complexity in diagnostics
101
- - **Exponential Backoff** โ€” Smart retry prevents sensor unavailability
102
- - **Comprehensive Debugging** โ€” Full API call tracking in msg.debug
103
-
104
- ### ๐Ÿก Home Assistant Integration
105
- - **Zero Configuration** โ€” MQTT auto-discovery sets everything up
106
- - **Two-Tier Entity Organisation** โ€” Main entities (controls, live rates, consumption, tariff metadata, rewards) and Diagnostics (errors, raw timestamps, API metrics, locale timestamps)
107
- - **Suggested Area** โ€” Auto-suggests "Energy" area
108
- - **Reference dashboard YAML** โ€” `examples/ha-dashboard.yaml` covers every entity in a packed sections layout, ready to paste into HA's Raw Configuration Editor
109
-
110
- ### ๐ŸŒ Timezone Support
111
- - **Locale Timestamps** (`*_locale` fields) โ€” always in server auto-detected timezone
112
- - **Resolved Display Fields** โ€” slot and window times in your configured timezone
113
- - **HA Timezone Select** โ€” change timezone from Home Assistant without redeploying
114
- - **Node Config Override** โ€” set IANA timezone directly in the node editor
115
- - **Zero Dependencies** โ€” native `Intl` API, no new packages
116
-
117
- ---
118
-
119
- ## ๐Ÿ“ธ Screenshots
120
-
121
- ### Node Configuration
122
-
123
- ![Node Configuration](images/examples/Octopus%20Intelligent%20Node.png)
124
-
125
- Configure your account credentials, polling intervals, and MQTT broker in the node editor. The MQTT Broker dropdown connects directly to your Home Assistant Mosquitto instance. Per-category intervals let you tune how often each data source is polled โ€” electricity and gas rates update hourly by default, while Home Mini polls every minute for live demand.
126
-
127
- ### Node-RED Flow Example
128
-
129
- ![Node-RED Flow Example](images/examples/basic-monitoring-flow.png)
130
-
131
- ### Home Assistant โ€” Dashboard
132
-
133
- `examples/ha-dashboard.yaml` is a comprehensive Lovelace dashboard that exposes every entity the plugin publishes. Paste it into HA's Raw Configuration Editor to get the layout below. The layout uses HA's sections view and packs cards uniformly across up to 4 columns on wide screens.
134
-
135
- #### EV controls, electricity import & export
136
-
137
- ![Dashboard โ€” EV, electricity import + export](images/examples/home_assistant_dashboard_1_1-3-0.png)
138
-
139
- EV target slider and ready-time dropdown at top, then live import rate / standing / today's kWh, full import tariff card, half-hourly applicable rates summary, and the same trio for export (live export rate, export tariff, export consumption, half-hourly Agile Outgoing rates).
140
-
141
- #### Gas, account, rewards, Home Mini
142
-
143
- ![Dashboard โ€” gas, account, rewards, Home Mini](images/examples/home_assistant_dashboard_2_1-3-0.png)
144
-
145
- Gas rate / standing / consumption + tariff. Account balance, Octoplus enrolment, Saving Sessions card, Free Electricity card, Wheel of Fortune spins, and the Home Mini live-demand gauge with current half-hour kWh.
146
-
147
- #### Diagnostics โ€” UTC timestamps, raw timestamps, errors
148
-
149
- ![Dashboard โ€” diagnostics](images/examples/home_assistant_dashboard_3_1-3-0.png)
150
-
151
- UTC-class slot/window timestamps (HA renders them as relative "n hours ago"), raw API strings for verbatim debugging, timezone + API usage rows, and a consolidated error panel covering every category.
152
-
153
- #### Gas โ€” live data from a real account
154
-
155
- ![Dashboard โ€” gas live data](images/examples/home_assistant_dashboard_working_gas_1-3-0.png)
156
-
157
- For accounts with a gas meter point, the gas card populates with live tariff code, unit rate (p/kWh), standing charge, daily consumption (kWh), and tariff validity dates. Above shows v1.3.0 reading correctly from a real account on Octopus standard variable gas tariff.
158
-
159
- #### Seasonal / conditional entities โ€” when they show "Unavailable"
160
-
161
- | Sensor | Active period | Outside season / condition |
162
- |---|---|---|
163
- | Saving Session Start / End | Octoberโ€“March | `null` โ€” no sessions scheduled |
164
- | Free Electricity Start / End | typically Juneโ€“October | `null` โ€” no sessions scheduled |
165
- | Electricity / Gas Tariff Valid To | When tariff has an end date | `null` โ€” open-ended tariff |
166
- | Gas entities | Only if account has a gas meter point | `null` โ€” electricity-only accounts |
167
- | Home Mini | Only if a Home Mini device is registered | Entity skipped if not registered |
168
- | Electricity Export entities | Only if account has an OUTGOING agreement | Entity values null without an export tariff |
169
- | EV planned slots / dispatches | Only when a charge is scheduled | `null` between plug-in cycles |
170
-
171
- These are normal MQTT behaviours, not bugs. The plugin publishes the entity definitions so HA registers them; their values populate when the API returns data for that period.
172
-
173
- ---
174
-
175
- ## ๐Ÿ“‹ Requirements
176
-
177
- - **Node-RED** v2.0+
178
- - **Octopus Energy Account** โ€” any electricity account works for rates/consumption/account data
179
- - [Intelligent Octopus Go](https://octopus.energy/intelligent/) tariff required for EV charging features
180
- - Octopus Home Mini device required for real-time consumption (opt-in)
181
- - Wheel of Fortune is opt-in and requires an active electricity agreement
182
- - **API Key** โ€” [Generate here](https://octopus.energy/dashboard/new/accounts/personal-details/api-access)
183
- - **MQTT Broker** (optional, for Home Assistant integration)
184
- - **Home Assistant** (optional, for MQTT features)
185
-
186
- ---
187
-
188
- ## ๐Ÿš€ Quick Start
189
-
190
- ### 1. Install via Node-RED Palette
191
-
192
- 1. Open Node-RED โ†’ **Menu** โ†’ **Manage Palette**
193
- 2. **Install** tab โ†’ Search `node-red-contrib-octopus-intelligent`
194
- 3. Click **Install**
195
-
196
- ### 2. Get Your Credentials
197
-
198
- **Account Number** (format: `A-XXXXXXXX`):
199
- - Found at https://octopus.energy/dashboard/
200
-
201
- **API Key** (format: `sk_live_...`):
202
- - Get from https://octopus.energy/dashboard/new/accounts/personal-details/api-access
203
- - Click "Generate API Key"
204
-
205
- ### 3. Configure the Node
206
-
207
- 1. Drag **Octopus Intelligent** into your flow
208
- 2. Double-click to configure:
209
- - Account Number (format: `A-XXXXXXXX`)
210
- - API Key (stored securely)
211
- - Refresh Interval (default: 5 min โ€” controls EV charging data polling)
212
- - Per-category polling intervals (electricity, gas, etc.)
213
- - โ˜‘ Enable Home Mini โ€” tick if you have an Octopus Home Mini device
214
- - โ˜‘ Enable Wheel of Fortune โ€” tick to track remaining spins
215
- - Enable MQTT if using Home Assistant and select your MQTT broker
216
- 3. **Deploy** โ€” account discovery runs automatically and enables categories based on your registered products
217
-
218
- ### 4. Home Assistant (Optional)
219
-
220
- If MQTT enabled:
221
- 1. Wait ~5 seconds after deploy
222
- 2. **Settings** โ†’ **Devices & Services** โ†’ **MQTT**
223
- 3. Find "Octopus Intelligent" device
224
- 4. All entities created automatically โ€” no YAML required
225
-
226
- ---
227
-
228
- ## โฌ†๏ธ Upgrading from v1.2.x
229
-
230
- v1.3.0 is additive โ€” no breaking changes. Existing flows, automations, and dashboards continue working unchanged.
231
-
232
- **What happens on upgrade:**
233
- - All existing entity IDs are preserved (HA's MQTT integration matches by `unique_id`, which is stable)
234
- - All v1.2.x payload fields remain in the same positions
235
- - ~70 new sensors appear in Home Assistant automatically after first poll โ€” electricity import/export tariff and rates, gas tariff and consumption, Home Mini, Octoplus, saving sessions, free electricity, Wheel of Fortune, account balance, applicable rates
236
- - New node config options (Home Mini, Wheel of Fortune) default to off
237
- - Two existing Octoplus booleans (`octoplus_enrolled`, `octoplus_loyalty_points_user`) move from `sensor.` to `binary_sensor.` domain โ€” a fresh install picks the right domain automatically; a clean upgrade may register both. Delete the old `sensor.` entries via Dev Tools if you want a tidy device card.
238
-
239
- If you installed an early dev build of v1.3 and have stale entities in Home Assistant, see [Stale Entities After Early v1.3 Dev Build](#stale-entities-after-early-v13-dev-build) in the Troubleshooting section.
240
-
241
- ---
242
-
243
- ## ๐Ÿ“Š Home Assistant Entities
244
-
245
- **121 MQTT entities** are published under a single **Octopus Intelligent** device on a fresh install โ€” verified against a live install. All entities are organised into two tiers: **Main** (controls, live data, tariff metadata, rewards) and **Diagnostics** (errors, raw timestamps, locale timestamps, API metrics).
246
-
247
- If your device card shows more than 121 entities, the extras are likely leftovers from earlier installed versions or interrupted discovery. They can be deleted via Settings โ†’ Devices & Services โ†’ MQTT โ†’ Octopus Intelligent โ†’ entity โ†’ cog โ†’ "Delete from registry" without affecting current operation.
248
-
249
- ### Node-RED payload vs MQTT entities
250
-
251
- `msg.payload` from the Node-RED node contains **~132 fields** โ€” 11 more than the MQTT entities count. The "extra" payload fields are intentionally **not** exposed as individual HA entities; they exist for template/automation use inside Node-RED or HA Jinja:
252
-
253
- | Category | Fields (count) | Why no MQTT entity |
254
- |---|---|---|
255
- | Bulk array data | `applicable_rates`, `electricity_export_rate`, `completed_dispatches`, `flex_planned_dispatches` (4) | Each is an array of 48 half-hour slots or N dispatches. Exposing each row as an MQTT entity would clutter the registry. The `_count` summary entity exists; consume the full array via templates / `apexcharts-card` for visualisation. |
256
- | Pending controls | `pending_limit`, `pending_time` (2) | The number/select control entities (`Target Charge`, `Ready By`) render the pending value through their own `value_template`. No separate sensor entity needed. |
257
- | Import rate adjacency | `applicable_rates_prev_pence`, `_prev_gbp`, `_prev_to`, `_next_pence`, `_next_gbp`, `_next_from` (6) | Available in `msg.payload` for templates / dashboards. Export equivalents (`electricity_export_rate_prev_*` / `_next_*`) ARE exposed as MQTT entities โ€” the inconsistency is intentional pending v1.4 promotion. |
258
- | Cost placeholders | `electricity_consumption_cost`, `gas_consumption_cost` (2) | Reserved for future cost-calculation feature (consumption ร— rate). Always `null` in v1.3. |
259
- | Vestigial | `saving_session_points` (1) | Octopus moved loyalty points out of saving sessions into the Octoplus query. The payload field remains for backward compatibility but is always `null`; use `binary_sensor.octopus_intelligent_octopus_octoplus_loyalty_points` instead. |
260
-
261
- **Implication for HA users:** every value you might want to display is reachable. Direct values use the MQTT entity. Adjacent-slot import rates require an MQTT template sensor reading from `applicable_rates_prev_pence` etc. (or use the Node-RED debug node to inspect the full payload).
262
-
263
- **Why the import / export asymmetry?** Phase 2 of v1.3.0 added the full export rate ecosystem as new MQTT entities. The pre-existing import prev/next fields were added in v1.0 as payload-only and weren't promoted at the time. Promoting them is straightforward but was descoped from v1.3 to keep release scope tight; tracked for v1.4.
264
-
265
- ### Controls
266
-
267
- Interactive entities that accept commands. **Timezone** and **Smart Charging** still carry the HA `entity_category: config` flag (they ARE user-configurable, so the category is semantically correct).
268
-
269
- | Name | Description |
270
- |---|---|
271
- | Octopus Target Charge | Slider (50โ€“100%) โ€” set desired battery charge level; shows the pending value until applied |
272
- | Octopus Ready Time | Dropdown (04:00โ€“11:00) โ€” time by which the car must be ready |
273
- | Octopus Apply Changes | Submit pending limit/time changes to the Octopus API |
274
- | Octopus Refresh API | Force an immediate API refresh (30-second cooldown enforced) |
275
- | Timezone | Display timezone for all slot and window times โ€” 15 IANA options; persists across Node-RED restarts |
276
- | Smart Charging | Enable (unsuspend) or disable (suspend) Octopus intelligent charging |
277
-
278
- ### Binary Sensors
279
-
280
- | Name | Description |
281
- |---|---|
282
- | Octopus Charging Now | `ON` while the EV is actively inside a dispatch charging slot |
283
- | Octopus Saving Session Available | `ON` if a saving session is upcoming or joinable |
284
- | Octopus Free Electricity Active | `ON` while a free electricity window is in progress right now |
285
- | Octopus Free Electricity Available | `ON` if a free electricity window is scheduled in the future |
286
- | Octopus Octoplus Enrolled | `ON` if the account is enrolled in Octoplus |
287
- | Octopus Octoplus Loyalty Points | `ON` if the account participates in Octoplus loyalty points (boolean flag from the API) |
288
-
289
- ### Main Sensors โ€” EV Charging
290
-
291
- | Name | Description |
292
- |---|---|
293
- | Octopus Confirmed Charge Limit | API-confirmed target charge percentage โ€” last setting accepted by Octopus |
294
- | Octopus Confirmed Ready Time | API-confirmed ready time โ€” last setting accepted by Octopus |
295
- | Octopus Next Charge Time | Start time of the next planned charging slot (display timezone) |
296
- | Octopus Total Planned Energy | Total kWh across all upcoming planned dispatch slots |
297
- | Octopus Next Slot Energy | Energy (kWh) scheduled for the next individual slot |
298
- | Octopus Charge Source | Source of next charge: `smart-charge` (scheduled by Octopus algorithm) or `bump-charge` (car plugged in outside schedule) |
299
- | Octopus Slot 1 Start | Start time of planned slot 1 |
300
- | Octopus Slot 1 End | End time of planned slot 1 |
301
- | Octopus Slot 2 Start | Start time of planned slot 2 (`null` if fewer than 2 slots) |
302
- | Octopus Slot 2 End | End time of planned slot 2 |
303
- | Octopus Slot 3 Start | Start time of planned slot 3 (`null` if fewer than 3 slots) |
304
- | Octopus Slot 3 End | End time of planned slot 3 |
305
- | Octopus Overall Window Start | Start of the first planned slot โ€” when the charging window opens |
306
- | Octopus Overall Window End | End of the last planned slot โ€” when the charging window closes |
307
- | Octopus Completed Dispatches | Count of completed intelligent dispatch sessions on record |
308
- | Octopus Flex Planned Dispatches | Count of upcoming flex dispatch slots |
309
-
310
- ### Main Sensors โ€” Electricity (Import)
311
-
312
- | Name | Description |
313
- |---|---|
314
- | Octopus Electricity Standing Charge | Daily electricity standing charge (p/day) from current tariff |
315
- | Octopus Electricity Consumption | Electricity consumed in the previous day (kWh) from the import meter |
316
- | Octopus Current Electricity Rate | Live unit rate (p/kWh) from the 24h applicable rates schedule โ€” use this on half-hourly tariffs (e.g. Intelligent Octopus Go) instead of Electricity Unit Rate |
317
- | Octopus Electricity Rate | Live unit rate in GBP/kWh โ€” measurement state class, ready for the HA Energy Dashboard |
318
- | Octopus Electricity Unit Rate | Fixed unit rate (p/kWh) โ€” `null` on half-hourly tariffs |
319
- | Octopus Electricity Tariff Code | Current import tariff product code |
320
- | Octopus Electricity Tariff Valid From / Valid To | Validity window of the current import tariff (`Valid To` is `null` for open-ended tariffs) |
321
-
322
- ### Main Sensors โ€” Electricity (Export)
323
-
324
- | Name | Description |
325
- |---|---|
326
- | Octopus Electricity Export Standing Charge | Daily export standing charge (p/day) โ€” typically `0` for Agile Outgoing |
327
- | Octopus Electricity Export Consumption | Electricity exported to the grid in the previous day (kWh) from the export meter |
328
- | Octopus Current Electricity Export Rate | Live export rate (p/kWh) for the current half-hour slot |
329
- | Octopus Electricity Export Rate | Live export rate (GBP/kWh) โ€” measurement state class |
330
- | Octopus Electricity Export Unit Rate | Fixed unit rate โ€” `null` on half-hourly export tariffs (e.g. Agile Outgoing) |
331
- | Octopus Electricity Export Tariff Code | Current export tariff product code (e.g. `AGILE-OUTGOING-19-05-13`) |
332
- | Octopus Electricity Export Tariff Valid From / Valid To | Validity window of the current export tariff |
333
-
334
- ### Main Sensors โ€” Gas
335
-
336
- | Name | Description |
337
- |---|---|
338
- | Octopus Gas Standing Charge | Daily gas standing charge (p/day) from current tariff |
339
- | Octopus Gas Consumption | Gas consumed in the previous day (kWh) |
340
- | Octopus Gas Unit Rate | Gas unit rate (p/kWh) |
341
- | Octopus Gas Tariff Code | Gas product code |
342
- | Octopus Gas Tariff Valid From / Valid To | Validity window of the current gas tariff |
343
-
344
- ### Main Sensors โ€” Account & Rewards
345
-
346
- | Name | Description |
347
- |---|---|
348
- | Octopus Account Balance | Current account credit or debit balance (ยฃ) |
349
- | Octopus Saving Session Joined | Whether you have joined the current saving session campaign |
350
- | Octopus WoF Electricity Spins | Wheel of Fortune electricity spins remaining (opt-in) |
351
- | Octopus WoF Gas Spins | Wheel of Fortune gas spins remaining (opt-in) |
352
-
353
- ### Main Sensors โ€” Home Mini
354
-
355
- | Name | Description |
356
- |---|---|
357
- | Octopus Home Mini Demand | Real-time grid import in kW โ€” requires Octopus Home Mini and opt-in checkbox in node config |
358
- | Octopus Home Mini Period Consumption | Energy consumed in the current half-hour period (kWh) |
359
-
360
- ### Main Sensors โ€” Account, Octoplus, Rewards (continued)
361
-
362
- The following appear in the main device entity list (not the Diagnostics tab):
363
-
364
- | Name | Description |
365
- |---|---|
366
- | Octopus Octoplus Status | Octoplus enrollment status string (e.g. `ENROLLED`) |
367
- | Octopus Saving Session Start / End | Start and end of the next saving session (`null` outside Octoberโ€“March) |
368
- | Octopus Free Electricity Start / End | Start and end of the next free electricity window (`null` outside the active period) |
369
-
370
- ### Diagnostic Sensors
371
-
372
- Appears under the **Diagnostics** tab of the HA device card.
373
-
374
- #### Polling & Refresh
375
-
376
- | Name | Description |
377
- |---|---|
378
- | Octopus Next Poll Time | Timestamp of the next scheduled automatic API refresh |
379
- | Octopus Refresh Available At | Timestamp when the manual refresh cooldown expires (`null` = available now) |
380
-
381
- #### API Usage
382
-
383
- | Name | Description |
384
- |---|---|
385
- | Octopus API Requests (Last Hour) | Number of API calls made in the last 60 minutes |
386
- | Octopus API Complexity (Last Hour) | Total estimated GraphQL complexity used in the last hour |
387
- | Octopus API Complexity Usage | Percentage of the 50,000/hour GraphQL complexity limit consumed |
388
-
389
- #### Raw Timestamps (UTC)
390
-
391
- Exact UTC strings from the API, unaffected by timezone settings. Use these when you need unambiguous UTC values in automations.
392
-
393
- | Name | Description |
394
- |---|---|
395
- | Octopus Next Charge Time (Raw) | Next charge time โ€” exact UTC string from API |
396
- | Octopus Next Poll Time (Raw) | Next poll time โ€” exact UTC string |
397
- | Octopus Slot 1 Start (Raw) | Slot 1 start โ€” exact UTC from API |
398
- | Octopus Slot 1 End (Raw) | Slot 1 end โ€” exact UTC from API |
399
- | Octopus Slot 2 Start (Raw) | Slot 2 start โ€” exact UTC from API |
400
- | Octopus Slot 2 End (Raw) | Slot 2 end โ€” exact UTC from API |
401
- | Octopus Slot 3 Start (Raw) | Slot 3 start โ€” exact UTC from API |
402
- | Octopus Slot 3 End (Raw) | Slot 3 end โ€” exact UTC from API |
403
- | Octopus Overall Window Start (Raw) | Window start โ€” exact UTC from API |
404
- | Octopus Overall Window End (Raw) | Window end โ€” exact UTC from API |
405
-
406
- #### Server-Timezone Timestamps (Locale)
407
-
408
- Times in the Node-RED server's auto-detected timezone. Unlike display fields, these are never affected by the Timezone selector or `set_timezone` command.
409
-
410
- | Name | Description |
411
- |---|---|
412
- | Octopus Next Charge Time (Locale) | Next charge time in Node-RED server timezone |
413
- | Octopus Slot 1 Start (Locale) | Slot 1 start in server timezone |
414
- | Octopus Slot 1 End (Locale) | Slot 1 end in server timezone |
415
- | Octopus Slot 2 Start (Locale) | Slot 2 start in server timezone |
416
- | Octopus Slot 2 End (Locale) | Slot 2 end in server timezone |
417
- | Octopus Slot 3 Start (Locale) | Slot 3 start in server timezone |
418
- | Octopus Slot 3 End (Locale) | Slot 3 end in server timezone |
419
- | Octopus Overall Window Start (Locale) | Window start in server timezone |
420
- | Octopus Overall Window End (Locale) | Window end in server timezone |
421
- | Octopus Timezone Detected | IANA timezone auto-detected from the Node-RED server (e.g. `Europe/London`) |
422
- | Octopus Timezone Applied | Active timezone currently used for all display timestamp fields |
423
-
424
- #### Consumption Metadata
425
-
426
- | Name | Description |
427
- |---|---|
428
- | Octopus Electricity Consumption From | Start of the electricity (import) consumption measurement period |
429
- | Octopus Electricity Consumption To | End of the electricity (import) consumption measurement period |
430
- | Octopus Electricity Export Consumption From | Start of the export consumption measurement period |
431
- | Octopus Electricity Export Consumption To | End of the export consumption measurement period |
432
- | Octopus Gas Consumption From | Start of the gas consumption measurement period |
433
- | Octopus Gas Consumption To | End of the gas consumption measurement period |
434
-
435
- #### Applicable Rates โ€” Import + Export
436
-
437
- | Name | Description |
438
- |---|---|
439
- | Octopus Applicable Rates Slots | Number of import rate slots in the current 24-hour window |
440
- | Octopus Electricity Export Rate Slots | Number of export rate slots in the current 24-hour window |
441
- | Octopus Electricity Export Rate Prev | Previous half-hour export rate (p/kWh) |
442
- | Octopus Electricity Export Rate Prev Ends | Timestamp when the previous export slot ended |
443
- | Octopus Electricity Export Rate Next | Next half-hour export rate (p/kWh) |
444
- | Octopus Electricity Export Rate Next From | Timestamp when the next export slot begins |
445
-
446
- #### Error & Detail Sensors
447
-
448
- `null` = healthy. Non-null = the last error message from that API category.
449
-
450
- | Name | Description |
451
- |---|---|
452
- | Octopus Electricity Rates Error | Last error fetching electricity rates |
453
- | Octopus Electricity Consumption Error | Last error fetching electricity consumption |
454
- | Octopus Gas Rates Error | Last error fetching gas rates |
455
- | Octopus Gas Consumption Error | Last error fetching gas consumption |
456
- | Octopus Applicable Rates Error | Last error fetching the import applicable rates schedule |
457
- | Octopus Electricity Export Rate Error | Last error fetching the export applicable rates schedule |
458
- | Octopus Account Balance (Pence) | Account balance in pence (raw integer) |
459
- | Octopus Account Error | Last error fetching account data |
460
- | Octopus Octoplus Error | Last error fetching Octoplus data |
461
- | Octopus WoF Electricity Max | Maximum Wheel of Fortune electricity spins allowed per period |
462
- | Octopus WoF Electricity Used | Wheel of Fortune electricity spins used this period |
463
- | Octopus WoF Gas Max | Maximum Wheel of Fortune gas spins allowed per period |
464
- | Octopus WoF Gas Used | Wheel of Fortune gas spins used this period |
465
- | Octopus WoF Error | Last error fetching Wheel of Fortune data |
466
- | Octopus Home Mini Reading Time | Timestamp of the most recent Home Mini telemetry reading |
467
- | Octopus Home Mini Error | Last error fetching Home Mini data |
468
- | Octopus Saving Sessions Error | Last error fetching saving sessions data |
469
- | Octopus Free Electricity Error | Last error fetching free electricity data |
470
- | Octopus Completed Dispatches Error | Last error fetching completed dispatch history |
471
- | Octopus Flex Planned Dispatches Error | Last error fetching flex planned dispatch schedule |
472
- | Octopus Intelligent Error | Last error from the intelligent charging (EV slots) query |
473
-
474
- ---
475
-
476
- ## ๐Ÿ†“ Free Electricity & Seasonal Sensors
477
-
478
- Octopus Energy runs free electricity sessions (typically Juneโ€“October) and saving sessions (typically Octoberโ€“March). The node polls for both and exposes binary sensors for automation use.
479
-
480
- ### Free Electricity
481
- - **`binary_sensor.octopus_free_electricity_active`** โ€” `ON` while a free window is in progress right now
482
- - **`binary_sensor.octopus_free_electricity_available`** โ€” `ON` if an upcoming free window is scheduled
483
-
484
- Use these to automatically start charging your car or battery when electricity is free:
485
-
486
- ```yaml
487
- automation:
488
- - alias: "Charge during free electricity"
489
- trigger:
490
- platform: state
491
- entity_id: binary_sensor.octopus_free_electricity_active
492
- to: "on"
493
- action:
494
- service: switch.turn_on
495
- target:
496
- entity_id: switch.battery_charger
497
- ```
498
-
499
- ### Saving Sessions
500
- - **`binary_sensor.octopus_saving_session_available`** โ€” `ON` if a saving session is upcoming
501
- - **`sensor.octopus_saving_session_start`** / **`sensor.octopus_saving_session_end`** โ€” start and end times
502
-
503
- ### Why These Sensors Are Null Outside Season
504
-
505
- The Octopus API only returns free electricity and saving session data when those programmes are active. Outside their respective seasons the API returns an empty list (or in the case of saving sessions, the query itself is unavailable). The node handles this gracefully:
506
-
507
- - Binary sensors remain `OFF` (not `unavailable`)
508
- - Timestamp sensors (`saving_session_start`, `free_electricity_start`, etc.) return `null`
509
- - In Home Assistant, `null`-valued configuration sensors may show as **unavailable** โ€” this is normal and expected
510
-
511
- ---
512
-
513
- ## ๐ŸŒ Timezone Configuration
514
-
515
- By default, slot and window times are converted to the **server's auto-detected timezone** (wherever Node-RED is running). Three ways to configure:
516
-
517
- ### Option 1: Node Config (static)
518
- Set a fixed IANA timezone in the node editor:
519
- - Open node โ†’ **Timezone** field โ†’ type `Australia/Sydney`
520
- - Leave blank to use server auto-detect
521
-
522
- ### Option 2: Home Assistant Select (dynamic, persists across restarts)
523
- Use the **Timezone** select entity in Home Assistant:
524
- - Home Assistant โ†’ Octopus Intelligent device โ†’ Timezone
525
- - Change takes effect on next poll
526
- - Persists across Node-RED restarts
527
-
528
- ### Option 3: `set_timezone` Input Command
529
- ```javascript
530
- msg.payload = { set_timezone: "Europe/London" };
531
- // Send to Octopus Intelligent node input
532
- ```
533
-
534
- ### Timestamp Tiers
535
- | Field suffix | Timezone | Configurable? |
536
- |---|---|---|
537
- | `*_raw` | Always UTC (exact API string) | Never |
538
- | `*_locale` | Server auto-detected | Never (always server TZ) |
539
- | Display fields (`slot1_start`, `window_start`, etc.) | Resolved TZ | Yes โ€” via HA, config, or command |
540
-
541
- ### Supported Timezones (HA select)
542
- `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`
543
-
544
- Any valid IANA timezone works in the node config field or `set_timezone` command.
545
-
546
- ---
547
-
548
- ## ๐Ÿ’ก Node-RED Usage
549
-
550
- ### Basic Monitoring
551
-
552
- ```
553
- [Inject: Every 5 min] โ†’ [Octopus Intelligent] โ†’ [Debug]
554
- ```
555
-
556
- ### Set Preferences from Flow
557
-
558
- ```javascript
559
- msg.payload = {
560
- set_limit: 85, // 85% charge
561
- set_time: "07:30" // Ready by 07:30
562
- };
563
- return msg;
564
- ```
565
-
566
- ### Set Timezone from Flow
567
-
568
- ```javascript
569
- msg.payload = { set_timezone: "Australia/Sydney" };
570
- return msg;
571
- ```
572
-
573
- ### Toggle Smart Charging from Flow
574
-
575
- ```javascript
576
- msg.payload = { set_smart_charging: true }; // enable (unsuspend)
577
- msg.payload = { set_smart_charging: false }; // disable (suspend)
578
- return msg;
579
- ```
580
-
581
- **Example: suspend charging when home battery is in use**
582
- ```
583
- [Inject: suspend] โ†’ [Function: set_smart_charging=false] โ†’ [Octopus Intelligent]
584
- [Inject: resume] โ†’ [Function: set_smart_charging=true] โ†’ [Octopus Intelligent]
585
- ```
586
-
587
- ### Output Format
588
-
589
- ```json
590
- {
591
- "payload": {
592
- "next_start": "2026-05-03 01:30:00+01:00",
593
- "total_energy": 42.5,
594
- "next_kwh": "15.20",
595
- "next_source": "smart-charge",
596
- "confirmed_limit": 80,
597
- "confirmed_time": "07:00",
598
- "pending_limit": 80,
599
- "pending_time": "07:00",
600
- "charging_now": false,
601
- "smart_charging": true,
602
- "next_poll": "2026-05-03T10:35:00Z",
603
- "refresh_available_at": null,
604
- "api_requests_hour": 12,
605
- "api_complexity_hour": 3600,
606
- "api_complexity_percent": 7.2,
607
- "slot1_start": "2026-05-03 01:30:00+01:00",
608
- "slot1_end": "2026-05-03 05:30:00+01:00",
609
- "slot2_start": null,
610
- "slot2_end": null,
611
- "slot3_start": null,
612
- "slot3_end": null,
613
- "window_start": "2026-05-03 01:30:00+01:00",
614
- "window_end": "2026-05-03 05:30:00+01:00",
615
- "timezone_detected": "Europe/London",
616
- "timezone_applied": "Europe/London",
617
- "next_start_locale": "2026-05-03 01:30:00+01:00",
618
- "slot1_start_locale": "2026-05-03 01:30:00+01:00",
619
- "slot1_end_locale": "2026-05-03 05:30:00+01:00",
620
- "window_start_locale": "2026-05-03 01:30:00+01:00",
621
- "window_end_locale": "2026-05-03 05:30:00+01:00",
622
- "completed_dispatches_count": 3,
623
- "completed_dispatches_error": null,
624
- "flex_planned_dispatches_count": 1,
625
- "flex_planned_dispatches_error": null,
626
- "intelligent_error": null,
627
- "electricity_unit_rate": null,
628
- "electricity_standing_charge": 53.94,
629
- "electricity_tariff_code": "E-1R-INTELLI-VAR-22-01-01-A",
630
- "electricity_valid_from": "2022-01-01T00:00:00Z",
631
- "electricity_valid_to": null,
632
- "electricity_consumption_kwh": 8.4,
633
- "electricity_consumption_from": "2026-05-02T00:00:00Z",
634
- "electricity_consumption_to": "2026-05-03T00:00:00Z",
635
- "electricity_rates_error": null,
636
- "electricity_consumption_error": null,
637
- "applicable_rates_count": 28,
638
- "applicable_rates_current_pence": 10.33,
639
- "applicable_rates_error": null,
640
- "gas_unit_rate": 6.24,
641
- "gas_standing_charge": 31.05,
642
- "gas_tariff_code": "G-1R-VAR-22-11-01-A",
643
- "gas_valid_from": "2022-11-01T00:00:00Z",
644
- "gas_valid_to": null,
645
- "gas_consumption_kwh": 12.1,
646
- "gas_consumption_from": "2026-05-02T00:00:00Z",
647
- "gas_consumption_to": "2026-05-03T00:00:00Z",
648
- "gas_rates_error": null,
649
- "gas_consumption_error": null,
650
- "account_balance_pence": 10900,
651
- "account_balance_pounds": 109,
652
- "account_error": null,
653
- "octoplus_enrolled": true,
654
- "octoplus_enrollment_status": "ENROLLED",
655
- "octoplus_loyalty_points_user": true,
656
- "octoplus_error": null,
657
- "wheel_of_fortune_electricity_spins": 2,
658
- "wheel_of_fortune_electricity_max": 3,
659
- "wheel_of_fortune_electricity_used": 1,
660
- "wheel_of_fortune_gas_spins": 1,
661
- "wheel_of_fortune_gas_max": 1,
662
- "wheel_of_fortune_gas_used": 0,
663
- "wheel_of_fortune_error": null,
664
- "mini_demand_kw": 0.082,
665
- "mini_consumption_delta_kwh": 0.002,
666
- "mini_read_at": "2026-05-03T10:00:00Z",
667
- "home_mini_error": null,
668
- "saving_session_available": false,
669
- "saving_session_start": null,
670
- "saving_session_end": null,
671
- "saving_session_joined": false,
672
- "saving_session_points": null,
673
- "saving_sessions_error": null,
674
- "free_electricity_active": false,
675
- "free_electricity_available": false,
676
- "free_electricity_start": null,
677
- "free_electricity_end": null,
678
- "free_electricity_error": null
679
- },
680
- "debug": {
681
- "success": true,
682
- "step": "complete",
683
- "apiCalls": [
684
- {"name": "authentication", "tokenObtained": true},
685
- {"name": "intelligent", "slotsFound": 1},
686
- {"name": "electricity_rates", "success": true},
687
- {"name": "electricity_consumption", "success": true},
688
- {"name": "gas_rates", "success": true},
689
- {"name": "gas_consumption", "success": true},
690
- {"name": "home_mini", "success": true},
691
- {"name": "account", "success": true}
692
- ]
693
- }
694
- }
695
- ```
696
-
697
- > **Note:** `electricity_unit_rate` is `null` for half-hourly tariffs (e.g. Intelligent Octopus Go). Use `applicable_rates_current_pence` for the live rate on HH tariffs.
698
-
699
- > **v1.3.0 additions:** The example above shows the v1.2.x payload shape for clarity. v1.3.0 adds ~14 additional fields covering electricity export (`electricity_export_unit_rate`, `electricity_export_tariff_code`, `electricity_export_consumption_kwh`, full `electricity_export_rate[]` half-hourly array with current/prev/next slot summaries) and import rate adjacency (`applicable_rates_prev_pence`, `_prev_gbp`, `_prev_to`, `_next_pence`, `_next_gbp`, `_next_from`). For the authoritative current set, inspect `msg.payload` in a Debug node after a real poll, or read `lib/payload.js` in the source.
700
-
701
- ---
702
-
703
- ## ๐Ÿก Home Assistant Automation Examples
704
-
705
- ### Notify When Charging Starts
706
-
707
- ```yaml
708
- automation:
709
- - alias: "EV Charging Starting"
710
- trigger:
711
- platform: state
712
- entity_id: binary_sensor.octopus_charging_now
713
- to: "on"
714
- action:
715
- service: notify.mobile_app
716
- data:
717
- message: "EV charging started"
718
- ```
719
-
720
- ### Charge During Free Electricity Window
721
-
722
- ```yaml
723
- automation:
724
- - alias: "Start battery charge on free electricity"
725
- trigger:
726
- platform: state
727
- entity_id: binary_sensor.octopus_free_electricity_active
728
- to: "on"
729
- action:
730
- service: switch.turn_on
731
- target:
732
- entity_id: switch.battery_charger
733
- - alias: "Stop battery charge after free electricity"
734
- trigger:
735
- platform: state
736
- entity_id: binary_sensor.octopus_free_electricity_active
737
- to: "off"
738
- action:
739
- service: switch.turn_off
740
- target:
741
- entity_id: switch.battery_charger
742
- ```
743
-
744
- ### Run Dishwasher During Cheap Rate
745
-
746
- ```yaml
747
- automation:
748
- - alias: "Dishwasher During Cheap Window"
749
- trigger:
750
- platform: time_pattern
751
- minutes: "/5"
752
- condition:
753
- - condition: template
754
- value_template: >
755
- {% set start = as_timestamp(states('sensor.octopus_slot_1_start')) %}
756
- {% set end = as_timestamp(states('sensor.octopus_slot_1_end')) %}
757
- {% set now = as_timestamp(now()) %}
758
- {{ start <= now <= end }}
759
- action:
760
- service: switch.turn_on
761
- target:
762
- entity_id: switch.dishwasher
763
- ```
764
-
765
- ### Alert When Saving Session Available
766
-
767
- ```yaml
768
- automation:
769
- - alias: "Saving session alert"
770
- trigger:
771
- platform: state
772
- entity_id: binary_sensor.octopus_saving_session_available
773
- to: "on"
774
- action:
775
- service: notify.mobile_app
776
- data:
777
- message: >
778
- Saving session available:
779
- {{ states('sensor.octopus_saving_session_start') }}
780
- to {{ states('sensor.octopus_saving_session_end') }}
781
- ```
782
-
783
- ---
784
-
785
- ## ๐Ÿ” Troubleshooting
786
-
787
- ### No Data (All Sensors Null/0)
788
-
789
- Check `msg.debug` output in a Debug node:
790
-
791
- - Account format must include `A-` prefix
792
- - Invalid API key โ€” regenerate at Octopus dashboard
793
- - Not on a recognised Octopus tariff (EV sensors require Intelligent Octopus Go)
794
- - Car not plugged in (no slots scheduled) โ€” EV sensors null is normal when no charging is planned
795
-
796
- ### Authentication Failing
797
-
798
- Check `msg.debug.apiCalls[0].errors` for details. Regenerate your API key and update the node configuration.
799
-
800
- ### Sensors Unavailable in Home Assistant
801
-
802
- 1. Verify MQTT broker is running
803
- 2. Check Node-RED can connect to MQTT broker
804
- 3. Deploy the flow to trigger discovery
805
- 4. Confirm Home Assistant MQTT integration is enabled
806
-
807
- ### electricity_unit_rate Always Null
808
-
809
- This is expected on half-hourly tariffs like Intelligent Octopus Go. The tariff has no single unit rate โ€” prices vary by half-hour slot. Use `applicable_rates_current_pence` for the live rate instead.
810
-
811
- ### Upgrading from v1.2.x โ€” Sensors Look Different
812
-
813
- v1.3.0 adds ~70 new sensors but does not rename or remove any v1.2 sensors. Existing automations and dashboards continue working unchanged. New sensors appear automatically in Home Assistant after the first poll following upgrade.
814
-
815
- Two existing Octoplus booleans (`octoplus_enrolled` and `octoplus_loyalty_points_user`) move from the `sensor.` domain to `binary_sensor.` in v1.3 because they are boolean values and HA's sensor domain doesn't accept booleans cleanly. If you have automations referencing the old `sensor.` entity IDs, update them to the new `binary_sensor.` IDs after upgrade.
816
-
817
- ### Stale Entities After Early v1.3 Dev Build
818
-
819
- If you installed an early v2 build before final release, some entity IDs may have changed. To clean up stale entities:
820
-
821
- 1. In HA โ†’ **Settings โ†’ Devices & Services โ†’ MQTT**
822
- 2. Find each stale entity name in Developer Tools โ†’ MQTT
823
- 3. Publish an **empty retained payload** to its config topic:
824
- ```
825
- Topic: homeassistant/sensor/nodered_A-XXXX_<entity_id>/config
826
- Payload: (empty)
827
- Retain: โœ“
828
- ```
829
- This removes the entity from the broker โ€” HA drops it automatically.
830
-
831
- ### Home Mini Not Showing
832
-
833
- 1. Tick **Enable Home Mini** in node config
834
- 2. Verify your Octopus account has a smart meter registered (visible in the Octopus app)
835
- 3. Check `msg.payload.home_mini_error` in a debug node for the specific error
836
-
837
- ### New Category Sensors All Null After Deploy
838
-
839
- Account discovery runs once at startup. If it fails, check `msg.debug` for auth errors, verify your API key, and redeploy.
840
-
841
- ### Seasonal Sensors Show "Unavailable"
842
-
843
- Saving session sensors are only populated Octoberโ€“March. Free electricity sensors are only populated Juneโ€“October. Outside season, `null` values cause these sensors to show as unavailable in HA โ€” this is correct behaviour, not a bug.
844
-
845
- ### Changes Not Applying
846
-
847
- This is by design. Use the **Apply Changes** button to submit. This prevents API spam when making multiple adjustments.
848
-
849
- ---
850
-
851
- ## ๐Ÿ› ๏ธ How It Works
852
-
853
- ### Startup โ€” Account Discovery
854
-
855
- On first deploy, the node queries the Octopus API to detect which products are registered on your account:
856
-
857
- - **Electricity** โ€” always enabled if an electricity agreement exists
858
- - **Gas** โ€” enabled if a gas agreement exists
859
- - **Intelligent EV** โ€” enabled if an EV device is registered (Intelligent Octopus Go)
860
- - **Home Mini** โ€” enabled if a smart meter device is registered AND the Home Mini checkbox is ticked
861
- - **Wheel of Fortune / Saving Sessions / Account** โ€” always polled if credentials are valid
862
-
863
- Discovery sets which categories are active. No manual configuration required.
864
-
865
- ### Category Scheduler
866
-
867
- Each data category polls on its own interval (configurable per category in the node editor). A 1-second clock-aligned scheduler checks which categories are due each tick. Categories poll independently โ€” a slow gas API response does not delay your EV slot update.
868
-
869
- ### Authentication Flow
870
-
871
- 1. **Exchange API key** for a short-lived token
872
- 2. **Run category polls** in parallel โ€” each category makes its own GraphQL query
873
- 3. **Merge results** into a single payload object
874
- 4. **Publish** to Node-RED output + MQTT state topic
875
-
876
- ### Exponential Backoff (preference changes)
877
-
878
- When changing charge limit or ready time:
879
-
880
- ```
881
- Mutation sent โ†’ Wait 15s โ†’ Validate
882
- โ†“ Not confirmed yet?
883
- โ†’ Wait 30s โ†’ Validate
884
- โ†“ Not confirmed yet?
885
- โ†’ Wait 60s โ†’ Validate
886
- โ†“ Not confirmed yet?
887
- โ†’ Wait 120s โ†’ Final check
888
- โ†“ Then normal interval resumes
889
- ```
890
-
891
- This prevents sensors becoming "unavailable" during updates.
892
-
893
- ### Debug Information
894
-
895
- Every message includes `msg.debug`:
896
-
897
- ```json
898
- {
899
- "timestamp": "2026-05-03T10:30:00Z",
900
- "success": true,
901
- "step": "complete",
902
- "apiCalls": [
903
- {"name": "authentication", "tokenObtained": true},
904
- {"name": "intelligent", "slotsFound": 1}
905
- ]
906
- }
907
- ```
908
-
909
- ---
910
-
911
- ## ๐Ÿ“ License
912
-
913
- MIT License - Copyright (c) 2025 Andrew Somerharju Neale
914
-
915
- See [LICENSE](LICENSE) file for full details.
916
-
917
- ---
918
-
919
- ## โš ๏ธ Disclaimer
920
-
921
- This is an **unofficial integration** and is not affiliated with, endorsed by, or connected to Octopus Energy Ltd.
922
-
923
- Use at your own risk. The Octopus Energy name and logo are trademarks of Octopus Energy Ltd.
924
-
925
- ---
926
-
927
- ## ๐Ÿ”— Links
928
-
929
- - **npm**: https://www.npmjs.com/package/node-red-contrib-octopus-intelligent
930
- - **GitHub**: https://github.com/ASomerN/node-red-contrib-octopus-intelligent
931
- - **Issues**: https://github.com/ASomerN/node-red-contrib-octopus-intelligent/issues
932
- - **Octopus Intelligent**: https://octopus.energy/intelligent/
933
- - **API Docs**: https://developer.octopus.energy/docs/api/
934
-
935
- ---
936
-
937
- ## ๐Ÿ“œ Changelog
938
-
939
- See [CHANGELOG.md](CHANGELOG.md) for detailed version history and release notes.
940
-
941
- ### v1.3.0 (2026-05-12)
942
-
943
- Major additive release โ€” full consumer read coverage. No breaking changes; all v1.2.x entity IDs, payload fields, and automations continue working unchanged.
944
-
945
- **New read categories:**
946
- - **Electricity import** โ€” live unit rate, standing charge, tariff code + validity dates, daily consumption, half-hourly applicable rates (current / prev / next), GBP/kWh rate for Energy Dashboard
947
- - **Electricity export** โ€” full read parity with import: live export rate, standing charge, tariff code (e.g. `AGILE-OUTGOING-19-05-13`), validity dates, daily export consumption, half-hourly export rate slots (48 entries), prev / next slot rates and transition timestamps
948
- - **Gas** โ€” unit rate, standing charge, tariff code + validity, daily consumption (account-conditional)
949
- - **Octopus Home Mini** โ€” real-time grid demand (kW), half-hour consumption (kWh), last reading timestamp
950
- - **Saving sessions** โ€” upcoming session start/end, joined status (now read from `api.backend.octopus.energy`)
951
- - **Free electricity** โ€” upcoming/active session detection, binary sensors for automation
952
- - **Wheel of Fortune** โ€” electricity and gas spin counts (now using non-deprecated `wheelOfFortuneSpinsAllowed` on backend endpoint)
953
- - **Account balance** โ€” credit/debit in ยฃ and pence
954
- - **Octoplus** โ€” enrollment status (string) + enrolled and loyalty-points-user booleans
955
-
956
- **Bug fixes carried in alongside the additive work:**
957
- - **Import / export meter point selection** โ€” meter point selection now uses the `direction` field, not array position. Earlier dev builds on accounts with both import + export meters could surface export data as if it were import (live "current rate" showing the export Agile rate instead of the import tariff). Fixed before release; no stable v1.x build was affected.
958
- - **MQTT transport** โ€” added `User-Agent` header required by `api.backend.octopus.energy`. Without it the backend returns 403 at the edge, which surfaced as "WoF returns HTML" / saving sessions silently broken.
959
- - **MQTT discovery for boolean sensors** โ€” `octoplus_enrolled` and `octoplus_loyalty_points_user` were previously published to the `sensor` MQTT domain; HA's sensor handler doesn't accept raw boolean values cleanly, so the entities never registered on some installs. Now published as `binary_sensor` โ€” registers reliably.
960
- - **MQTT discovery for read-only info sensors** โ€” removed `entity_category: config` from tariff codes, validity dates, etc. That category is intended for user-configurable entities; on read-only sensors HA's state handling caused them to stick at "unavailable". Moved to the main entity list.
961
-
962
- **Backwards compatibility:** zero breaking changes. New entities appear automatically after first poll following upgrade. Existing automations continue unchanged.
963
-
964
- ### v1.2.1 (2026-04-29)
965
- - **Deprecated API migration** โ€” moved to current `devices` query and `setDevicePreferences` mutation
966
-
967
- ### v1.2.0 (2026-04-26)
968
- - **Smart Charging Toggle** โ€” suspend/resume Octopus intelligent charging from Node-RED or Home Assistant
969
- - **HA MQTT Switch** โ€” auto-discovered Smart Charging switch entity
970
- - **`smart_charging` payload field** โ€” live state in every message
971
-
972
- ### v1.0.4 (2025-12-11)
973
- - **Manual Refresh Button** โ€” Force API refresh via Home Assistant with 30s cooldown
974
- - **Next Poll Timer** โ€” See when next automatic refresh occurs
975
- - **API Complexity Monitoring** โ€” Track API usage against 50,000/hour limit
976
- - **Rate Limiting** โ€” MQTT button (30s cooldown), Node-RED input (no limit)
977
-
978
- ---
979
-
980
- **Made with โšก for the Octopus Energy & Home Assistant communities**
1
+ # node-red-contrib-octopus-intelligent
2
+
3
+ > Node-RED integration for **Octopus Energy** with automatic Home Assistant MQTT discovery
4
+
5
+ Monitor electricity and gas rates (import + export), EV charging schedules, real-time home energy usage, account balance, saving sessions, and Wheel of Fortune spins โ€” all automatically configured as Home Assistant entities via MQTT discovery.
6
+
7
+ [![npm version](https://badge.fury.io/js/node-red-contrib-octopus-intelligent.svg)](https://www.npmjs.com/package/node-red-contrib-octopus-intelligent)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
+
10
+ ---
11
+
12
+ ## ๐Ÿค Support This Project
13
+
14
+ Found this useful? Support continued development:
15
+
16
+ <table>
17
+ <tr>
18
+ <td width="33%" align="center">
19
+
20
+ ### โญ GitHub Star
21
+ Star the repository to show your support!
22
+
23
+ [โญ Star on GitHub](https://github.com/ASomerN/node-red-contrib-octopus-intelligent)
24
+
25
+ </td>
26
+ <td width="33%" align="center">
27
+
28
+ ### ๐Ÿ’– Sponsor
29
+ Support ongoing development and maintenance
30
+
31
+ [Become a Sponsor](https://github.com/sponsors/ASomerN)
32
+
33
+ </td>
34
+ <td width="33%" align="center">
35
+
36
+ ### โ˜• Buy Me a Coffee
37
+ If this project has helped you!
38
+
39
+ [![Donate with PayPal](https://www.paypalobjects.com/en_GB/i/btn/btn_donate_LG.gif)](https://www.paypal.com/donate?hosted_button_id=A2B8ZFEJBE2S6)
40
+
41
+ </td>
42
+ </tr>
43
+ </table>
44
+
45
+ **Your support helps with:** Bug fixes and maintenance โ€ข New feature development โ€ข Documentation improvements โ€ข Community support โ€ข Feeding my children
46
+
47
+ ---
48
+
49
+ ## โœจ Features
50
+
51
+ ### ๐ŸŽฎ EV Smart Controls
52
+ - **Target Charge Slider** (5โ€“100%) โ€” Set your desired battery level
53
+ - **Ready Time Dropdown** (any half-hour slot, 00:00โ€“23:30) โ€” When your car needs to be ready. Matches the Octopus app; other values are rejected with an error and nothing is sent to Octopus.
54
+ - **Apply Changes Button** โ€” Prevents API spam while adjusting settings
55
+ - **Confirmed Values** โ€” See your current API-validated settings
56
+ - **Smart Charging Toggle** โ€” Suspend or resume Octopus intelligent charging from Node-RED or Home Assistant
57
+
58
+ ### โšก Real-Time Charging Data
59
+ - **Next Charge Time** โ€” When your next slot starts
60
+ - **Total Planned Energy** โ€” Total kWh across all upcoming slots
61
+ - **Individual Slot Times** โ€” Up to 3 slots with start/end times
62
+ - **Charging Window** โ€” Overall window from first to last slot
63
+ - **Charge Source** โ€” Smart-charge vs bump-charge indicator
64
+ - **Completed Dispatches** โ€” History of completed intelligent charging sessions
65
+ - **Flex Planned Dispatches** โ€” Upcoming flex dispatch schedule
66
+
67
+ ### ๐Ÿ”Œ Electricity & Gas Rates
68
+ - **Live Unit Rate** โ€” Current electricity rate (p/kWh) and gas rate (p/kWh)
69
+ - **Standing Charges** โ€” Daily standing charges for electricity and gas
70
+ - **Tariff Code** โ€” Your current tariff identifier and validity dates
71
+ - **Recent Consumption** โ€” Previous day kWh for electricity (import + export) and gas
72
+ - **Current Rate Slot** โ€” Live rate from your 24h applicable rates schedule
73
+ - **Previous / Next Rate** โ€” Adjacent slot rates and transition timestamps
74
+ - **Energy Dashboard Rate** โ€” Electricity rate in GBP/kWh, ready for HA's Energy Dashboard cost tracking
75
+
76
+ ### ๐ŸŒž Electricity Export (Solar / Battery)
77
+ - **Export Tariff** โ€” Tariff code, standing charge, validity dates for the OUTGOING agreement
78
+ - **Export Half-Hourly Rates** โ€” Full 48-slot schedule for variable export tariffs (e.g. Agile Outgoing)
79
+ - **Live Export Rate** โ€” Current p/kWh and GBP/kWh
80
+ - **Previous / Next Export Rate** โ€” Adjacent slot rates and transition timestamps
81
+ - **Export Consumption** โ€” Previous day kWh exported to the grid (read from the export meter point)
82
+
83
+ ### ๐Ÿ  Home Energy (Octopus Home Mini)
84
+ - **Live Demand** โ€” Real-time grid import in kW
85
+ - **Period Consumption** โ€” Energy consumed in the last half-hour period (kWh)
86
+ - Requires Octopus Home Mini device registered to your account (opt-in)
87
+
88
+ ### ๐Ÿ’ฐ Account & Rewards
89
+ - **Account Balance** โ€” Current credit/debit balance in ยฃ
90
+ - **Saving Sessions** โ€” Next session availability, start/end times, joined status, and Octopus Points
91
+ - **Free Electricity** โ€” Upcoming free electricity window detection (active Juneโ€“October)
92
+ - **Wheel of Fortune** โ€” Remaining electricity and gas spins (opt-in)
93
+ - **Octoplus** โ€” Enrollment status and loyalty points
94
+
95
+ ### ๐Ÿ”ง Advanced Features
96
+ - **Account Discovery** โ€” Automatic product detection at startup; categories auto-enable based on registered products
97
+ - **Per-Category Polling** โ€” Each data category polls on its own configurable interval
98
+ - **Manual Refresh Button** โ€” Force API refresh from Home Assistant (30s cooldown)
99
+ - **Next Poll Timer** โ€” See when the next automatic refresh will occur
100
+ - **API Usage Tracking** โ€” Monitor requests and complexity in diagnostics
101
+ - **Exponential Backoff** โ€” Smart retry prevents sensor unavailability
102
+ - **Comprehensive Debugging** โ€” Full API call tracking in msg.debug
103
+
104
+ ### ๐Ÿก Home Assistant Integration
105
+ - **Zero Configuration** โ€” MQTT auto-discovery sets everything up
106
+ - **Two-Tier Entity Organisation** โ€” Main entities (controls, live rates, consumption, tariff metadata, rewards) and Diagnostics (errors, raw timestamps, API metrics, locale timestamps)
107
+ - **Suggested Area** โ€” Auto-suggests "Energy" area
108
+ - **Reference dashboard YAML** โ€” `examples/ha-dashboard.yaml` covers every entity (including the Smart Charging and Charge Cap switches) in a packed sections layout, ready to paste into HA's Raw Configuration Editor
109
+ - **Node-RED Dashboard 2.0 example** โ€” `examples/node-red-dashboard-flow.json` is an importable [@flowfuse/node-red-dashboard](https://github.com/FlowFuse/node-red-dashboard) flow whose Controls page has the target limit, all 48 ready-by times, the Smart Charging and Charge Cap switches, refresh and timezone override
110
+
111
+ ### ๐ŸŒ Timezone Support
112
+ - **Locale Timestamps** (`*_locale` fields) โ€” always in server auto-detected timezone
113
+ - **Resolved Display Fields** โ€” slot and window times in your configured timezone
114
+ - **HA Timezone Select** โ€” change timezone from Home Assistant without redeploying
115
+ - **Node Config Override** โ€” set IANA timezone directly in the node editor
116
+ - **Zero Dependencies** โ€” native `Intl` API, no new packages
117
+
118
+ ---
119
+
120
+ ## ๐Ÿ“ธ Screenshots
121
+
122
+ ### Node Configuration
123
+
124
+ ![Node Configuration](images/examples/Octopus%20Intelligent%20Node.png)
125
+
126
+ Configure your account credentials, polling intervals, and MQTT broker in the node editor. The MQTT Broker dropdown connects directly to your Home Assistant Mosquitto instance. Per-category intervals let you tune how often each data source is polled โ€” electricity and gas rates update hourly by default, while Home Mini polls every minute for live demand.
127
+
128
+ ### Node-RED Flow Example
129
+
130
+ ![Node-RED Flow Example](images/examples/basic-monitoring-flow.png)
131
+
132
+ ### Home Assistant โ€” Dashboard
133
+
134
+ `examples/ha-dashboard.yaml` is a comprehensive Lovelace dashboard that exposes every entity the plugin publishes. Paste it into HA's Raw Configuration Editor to get the layout below. The layout uses HA's sections view and packs cards uniformly across up to 4 columns on wide screens. The EV controls card includes the Smart Charging and Charge Cap switches (the screenshots below predate the Charge Cap switch).
135
+
136
+ #### EV controls, electricity import & export
137
+
138
+ ![Dashboard โ€” EV, electricity import + export](images/examples/home_assistant_dashboard_1_1-3-0.png)
139
+
140
+ EV target slider and ready-time dropdown at top, then live import rate / standing / today's kWh, full import tariff card, half-hourly applicable rates summary, and the same trio for export (live export rate, export tariff, export consumption, half-hourly Agile Outgoing rates).
141
+
142
+ #### Gas, account, rewards, Home Mini
143
+
144
+ ![Dashboard โ€” gas, account, rewards, Home Mini](images/examples/home_assistant_dashboard_2_1-3-0.png)
145
+
146
+ Gas rate / standing / consumption + tariff. Account balance, Octoplus enrolment, Saving Sessions card, Free Electricity card, Wheel of Fortune spins, and the Home Mini live-demand gauge with current half-hour kWh.
147
+
148
+ #### Diagnostics โ€” UTC timestamps, raw timestamps, errors
149
+
150
+ ![Dashboard โ€” diagnostics](images/examples/home_assistant_dashboard_3_1-3-0.png)
151
+
152
+ UTC-class slot/window timestamps (HA renders them as relative "n hours ago"), raw API strings for verbatim debugging, timezone + API usage rows, and a consolidated error panel covering every category.
153
+
154
+ #### Gas โ€” live data from a real account
155
+
156
+ ![Dashboard โ€” gas live data](images/examples/home_assistant_dashboard_working_gas_1-3-0.png)
157
+
158
+ For accounts with a gas meter point, the gas card populates with live tariff code, unit rate (p/kWh), standing charge, daily consumption (kWh), and tariff validity dates. Above shows v1.3.0 reading correctly from a real account on Octopus standard variable gas tariff.
159
+
160
+ #### Seasonal / conditional entities โ€” when they show "Unavailable"
161
+
162
+ | Sensor | Active period | Outside season / condition |
163
+ |---|---|---|
164
+ | Saving Session Start / End | Octoberโ€“March | `null` โ€” no sessions scheduled |
165
+ | Free Electricity Start / End | typically Juneโ€“October | `null` โ€” no sessions scheduled |
166
+ | Electricity / Gas Tariff Valid To | When tariff has an end date | `null` โ€” open-ended tariff |
167
+ | Gas entities | Only if account has a gas meter point | `null` โ€” electricity-only accounts |
168
+ | Home Mini | Only if a Home Mini device is registered | Entity skipped if not registered |
169
+ | Electricity Export entities | Only if account has an OUTGOING agreement | Entity values null without an export tariff |
170
+ | EV planned slots / dispatches | Only when a charge is scheduled | `null` between plug-in cycles |
171
+
172
+ These are normal MQTT behaviours, not bugs. The plugin publishes the entity definitions so HA registers them; their values populate when the API returns data for that period.
173
+
174
+ ---
175
+
176
+ ## ๐Ÿ“‹ Requirements
177
+
178
+ - **Node-RED** v2.0+
179
+ - **Octopus Energy Account** โ€” any electricity account works for rates/consumption/account data
180
+ - [Intelligent Octopus Go](https://octopus.energy/intelligent/) tariff required for EV charging features
181
+ - Octopus Home Mini device required for real-time consumption (opt-in)
182
+ - Wheel of Fortune is opt-in and requires an active electricity agreement
183
+ - **API Key** โ€” [Generate here](https://octopus.energy/dashboard/new/accounts/personal-details/api-access)
184
+ - **MQTT Broker** (optional, for Home Assistant integration)
185
+ - **Home Assistant** (optional, for MQTT features)
186
+
187
+ ---
188
+
189
+ ## ๐Ÿš€ Quick Start
190
+
191
+ ### 1. Install via Node-RED Palette
192
+
193
+ 1. Open Node-RED โ†’ **Menu** โ†’ **Manage Palette**
194
+ 2. **Install** tab โ†’ Search `node-red-contrib-octopus-intelligent`
195
+ 3. Click **Install**
196
+
197
+ ### 2. Get Your Credentials
198
+
199
+ **Account Number** (format: `A-XXXXXXXX`):
200
+ - Found at https://octopus.energy/dashboard/
201
+
202
+ **API Key** (format: `sk_live_...`):
203
+ - Get from https://octopus.energy/dashboard/new/accounts/personal-details/api-access
204
+ - Click "Generate API Key"
205
+
206
+ ### 3. Configure the Node
207
+
208
+ 1. Drag **Octopus Intelligent** into your flow
209
+ 2. Double-click to configure:
210
+ - Account Number (format: `A-XXXXXXXX`)
211
+ - API Key (stored securely)
212
+ - Refresh Interval (default: 5 min โ€” controls EV charging data polling)
213
+ - Per-category polling intervals (electricity, gas, etc.)
214
+ - โ˜‘ Enable Home Mini โ€” tick if you have an Octopus Home Mini device
215
+ - โ˜‘ Enable Wheel of Fortune โ€” tick to track remaining spins
216
+ - Enable MQTT if using Home Assistant and select your MQTT broker
217
+ 3. **Deploy** โ€” account discovery runs automatically and enables categories based on your registered products
218
+
219
+ ### 4. Home Assistant (Optional)
220
+
221
+ If MQTT enabled:
222
+ 1. Wait ~5 seconds after deploy
223
+ 2. **Settings** โ†’ **Devices & Services** โ†’ **MQTT**
224
+ 3. Find "Octopus Intelligent" device
225
+ 4. All entities created automatically โ€” no YAML required
226
+
227
+ ---
228
+
229
+ ## โฌ†๏ธ Upgrading from v1.2.x
230
+
231
+ v1.3.0 is additive โ€” no breaking changes. Existing flows, automations, and dashboards continue working unchanged.
232
+
233
+ **What happens on upgrade:**
234
+ - All existing entity IDs are preserved (HA's MQTT integration matches by `unique_id`, which is stable)
235
+ - All v1.2.x payload fields remain in the same positions
236
+ - ~70 new sensors appear in Home Assistant automatically after first poll โ€” electricity import/export tariff and rates, gas tariff and consumption, Home Mini, Octoplus, saving sessions, free electricity, Wheel of Fortune, account balance, applicable rates
237
+ - New node config options (Home Mini, Wheel of Fortune) default to off
238
+ - Two existing Octoplus booleans (`octoplus_enrolled`, `octoplus_loyalty_points_user`) move from `sensor.` to `binary_sensor.` domain โ€” a fresh install picks the right domain automatically; a clean upgrade may register both. Delete the old `sensor.` entries via Dev Tools if you want a tidy device card.
239
+
240
+ If you installed an early dev build of v1.3 and have stale entities in Home Assistant, see [Stale Entities After Early v1.3 Dev Build](#stale-entities-after-early-v13-dev-build) in the Troubleshooting section.
241
+
242
+ ---
243
+
244
+ ## ๐Ÿ“Š Home Assistant Entities
245
+
246
+ **164 MQTT entities** are published under a single **Octopus Intelligent** device on a fresh install. All entities are organised into two tiers: **Main** (controls, live data, tariff metadata, rewards) and **Diagnostics** (errors, raw timestamps, locale timestamps, API metrics).
247
+
248
+ If your device card shows more than 164 entities, the extras are likely leftovers from earlier installed versions or interrupted discovery. They can be deleted via Settings โ†’ Devices & Services โ†’ MQTT โ†’ Octopus Intelligent โ†’ entity โ†’ cog โ†’ "Delete from registry" without affecting current operation.
249
+
250
+ ### Node-RED payload vs MQTT entities
251
+
252
+ `msg.payload` from the Node-RED node contains **~133 fields**. Some payload fields are intentionally **not** exposed as individual HA entities; they exist for template/automation use inside Node-RED or HA Jinja:
253
+
254
+ | Category | Fields (count) | Why no MQTT entity |
255
+ |---|---|---|
256
+ | Bulk array data | `applicable_rates`, `electricity_export_rate`, `completed_dispatches`, `flex_planned_dispatches` (4) | Each is an array of 48 half-hour slots or N dispatches. Exposing each row as an MQTT entity would clutter the registry. The `_count` summary entity exists; consume the full array via templates / `apexcharts-card` for visualisation. |
257
+ | Pending controls | `pending_limit`, `pending_time` (2) | The number/select control entities (`Target Charge`, `Ready By`) render the pending value through their own `value_template`. No separate sensor entity needed. |
258
+ | Import rate adjacency | `applicable_rates_prev_pence`, `_prev_gbp`, `_prev_to`, `_next_pence`, `_next_gbp`, `_next_from` (6) | Available in `msg.payload` for templates / dashboards. Export equivalents (`electricity_export_rate_prev_*` / `_next_*`) ARE exposed as MQTT entities โ€” the inconsistency is intentional pending v1.4 promotion. |
259
+ | Cost placeholders | `electricity_consumption_cost`, `gas_consumption_cost` (2) | Reserved for future cost-calculation feature (consumption ร— rate). Always `null` in v1.3. |
260
+ | Vestigial | `saving_session_points` (1) | Octopus moved loyalty points out of saving sessions into the Octoplus query. The payload field remains for backward compatibility but is always `null`; use `binary_sensor.octopus_intelligent_octopus_octoplus_loyalty_points` instead. |
261
+
262
+ **Implication for HA users:** every value you might want to display is reachable. Direct values use the MQTT entity. Adjacent-slot import rates require an MQTT template sensor reading from `applicable_rates_prev_pence` etc. (or use the Node-RED debug node to inspect the full payload).
263
+
264
+ **Why the import / export asymmetry?** Phase 2 of v1.3.0 added the full export rate ecosystem as new MQTT entities. The pre-existing import prev/next fields were added in v1.0 as payload-only and weren't promoted at the time. Promoting them is straightforward but was descoped from v1.3 to keep release scope tight; tracked for v1.4.
265
+
266
+ ### Controls
267
+
268
+ Interactive entities that accept commands. **Timezone**, **Smart Charging** and **Charge Cap** still carry the HA `entity_category: config` flag (they ARE user-configurable, so the category is semantically correct).
269
+
270
+ | Name | Description |
271
+ |---|---|
272
+ | Octopus Target Charge | Slider (5โ€“100%) โ€” set desired battery charge level; shows the pending value until applied |
273
+ | Octopus Ready Time | Dropdown (00:00โ€“23:30, half-hour slots) โ€” time by which the car must be ready. Other values are rejected with an error and nothing is sent to Octopus |
274
+ | Octopus Apply Changes | Submit pending limit/time changes to the Octopus API |
275
+ | Octopus Refresh API | Force an immediate API refresh (30-second cooldown enforced) |
276
+ | Timezone | Display timezone for all slot and window times โ€” 15 IANA options; persists across Node-RED restarts |
277
+ | Smart Charging | Enable (unsuspend) or disable (suspend) Octopus intelligent charging |
278
+ | Charge Cap | Limit smart charging to off-peak rates only (as in the Octopus app) |
279
+
280
+ ### Binary Sensors
281
+
282
+ | Name | Description |
283
+ |---|---|
284
+ | Octopus Charging Now | `ON` while the EV is actively inside a dispatch charging slot |
285
+ | Octopus Saving Session Available | `ON` if a saving session is upcoming or joinable |
286
+ | Octopus Free Electricity Active | `ON` while a free electricity window is in progress right now |
287
+ | Octopus Free Electricity Available | `ON` if a free electricity window is scheduled in the future |
288
+ | Octopus Octoplus Enrolled | `ON` if the account is enrolled in Octoplus |
289
+ | Octopus Octoplus Loyalty Points | `ON` if the account participates in Octoplus loyalty points (boolean flag from the API) |
290
+
291
+ ### Main Sensors โ€” EV Charging
292
+
293
+ | Name | Description |
294
+ |---|---|
295
+ | Octopus Confirmed Charge Limit | API-confirmed target charge percentage โ€” last setting accepted by Octopus |
296
+ | Octopus Confirmed Ready Time | API-confirmed ready time โ€” last setting accepted by Octopus |
297
+ | Octopus Next Charge Time | Start time of the next planned charging slot (display timezone) |
298
+ | Octopus Total Planned Energy | Total kWh across all upcoming planned dispatch slots |
299
+ | Octopus Next Slot Energy | Energy (kWh) scheduled for the next individual slot |
300
+ | Octopus Charge Source | Source of next charge: `smart-charge` (scheduled by Octopus algorithm) or `bump-charge` (car plugged in outside schedule) |
301
+ | Octopus Slot 1 Start | Start time of planned slot 1 |
302
+ | Octopus Slot 1 End | End time of planned slot 1 |
303
+ | Octopus Slot 2 Start | Start time of planned slot 2 (`null` if fewer than 2 slots) |
304
+ | Octopus Slot 2 End | End time of planned slot 2 |
305
+ | Octopus Slot 3 Start | Start time of planned slot 3 (`null` if fewer than 3 slots) |
306
+ | Octopus Slot 3 End | End time of planned slot 3 |
307
+ | Octopus Overall Window Start | Start of the first planned slot โ€” when the charging window opens |
308
+ | Octopus Overall Window End | End of the last planned slot โ€” when the charging window closes |
309
+ | Octopus Completed Dispatches | Count of completed intelligent dispatch sessions on record |
310
+ | Octopus Flex Planned Dispatches | Count of upcoming flex dispatch slots |
311
+
312
+ ### Main Sensors โ€” Electricity (Import)
313
+
314
+ | Name | Description |
315
+ |---|---|
316
+ | Octopus Electricity Standing Charge | Daily electricity standing charge (p/day) from current tariff |
317
+ | Octopus Electricity Consumption | Electricity consumed in the previous day (kWh) from the import meter |
318
+ | Octopus Current Electricity Rate | Live unit rate (p/kWh) from the 24h applicable rates schedule โ€” use this on half-hourly tariffs (e.g. Intelligent Octopus Go) instead of Electricity Unit Rate |
319
+ | Octopus Electricity Rate | Live unit rate in GBP/kWh โ€” measurement state class, ready for the HA Energy Dashboard |
320
+ | Octopus Electricity Unit Rate | Fixed unit rate (p/kWh) โ€” `null` on half-hourly tariffs |
321
+ | Octopus Electricity Tariff Code | Current import tariff product code |
322
+ | Octopus Electricity Tariff Valid From / Valid To | Validity window of the current import tariff (`Valid To` is `null` for open-ended tariffs) |
323
+
324
+ ### Main Sensors โ€” Electricity (Export)
325
+
326
+ | Name | Description |
327
+ |---|---|
328
+ | Octopus Electricity Export Standing Charge | Daily export standing charge (p/day) โ€” typically `0` for Agile Outgoing |
329
+ | Octopus Electricity Export Consumption | Electricity exported to the grid in the previous day (kWh) from the export meter |
330
+ | Octopus Current Electricity Export Rate | Live export rate (p/kWh) for the current half-hour slot |
331
+ | Octopus Electricity Export Rate | Live export rate (GBP/kWh) โ€” measurement state class |
332
+ | Octopus Electricity Export Unit Rate | Fixed unit rate โ€” `null` on half-hourly export tariffs (e.g. Agile Outgoing) |
333
+ | Octopus Electricity Export Tariff Code | Current export tariff product code (e.g. `AGILE-OUTGOING-19-05-13`) |
334
+ | Octopus Electricity Export Tariff Valid From / Valid To | Validity window of the current export tariff |
335
+
336
+ ### Main Sensors โ€” Gas
337
+
338
+ | Name | Description |
339
+ |---|---|
340
+ | Octopus Gas Standing Charge | Daily gas standing charge (p/day) from current tariff |
341
+ | Octopus Gas Consumption | Gas consumed in the previous day (kWh) |
342
+ | Octopus Gas Unit Rate | Gas unit rate (p/kWh) |
343
+ | Octopus Gas Tariff Code | Gas product code |
344
+ | Octopus Gas Tariff Valid From / Valid To | Validity window of the current gas tariff |
345
+
346
+ ### Main Sensors โ€” Account & Rewards
347
+
348
+ | Name | Description |
349
+ |---|---|
350
+ | Octopus Account Balance | Current account credit or debit balance (ยฃ) |
351
+ | Octopus Saving Session Joined | Whether you have joined the current saving session campaign |
352
+ | Octopus WoF Electricity Spins | Wheel of Fortune electricity spins remaining (opt-in) |
353
+ | Octopus WoF Gas Spins | Wheel of Fortune gas spins remaining (opt-in) |
354
+
355
+ ### Main Sensors โ€” Home Mini
356
+
357
+ | Name | Description |
358
+ |---|---|
359
+ | Octopus Home Mini Demand | Real-time grid import in kW โ€” requires Octopus Home Mini and opt-in checkbox in node config |
360
+ | Octopus Home Mini Period Consumption | Energy consumed in the current half-hour period (kWh) |
361
+
362
+ ### Main Sensors โ€” Account, Octoplus, Rewards (continued)
363
+
364
+ The following appear in the main device entity list (not the Diagnostics tab):
365
+
366
+ | Name | Description |
367
+ |---|---|
368
+ | Octopus Octoplus Status | Octoplus enrollment status string (e.g. `ENROLLED`) |
369
+ | Octopus Saving Session Start / End | Start and end of the next saving session (`null` outside Octoberโ€“March) |
370
+ | Octopus Free Electricity Start / End | Start and end of the next free electricity window (`null` outside the active period) |
371
+
372
+ ### Diagnostic Sensors
373
+
374
+ Appears under the **Diagnostics** tab of the HA device card.
375
+
376
+ #### Polling & Refresh
377
+
378
+ | Name | Description |
379
+ |---|---|
380
+ | Octopus Next Poll Time | Timestamp of the next scheduled automatic API refresh |
381
+ | Octopus Refresh Available At | Timestamp when the manual refresh cooldown expires (`null` = available now) |
382
+
383
+ #### API Usage
384
+
385
+ | Name | Description |
386
+ |---|---|
387
+ | Octopus API Requests (Last Hour) | Number of API calls made in the last 60 minutes |
388
+ | Octopus API Complexity (Last Hour) | Total estimated GraphQL complexity used in the last hour |
389
+ | Octopus API Complexity Usage | Percentage of the 50,000/hour GraphQL complexity limit consumed |
390
+
391
+ #### Raw Timestamps (UTC)
392
+
393
+ Exact UTC strings from the API, unaffected by timezone settings. Use these when you need unambiguous UTC values in automations.
394
+
395
+ | Name | Description |
396
+ |---|---|
397
+ | Octopus Next Charge Time (Raw) | Next charge time โ€” exact UTC string from API |
398
+ | Octopus Next Poll Time (Raw) | Next poll time โ€” exact UTC string |
399
+ | Octopus Slot 1 Start (Raw) | Slot 1 start โ€” exact UTC from API |
400
+ | Octopus Slot 1 End (Raw) | Slot 1 end โ€” exact UTC from API |
401
+ | Octopus Slot 2 Start (Raw) | Slot 2 start โ€” exact UTC from API |
402
+ | Octopus Slot 2 End (Raw) | Slot 2 end โ€” exact UTC from API |
403
+ | Octopus Slot 3 Start (Raw) | Slot 3 start โ€” exact UTC from API |
404
+ | Octopus Slot 3 End (Raw) | Slot 3 end โ€” exact UTC from API |
405
+ | Octopus Overall Window Start (Raw) | Window start โ€” exact UTC from API |
406
+ | Octopus Overall Window End (Raw) | Window end โ€” exact UTC from API |
407
+
408
+ #### Server-Timezone Timestamps (Locale)
409
+
410
+ Times in the Node-RED server's auto-detected timezone. Unlike display fields, these are never affected by the Timezone selector or `set_timezone` command.
411
+
412
+ | Name | Description |
413
+ |---|---|
414
+ | Octopus Next Charge Time (Locale) | Next charge time in Node-RED server timezone |
415
+ | Octopus Slot 1 Start (Locale) | Slot 1 start in server timezone |
416
+ | Octopus Slot 1 End (Locale) | Slot 1 end in server timezone |
417
+ | Octopus Slot 2 Start (Locale) | Slot 2 start in server timezone |
418
+ | Octopus Slot 2 End (Locale) | Slot 2 end in server timezone |
419
+ | Octopus Slot 3 Start (Locale) | Slot 3 start in server timezone |
420
+ | Octopus Slot 3 End (Locale) | Slot 3 end in server timezone |
421
+ | Octopus Overall Window Start (Locale) | Window start in server timezone |
422
+ | Octopus Overall Window End (Locale) | Window end in server timezone |
423
+ | Octopus Timezone Detected | IANA timezone auto-detected from the Node-RED server (e.g. `Europe/London`) |
424
+ | Octopus Timezone Applied | Active timezone currently used for all display timestamp fields |
425
+
426
+ #### Consumption Metadata
427
+
428
+ | Name | Description |
429
+ |---|---|
430
+ | Octopus Electricity Consumption From | Start of the electricity (import) consumption measurement period |
431
+ | Octopus Electricity Consumption To | End of the electricity (import) consumption measurement period |
432
+ | Octopus Electricity Export Consumption From | Start of the export consumption measurement period |
433
+ | Octopus Electricity Export Consumption To | End of the export consumption measurement period |
434
+ | Octopus Gas Consumption From | Start of the gas consumption measurement period |
435
+ | Octopus Gas Consumption To | End of the gas consumption measurement period |
436
+
437
+ #### Applicable Rates โ€” Import + Export
438
+
439
+ | Name | Description |
440
+ |---|---|
441
+ | Octopus Applicable Rates Slots | Number of import rate slots in the current 24-hour window |
442
+ | Octopus Electricity Export Rate Slots | Number of export rate slots in the current 24-hour window |
443
+ | Octopus Electricity Export Rate Prev | Previous half-hour export rate (p/kWh) |
444
+ | Octopus Electricity Export Rate Prev Ends | Timestamp when the previous export slot ended |
445
+ | Octopus Electricity Export Rate Next | Next half-hour export rate (p/kWh) |
446
+ | Octopus Electricity Export Rate Next From | Timestamp when the next export slot begins |
447
+
448
+ #### Error & Detail Sensors
449
+
450
+ `null` = healthy. Non-null = the last error message from that API category.
451
+
452
+ | Name | Description |
453
+ |---|---|
454
+ | Octopus Electricity Rates Error | Last error fetching electricity rates |
455
+ | Octopus Electricity Consumption Error | Last error fetching electricity consumption |
456
+ | Octopus Gas Rates Error | Last error fetching gas rates |
457
+ | Octopus Gas Consumption Error | Last error fetching gas consumption |
458
+ | Octopus Applicable Rates Error | Last error fetching the import applicable rates schedule |
459
+ | Octopus Electricity Export Rate Error | Last error fetching the export applicable rates schedule |
460
+ | Octopus Account Balance (Pence) | Account balance in pence (raw integer) |
461
+ | Octopus Account Error | Last error fetching account data |
462
+ | Octopus Octoplus Error | Last error fetching Octoplus data |
463
+ | Octopus WoF Electricity Max | Maximum Wheel of Fortune electricity spins allowed per period |
464
+ | Octopus WoF Electricity Used | Wheel of Fortune electricity spins used this period |
465
+ | Octopus WoF Gas Max | Maximum Wheel of Fortune gas spins allowed per period |
466
+ | Octopus WoF Gas Used | Wheel of Fortune gas spins used this period |
467
+ | Octopus WoF Error | Last error fetching Wheel of Fortune data |
468
+ | Octopus Home Mini Reading Time | Timestamp of the most recent Home Mini telemetry reading |
469
+ | Octopus Home Mini Error | Last error fetching Home Mini data |
470
+ | Octopus Saving Sessions Error | Last error fetching saving sessions data |
471
+ | Octopus Free Electricity Error | Last error fetching free electricity data |
472
+ | Octopus Completed Dispatches Error | Last error fetching completed dispatch history |
473
+ | Octopus Flex Planned Dispatches Error | Last error fetching flex planned dispatch schedule |
474
+ | Octopus Intelligent Error | Last error from the intelligent charging (EV slots) query |
475
+
476
+ ---
477
+
478
+ ## ๐Ÿ†“ Free Electricity & Seasonal Sensors
479
+
480
+ Octopus Energy runs free electricity sessions (typically Juneโ€“October) and saving sessions (typically Octoberโ€“March). The node polls for both and exposes binary sensors for automation use.
481
+
482
+ ### Free Electricity
483
+ - **`binary_sensor.octopus_free_electricity_active`** โ€” `ON` while a free window is in progress right now
484
+ - **`binary_sensor.octopus_free_electricity_available`** โ€” `ON` if an upcoming free window is scheduled
485
+
486
+ Use these to automatically start charging your car or battery when electricity is free:
487
+
488
+ ```yaml
489
+ automation:
490
+ - alias: "Charge during free electricity"
491
+ trigger:
492
+ platform: state
493
+ entity_id: binary_sensor.octopus_free_electricity_active
494
+ to: "on"
495
+ action:
496
+ service: switch.turn_on
497
+ target:
498
+ entity_id: switch.battery_charger
499
+ ```
500
+
501
+ ### Saving Sessions
502
+ - **`binary_sensor.octopus_saving_session_available`** โ€” `ON` if a saving session is upcoming
503
+ - **`sensor.octopus_saving_session_start`** / **`sensor.octopus_saving_session_end`** โ€” start and end times
504
+
505
+ ### Why These Sensors Are Null Outside Season
506
+
507
+ The Octopus API only returns free electricity and saving session data when those programmes are active. Outside their respective seasons the API returns an empty list (or in the case of saving sessions, the query itself is unavailable). The node handles this gracefully:
508
+
509
+ - Binary sensors remain `OFF` (not `unavailable`)
510
+ - Timestamp sensors (`saving_session_start`, `free_electricity_start`, etc.) return `null`
511
+ - In Home Assistant, `null`-valued configuration sensors may show as **unavailable** โ€” this is normal and expected
512
+
513
+ ---
514
+
515
+ ## ๐ŸŒ Timezone Configuration
516
+
517
+ By default, slot and window times are converted to the **server's auto-detected timezone** (wherever Node-RED is running). Three ways to configure:
518
+
519
+ ### Option 1: Node Config (static)
520
+ Set a fixed IANA timezone in the node editor:
521
+ - Open node โ†’ **Timezone** field โ†’ type `Australia/Sydney`
522
+ - Leave blank to use server auto-detect
523
+
524
+ ### Option 2: Home Assistant Select (dynamic, persists across restarts)
525
+ Use the **Timezone** select entity in Home Assistant:
526
+ - Home Assistant โ†’ Octopus Intelligent device โ†’ Timezone
527
+ - Change takes effect on next poll
528
+ - Persists across Node-RED restarts
529
+
530
+ ### Option 3: `set_timezone` Input Command
531
+ ```javascript
532
+ msg.payload = { set_timezone: "Europe/London" };
533
+ // Send to Octopus Intelligent node input
534
+ ```
535
+
536
+ ### Timestamp Tiers
537
+ | Field suffix | Timezone | Configurable? |
538
+ |---|---|---|
539
+ | `*_raw` | Always UTC (exact API string) | Never |
540
+ | `*_locale` | Server auto-detected | Never (always server TZ) |
541
+ | Display fields (`slot1_start`, `window_start`, etc.) | Resolved TZ | Yes โ€” via HA, config, or command |
542
+
543
+ ### Supported Timezones (HA select)
544
+ `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`
545
+
546
+ Any valid IANA timezone works in the node config field or `set_timezone` command.
547
+
548
+ ---
549
+
550
+ ## ๐Ÿ’ก Node-RED Usage
551
+
552
+ ### Basic Monitoring
553
+
554
+ ```
555
+ [Inject: Every 5 min] โ†’ [Octopus Intelligent] โ†’ [Debug]
556
+ ```
557
+
558
+ ### Set Preferences from Flow
559
+
560
+ ```javascript
561
+ msg.payload = {
562
+ set_limit: 85, // 85% charge
563
+ set_time: "07:30" // Ready by 07:30
564
+ };
565
+ return msg;
566
+ ```
567
+
568
+ Ready-by time: any half-hour slot from 00:00 to 23:30 (matches the Octopus app). Other values are rejected with an error and nothing is sent to Octopus. Charge limit values clamp to 5โ€“100 and round to 5; non-numeric values and `set_limit: 0` are rejected.
569
+
570
+ ### Set Timezone from Flow
571
+
572
+ ```javascript
573
+ msg.payload = { set_timezone: "Australia/Sydney" };
574
+ return msg;
575
+ ```
576
+
577
+ ### Toggle Smart Charging from Flow
578
+
579
+ ```javascript
580
+ msg.payload = { set_smart_charging: true }; // enable (unsuspend)
581
+ msg.payload = { set_smart_charging: false }; // disable (suspend)
582
+ return msg;
583
+ ```
584
+
585
+ **Example: suspend charging when home battery is in use**
586
+ ```
587
+ [Inject: suspend] โ†’ [Function: set_smart_charging=false] โ†’ [Octopus Intelligent]
588
+ [Inject: resume] โ†’ [Function: set_smart_charging=true] โ†’ [Octopus Intelligent]
589
+ ```
590
+
591
+ ### `set_charge_cap`
592
+
593
+ ```js
594
+ msg.payload = { set_charge_cap: true }; // limit smart charging to off-peak rates only
595
+ msg.payload = { set_charge_cap: false };
596
+ ```
597
+
598
+ Non-boolean values are ignored. Also available as the **Charge Cap** switch in Home Assistant.
599
+
600
+ ### Combining commands
601
+
602
+ One message can carry several commands, and each is applied independently:
603
+
604
+ ```js
605
+ msg.payload = { set_limit: 90, set_time: "06:30", set_charge_cap: true };
606
+ ```
607
+
608
+ `set_limit` and `set_time` are sent to Octopus together, so an invalid value in either rejects both; other commands in the same message still apply.
609
+
610
+ ### Output Format
611
+
612
+ ```json
613
+ {
614
+ "payload": {
615
+ "next_start": "2026-05-03 01:30:00+01:00",
616
+ "total_energy": 42.5,
617
+ "next_kwh": "15.20",
618
+ "next_source": "smart-charge",
619
+ "confirmed_limit": 80,
620
+ "confirmed_time": "07:00",
621
+ "pending_limit": 80,
622
+ "pending_time": "07:00",
623
+ "charging_now": false,
624
+ "smart_charging": true,
625
+ "charge_cap": false,
626
+ "next_poll": "2026-05-03T10:35:00Z",
627
+ "refresh_available_at": null,
628
+ "api_requests_hour": 12,
629
+ "api_complexity_hour": 3600,
630
+ "api_complexity_percent": 7.2,
631
+ "slot1_start": "2026-05-03 01:30:00+01:00",
632
+ "slot1_end": "2026-05-03 05:30:00+01:00",
633
+ "slot2_start": null,
634
+ "slot2_end": null,
635
+ "slot3_start": null,
636
+ "slot3_end": null,
637
+ "window_start": "2026-05-03 01:30:00+01:00",
638
+ "window_end": "2026-05-03 05:30:00+01:00",
639
+ "timezone_detected": "Europe/London",
640
+ "timezone_applied": "Europe/London",
641
+ "next_start_locale": "2026-05-03 01:30:00+01:00",
642
+ "slot1_start_locale": "2026-05-03 01:30:00+01:00",
643
+ "slot1_end_locale": "2026-05-03 05:30:00+01:00",
644
+ "window_start_locale": "2026-05-03 01:30:00+01:00",
645
+ "window_end_locale": "2026-05-03 05:30:00+01:00",
646
+ "completed_dispatches_count": 3,
647
+ "completed_dispatches_error": null,
648
+ "flex_planned_dispatches_count": 1,
649
+ "flex_planned_dispatches_error": null,
650
+ "intelligent_error": null,
651
+ "electricity_unit_rate": null,
652
+ "electricity_standing_charge": 53.94,
653
+ "electricity_tariff_code": "E-1R-INTELLI-VAR-22-01-01-A",
654
+ "electricity_valid_from": "2022-01-01T00:00:00Z",
655
+ "electricity_valid_to": null,
656
+ "electricity_consumption_kwh": 8.4,
657
+ "electricity_consumption_from": "2026-05-02T00:00:00Z",
658
+ "electricity_consumption_to": "2026-05-03T00:00:00Z",
659
+ "electricity_rates_error": null,
660
+ "electricity_consumption_error": null,
661
+ "applicable_rates_count": 28,
662
+ "applicable_rates_current_pence": 10.33,
663
+ "applicable_rates_error": null,
664
+ "gas_unit_rate": 6.24,
665
+ "gas_standing_charge": 31.05,
666
+ "gas_tariff_code": "G-1R-VAR-22-11-01-A",
667
+ "gas_valid_from": "2022-11-01T00:00:00Z",
668
+ "gas_valid_to": null,
669
+ "gas_consumption_kwh": 12.1,
670
+ "gas_consumption_from": "2026-05-02T00:00:00Z",
671
+ "gas_consumption_to": "2026-05-03T00:00:00Z",
672
+ "gas_rates_error": null,
673
+ "gas_consumption_error": null,
674
+ "account_balance_pence": 10900,
675
+ "account_balance_pounds": 109,
676
+ "account_error": null,
677
+ "octoplus_enrolled": true,
678
+ "octoplus_enrollment_status": "ENROLLED",
679
+ "octoplus_loyalty_points_user": true,
680
+ "octoplus_error": null,
681
+ "wheel_of_fortune_electricity_spins": 2,
682
+ "wheel_of_fortune_electricity_max": 3,
683
+ "wheel_of_fortune_electricity_used": 1,
684
+ "wheel_of_fortune_gas_spins": 1,
685
+ "wheel_of_fortune_gas_max": 1,
686
+ "wheel_of_fortune_gas_used": 0,
687
+ "wheel_of_fortune_error": null,
688
+ "mini_demand_kw": 0.082,
689
+ "mini_consumption_delta_kwh": 0.002,
690
+ "mini_read_at": "2026-05-03T10:00:00Z",
691
+ "home_mini_error": null,
692
+ "saving_session_available": false,
693
+ "saving_session_start": null,
694
+ "saving_session_end": null,
695
+ "saving_session_joined": false,
696
+ "saving_session_points": null,
697
+ "saving_sessions_error": null,
698
+ "free_electricity_active": false,
699
+ "free_electricity_available": false,
700
+ "free_electricity_start": null,
701
+ "free_electricity_end": null,
702
+ "free_electricity_error": null
703
+ },
704
+ "debug": {
705
+ "success": true,
706
+ "step": "complete",
707
+ "apiCalls": [
708
+ {"name": "authentication", "tokenObtained": true},
709
+ {"name": "intelligent", "slotsFound": 1},
710
+ {"name": "electricity_rates", "success": true},
711
+ {"name": "electricity_consumption", "success": true},
712
+ {"name": "gas_rates", "success": true},
713
+ {"name": "gas_consumption", "success": true},
714
+ {"name": "home_mini", "success": true},
715
+ {"name": "account", "success": true}
716
+ ]
717
+ }
718
+ }
719
+ ```
720
+
721
+ > **Note:** `electricity_unit_rate` is `null` for half-hourly tariffs (e.g. Intelligent Octopus Go). Use `applicable_rates_current_pence` for the live rate on HH tariffs.
722
+
723
+ > **v1.3.0 additions:** The example above shows the v1.2.x payload shape for clarity. v1.3.0 adds ~14 additional fields covering electricity export (`electricity_export_unit_rate`, `electricity_export_tariff_code`, `electricity_export_consumption_kwh`, full `electricity_export_rate[]` half-hourly array with current/prev/next slot summaries) and import rate adjacency (`applicable_rates_prev_pence`, `_prev_gbp`, `_prev_to`, `_next_pence`, `_next_gbp`, `_next_from`). For the authoritative current set, inspect `msg.payload` in a Debug node after a real poll, or read `lib/payload.js` in the source.
724
+
725
+ ---
726
+
727
+ ## ๐Ÿก Home Assistant Automation Examples
728
+
729
+ ### Notify When Charging Starts
730
+
731
+ ```yaml
732
+ automation:
733
+ - alias: "EV Charging Starting"
734
+ trigger:
735
+ platform: state
736
+ entity_id: binary_sensor.octopus_charging_now
737
+ to: "on"
738
+ action:
739
+ service: notify.mobile_app
740
+ data:
741
+ message: "EV charging started"
742
+ ```
743
+
744
+ ### Charge During Free Electricity Window
745
+
746
+ ```yaml
747
+ automation:
748
+ - alias: "Start battery charge on free electricity"
749
+ trigger:
750
+ platform: state
751
+ entity_id: binary_sensor.octopus_free_electricity_active
752
+ to: "on"
753
+ action:
754
+ service: switch.turn_on
755
+ target:
756
+ entity_id: switch.battery_charger
757
+ - alias: "Stop battery charge after free electricity"
758
+ trigger:
759
+ platform: state
760
+ entity_id: binary_sensor.octopus_free_electricity_active
761
+ to: "off"
762
+ action:
763
+ service: switch.turn_off
764
+ target:
765
+ entity_id: switch.battery_charger
766
+ ```
767
+
768
+ ### Run Dishwasher During Cheap Rate
769
+
770
+ ```yaml
771
+ automation:
772
+ - alias: "Dishwasher During Cheap Window"
773
+ trigger:
774
+ platform: time_pattern
775
+ minutes: "/5"
776
+ condition:
777
+ - condition: template
778
+ value_template: >
779
+ {% set start = as_timestamp(states('sensor.octopus_slot_1_start')) %}
780
+ {% set end = as_timestamp(states('sensor.octopus_slot_1_end')) %}
781
+ {% set now = as_timestamp(now()) %}
782
+ {{ start <= now <= end }}
783
+ action:
784
+ service: switch.turn_on
785
+ target:
786
+ entity_id: switch.dishwasher
787
+ ```
788
+
789
+ ### Alert When Saving Session Available
790
+
791
+ ```yaml
792
+ automation:
793
+ - alias: "Saving session alert"
794
+ trigger:
795
+ platform: state
796
+ entity_id: binary_sensor.octopus_saving_session_available
797
+ to: "on"
798
+ action:
799
+ service: notify.mobile_app
800
+ data:
801
+ message: >
802
+ Saving session available:
803
+ {{ states('sensor.octopus_saving_session_start') }}
804
+ to {{ states('sensor.octopus_saving_session_end') }}
805
+ ```
806
+
807
+ ---
808
+
809
+ ## ๐Ÿ” Troubleshooting
810
+
811
+ ### No Data (All Sensors Null/0)
812
+
813
+ Check `msg.debug` output in a Debug node:
814
+
815
+ - Account format must include `A-` prefix
816
+ - Invalid API key โ€” regenerate at Octopus dashboard
817
+ - Not on a recognised Octopus tariff (EV sensors require Intelligent Octopus Go)
818
+ - Car not plugged in (no slots scheduled) โ€” EV sensors null is normal when no charging is planned
819
+
820
+ ### Authentication Failing
821
+
822
+ Check `msg.debug.apiCalls[0].errors` for details. Regenerate your API key and update the node configuration.
823
+
824
+ ### Sensors Unavailable in Home Assistant
825
+
826
+ 1. Verify MQTT broker is running
827
+ 2. Check Node-RED can connect to MQTT broker
828
+ 3. Deploy the flow to trigger discovery
829
+ 4. Confirm Home Assistant MQTT integration is enabled
830
+
831
+ ### electricity_unit_rate Always Null
832
+
833
+ This is expected on half-hourly tariffs like Intelligent Octopus Go. The tariff has no single unit rate โ€” prices vary by half-hour slot. Use `applicable_rates_current_pence` for the live rate instead.
834
+
835
+ ### Upgrading from v1.2.x โ€” Sensors Look Different
836
+
837
+ v1.3.0 adds ~70 new sensors but does not rename or remove any v1.2 sensors. Existing automations and dashboards continue working unchanged. New sensors appear automatically in Home Assistant after the first poll following upgrade.
838
+
839
+ Two existing Octoplus booleans (`octoplus_enrolled` and `octoplus_loyalty_points_user`) move from the `sensor.` domain to `binary_sensor.` in v1.3 because they are boolean values and HA's sensor domain doesn't accept booleans cleanly. If you have automations referencing the old `sensor.` entity IDs, update them to the new `binary_sensor.` IDs after upgrade.
840
+
841
+ ### Stale Entities After Early v1.3 Dev Build
842
+
843
+ If you installed an early v2 build before final release, some entity IDs may have changed. To clean up stale entities:
844
+
845
+ 1. In HA โ†’ **Settings โ†’ Devices & Services โ†’ MQTT**
846
+ 2. Find each stale entity name in Developer Tools โ†’ MQTT
847
+ 3. Publish an **empty retained payload** to its config topic:
848
+ ```
849
+ Topic: homeassistant/sensor/nodered_A-XXXX_<entity_id>/config
850
+ Payload: (empty)
851
+ Retain: โœ“
852
+ ```
853
+ This removes the entity from the broker โ€” HA drops it automatically.
854
+
855
+ ### Home Mini Not Showing
856
+
857
+ 1. Tick **Enable Home Mini** in node config
858
+ 2. Verify your Octopus account has a smart meter registered (visible in the Octopus app)
859
+ 3. Check `msg.payload.home_mini_error` in a debug node for the specific error
860
+
861
+ ### New Category Sensors All Null After Deploy
862
+
863
+ Account discovery runs once at startup. If it fails, check `msg.debug` for auth errors, verify your API key, and redeploy.
864
+
865
+ ### Seasonal Sensors Show "Unavailable"
866
+
867
+ Saving session sensors are only populated Octoberโ€“March. Free electricity sensors are only populated Juneโ€“October. Outside season, `null` values cause these sensors to show as unavailable in HA โ€” this is correct behaviour, not a bug.
868
+
869
+ ### Changes Not Applying
870
+
871
+ This is by design. Use the **Apply Changes** button to submit. This prevents API spam when making multiple adjustments.
872
+
873
+ ---
874
+
875
+ ## ๐Ÿ› ๏ธ How It Works
876
+
877
+ ### Startup โ€” Account Discovery
878
+
879
+ On first deploy, the node queries the Octopus API to detect which products are registered on your account:
880
+
881
+ - **Electricity** โ€” always enabled if an electricity agreement exists
882
+ - **Gas** โ€” enabled if a gas agreement exists
883
+ - **Intelligent EV** โ€” enabled if an EV device is registered (Intelligent Octopus Go)
884
+ - **Home Mini** โ€” enabled if a smart meter device is registered AND the Home Mini checkbox is ticked
885
+ - **Wheel of Fortune / Saving Sessions / Account** โ€” always polled if credentials are valid
886
+
887
+ Discovery sets which categories are active. No manual configuration required.
888
+
889
+ ### Category Scheduler
890
+
891
+ Each data category polls on its own interval (configurable per category in the node editor). A 1-second clock-aligned scheduler checks which categories are due each tick. Categories poll independently โ€” a slow gas API response does not delay your EV slot update.
892
+
893
+ ### Authentication Flow
894
+
895
+ 1. **Exchange API key** for a short-lived token
896
+ 2. **Run category polls** in parallel โ€” each category makes its own GraphQL query
897
+ 3. **Merge results** into a single payload object
898
+ 4. **Publish** to Node-RED output + MQTT state topic
899
+
900
+ ### Exponential Backoff (preference changes)
901
+
902
+ When changing charge limit or ready time:
903
+
904
+ ```
905
+ Mutation sent โ†’ Wait 15s โ†’ Validate
906
+ โ†“ Not confirmed yet?
907
+ โ†’ Wait 30s โ†’ Validate
908
+ โ†“ Not confirmed yet?
909
+ โ†’ Wait 60s โ†’ Validate
910
+ โ†“ Not confirmed yet?
911
+ โ†’ Wait 120s โ†’ Final check
912
+ โ†“ Then normal interval resumes
913
+ ```
914
+
915
+ This prevents sensors becoming "unavailable" during updates.
916
+
917
+ ### Debug Information
918
+
919
+ Every message includes `msg.debug`:
920
+
921
+ ```json
922
+ {
923
+ "timestamp": "2026-05-03T10:30:00Z",
924
+ "success": true,
925
+ "step": "complete",
926
+ "apiCalls": [
927
+ {"name": "authentication", "tokenObtained": true},
928
+ {"name": "intelligent", "slotsFound": 1}
929
+ ]
930
+ }
931
+ ```
932
+
933
+ ---
934
+
935
+ ## ๐Ÿ“ License
936
+
937
+ MIT License - Copyright (c) 2025 Andrew Somerharju Neale
938
+
939
+ See [LICENSE](LICENSE) file for full details.
940
+
941
+ ---
942
+
943
+ ## โš ๏ธ Disclaimer
944
+
945
+ This is an **unofficial integration** and is not affiliated with, endorsed by, or connected to Octopus Energy Ltd.
946
+
947
+ Use at your own risk. The Octopus Energy name and logo are trademarks of Octopus Energy Ltd.
948
+
949
+ ---
950
+
951
+ ## ๐Ÿ”— Links
952
+
953
+ - **npm**: https://www.npmjs.com/package/node-red-contrib-octopus-intelligent
954
+ - **GitHub**: https://github.com/ASomerN/node-red-contrib-octopus-intelligent
955
+ - **Issues**: https://github.com/ASomerN/node-red-contrib-octopus-intelligent/issues
956
+ - **Octopus Intelligent**: https://octopus.energy/intelligent/
957
+ - **API Docs**: https://developer.octopus.energy/docs/api/
958
+
959
+ ---
960
+
961
+ ## ๐Ÿ“œ Changelog
962
+
963
+ See [CHANGELOG.md](CHANGELOG.md) for detailed version history and release notes.
964
+
965
+ ### v1.3.0 (2026-05-12)
966
+
967
+ Major additive release โ€” full consumer read coverage. No breaking changes; all v1.2.x entity IDs, payload fields, and automations continue working unchanged.
968
+
969
+ **New read categories:**
970
+ - **Electricity import** โ€” live unit rate, standing charge, tariff code + validity dates, daily consumption, half-hourly applicable rates (current / prev / next), GBP/kWh rate for Energy Dashboard
971
+ - **Electricity export** โ€” full read parity with import: live export rate, standing charge, tariff code (e.g. `AGILE-OUTGOING-19-05-13`), validity dates, daily export consumption, half-hourly export rate slots (48 entries), prev / next slot rates and transition timestamps
972
+ - **Gas** โ€” unit rate, standing charge, tariff code + validity, daily consumption (account-conditional)
973
+ - **Octopus Home Mini** โ€” real-time grid demand (kW), half-hour consumption (kWh), last reading timestamp
974
+ - **Saving sessions** โ€” upcoming session start/end, joined status (now read from `api.backend.octopus.energy`)
975
+ - **Free electricity** โ€” upcoming/active session detection, binary sensors for automation
976
+ - **Wheel of Fortune** โ€” electricity and gas spin counts (now using non-deprecated `wheelOfFortuneSpinsAllowed` on backend endpoint)
977
+ - **Account balance** โ€” credit/debit in ยฃ and pence
978
+ - **Octoplus** โ€” enrollment status (string) + enrolled and loyalty-points-user booleans
979
+
980
+ **Bug fixes carried in alongside the additive work:**
981
+ - **Import / export meter point selection** โ€” meter point selection now uses the `direction` field, not array position. Earlier dev builds on accounts with both import + export meters could surface export data as if it were import (live "current rate" showing the export Agile rate instead of the import tariff). Fixed before release; no stable v1.x build was affected.
982
+ - **MQTT transport** โ€” added `User-Agent` header required by `api.backend.octopus.energy`. Without it the backend returns 403 at the edge, which surfaced as "WoF returns HTML" / saving sessions silently broken.
983
+ - **MQTT discovery for boolean sensors** โ€” `octoplus_enrolled` and `octoplus_loyalty_points_user` were previously published to the `sensor` MQTT domain; HA's sensor handler doesn't accept raw boolean values cleanly, so the entities never registered on some installs. Now published as `binary_sensor` โ€” registers reliably.
984
+ - **MQTT discovery for read-only info sensors** โ€” removed `entity_category: config` from tariff codes, validity dates, etc. That category is intended for user-configurable entities; on read-only sensors HA's state handling caused them to stick at "unavailable". Moved to the main entity list.
985
+
986
+ **Backwards compatibility:** zero breaking changes. New entities appear automatically after first poll following upgrade. Existing automations continue unchanged.
987
+
988
+ ### v1.2.1 (2026-04-29)
989
+ - **Deprecated API migration** โ€” moved to current `devices` query and `setDevicePreferences` mutation
990
+
991
+ ### v1.2.0 (2026-04-26)
992
+ - **Smart Charging Toggle** โ€” suspend/resume Octopus intelligent charging from Node-RED or Home Assistant
993
+ - **HA MQTT Switch** โ€” auto-discovered Smart Charging switch entity
994
+ - **`smart_charging` payload field** โ€” live state in every message
995
+
996
+ ### v1.0.4 (2025-12-11)
997
+ - **Manual Refresh Button** โ€” Force API refresh via Home Assistant with 30s cooldown
998
+ - **Next Poll Timer** โ€” See when next automatic refresh occurs
999
+ - **API Complexity Monitoring** โ€” Track API usage against 50,000/hour limit
1000
+ - **Rate Limiting** โ€” MQTT button (30s cooldown), Node-RED input (no limit)
1001
+
1002
+ ---
1003
+
1004
+ **Made with โšก for the Octopus Energy & Home Assistant communities**