node-red-contrib-octopus-intelligent 1.6.1 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +129 -19
  2. package/README.md +386 -156
  3. package/examples/basic-monitoring.json +1 -1
  4. package/examples/boost-on-cheap-or-surplus.json +171 -0
  5. package/examples/charging-and-error-alerts.json +95 -0
  6. package/examples/cheapest-window-planner.json +165 -0
  7. package/examples/daily-charging-summary.json +165 -0
  8. package/examples/ha-dashboard.yaml +67 -2
  9. package/examples/mqtt-integration.json +1 -1
  10. package/examples/node-red-dashboard-flow.json +92 -2
  11. package/examples/set-preferences.json +1 -1
  12. package/lib/active-now.js +33 -0
  13. package/lib/auth.js +6 -1
  14. package/lib/boost.js +85 -0
  15. package/lib/categories/account.js +3 -3
  16. package/lib/categories/applicable-rates.js +29 -19
  17. package/lib/categories/completed-dispatches.js +2 -1
  18. package/lib/categories/electricity.js +23 -13
  19. package/lib/categories/flex-planned-dispatches.js +2 -2
  20. package/lib/categories/free-electricity.js +13 -1
  21. package/lib/categories/gas.js +13 -6
  22. package/lib/categories/home-mini.js +11 -3
  23. package/lib/categories/intelligent.js +87 -21
  24. package/lib/categories/octoplus.js +6 -3
  25. package/lib/categories/saving-sessions.js +15 -1
  26. package/lib/categories/smartflex-inverter.js +95 -0
  27. package/lib/categories/smartflex-vehicle.js +198 -0
  28. package/lib/categories/wheel-of-fortune.js +3 -2
  29. package/lib/commands.js +25 -3
  30. package/lib/discovery-retry.js +4 -1
  31. package/lib/discovery.js +71 -9
  32. package/lib/graphql-errors.js +160 -4
  33. package/lib/graphql.js +104 -7
  34. package/lib/http-get-json.js +64 -6
  35. package/lib/payload.js +15 -0
  36. package/lib/poll-retry.js +71 -0
  37. package/lib/poll-tick.js +88 -20
  38. package/lib/preferences.js +4 -2
  39. package/lib/scheduler.js +46 -8
  40. package/lib/sensor-definitions.js +51 -1
  41. package/lib/timezone.js +19 -1
  42. package/lib/values.js +47 -0
  43. package/octopus-intelligent.html +74 -34
  44. package/octopus-intelligent.js +1379 -250
  45. package/package.json +1 -1
package/lib/timezone.js CHANGED
@@ -1,4 +1,8 @@
1
1
  'use strict';
2
+ const { shown } = require('./values');
3
+
4
+ // Longest IANA names are about 30 characters; the value is also an HA select state.
5
+ const MAX_TIMEZONE_LENGTH = 64;
2
6
 
3
7
  function convertToTimezone(dateStr, tz) {
4
8
  if (!dateStr || typeof dateStr !== 'string') return dateStr;
@@ -46,4 +50,18 @@ function resolveTimezone(nd) {
46
50
  }
47
51
  }
48
52
 
49
- module.exports = { convertToTimezone, resolveTimezone };
53
+ // A timezone from set_timezone (input or MQTT): a non-empty IANA name that Intl knows, at most
54
+ // MAX_TIMEZONE_LENGTH characters. Trimmed. A wrong name used to be stored as it was, and every
55
+ // display time then kept the raw UTC text.
56
+ function validateTimezone(value) {
57
+ const tz = typeof value === 'string' ? value.trim() : '';
58
+ if (tz.length > 0 && tz.length <= MAX_TIMEZONE_LENGTH) {
59
+ try {
60
+ new Intl.DateTimeFormat('en-GB', { timeZone: tz });
61
+ return { ok: true, timezone: tz };
62
+ } catch (e) { /* unknown zone: fall through */ }
63
+ }
64
+ return { ok: false, error: `Invalid timezone '${shown(value)}' — must be an IANA name such as Europe/London` };
65
+ }
66
+
67
+ module.exports = { convertToTimezone, resolveTimezone, validateTimezone, MAX_TIMEZONE_LENGTH };
package/lib/values.js ADDED
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ // Kraken numeric scalars can arrive as numbers or as JSON strings ("12.5"). A value that is
4
+ // not a finite number (null, "abc", "Infinity", 1e400 in the JSON, a list) becomes null, so
5
+ // NaN and Infinity never reach msg.payload or Home Assistant.
6
+ function toNumber(value) {
7
+ if (typeof value === 'number') return Number.isFinite(value) ? value : null;
8
+ if (typeof value !== 'string') return null;
9
+ const n = parseFloat(value);
10
+ return Number.isFinite(n) ? n : null;
11
+ }
12
+
13
+ // A value as text for an error message, cut to `max` characters. Never throws: a Symbol, an
14
+ // object with no prototype or a throwing toString still gives some text.
15
+ function shown(value, max = 40) {
16
+ let s;
17
+ try {
18
+ s = String(value);
19
+ } catch (e) {
20
+ s = Object.prototype.toString.call(value);
21
+ }
22
+ return s.length > max ? `${s.slice(0, max)}...` : s;
23
+ }
24
+
25
+ // Home Assistant rejects a state of 255 characters or more, and the entity then stops updating.
26
+ const MAX_STATE_LENGTH = 254;
27
+
28
+ // Text from the API that becomes an entity state (a tariff code, a time Octopus sent that could
29
+ // not be read, a charge source) is cut to MAX_STATE_LENGTH.
30
+ function capText(value) {
31
+ return typeof value === 'string' && value.length > MAX_STATE_LENGTH
32
+ ? `${value.slice(0, MAX_STATE_LENGTH - 3)}...` : value;
33
+ }
34
+
35
+ // `parse` with every top-level text field of its result cut by capText. Lists and objects
36
+ // (attributes such as the rate list) are left as they are.
37
+ function capStrings(parse) {
38
+ return function capped(...args) {
39
+ const out = parse(...args);
40
+ if (!out || typeof out !== 'object') return out;
41
+ const copy = Object.assign({}, out);
42
+ for (const k of Object.keys(copy)) copy[k] = capText(copy[k]);
43
+ return copy;
44
+ };
45
+ }
46
+
47
+ module.exports = { toNumber, shown, capText, capStrings, MAX_STATE_LENGTH };
@@ -22,7 +22,9 @@
22
22
  wheelOfFortuneInterval: { value: 60, validate: RED.validators.number() },
23
23
  // Home Mini
24
24
  enableHomeMini: { value: false },
25
- homeMiniInterval: { value: 1, validate: RED.validators.number() }
25
+ homeMiniInterval: { value: 1, validate: RED.validators.number() },
26
+ // SmartFlex inverter (experimental, v1.7.0)
27
+ enableSmartflexInverter: { value: false }
26
28
  },
27
29
  credentials: {
28
30
  apiKey: { type: "password" }
@@ -130,57 +132,84 @@
130
132
  <input type="number" id="node-input-homeMiniInterval" style="width:55px;" placeholder="1">
131
133
  <span style="font-size:0.85em;color:#888;">min</span>
132
134
  </div>
135
+
136
+ <div class="form-row" style="display:flex;align-items:center;flex-wrap:wrap;gap:6px;">
137
+ <label for="node-input-enableSmartflexInverter" style="width:120px;flex-shrink:0;">
138
+ <i class="fa fa-sun-o"></i> Inverter
139
+ </label>
140
+ <input type="checkbox" id="node-input-enableSmartflexInverter" style="width:auto;">
141
+ <span style="font-size:0.85em;color:#666;margin-left:4px;">experimental: not yet verified on a real inverter. Every 5 min.</span>
142
+ </div>
133
143
  </script>
134
144
 
135
145
  <script type="text/html" data-help-name="octopus-intelligent">
136
- <p>This node integrates with the <strong>Octopus Energy Intelligent Octopus Go</strong> API to retrieve planned charging slots and preferences.</p>
137
- <p>Configure your Account Number and API Key, then deploy the flow. The node will fetch data at regular intervals and output charging information.</p>
138
- <p>Enable MQTT to automatically configure Home Assistant entities via auto-discovery.</p>
146
+ <p>This node reads Octopus Energy data into Node-RED. It covers EV charging slots, electricity and gas rates, consumption, account balance, and rewards. EV charging features need Intelligent Octopus Go.</p>
147
+ <p>Enter your Account Number and API Key, then deploy. The node polls on its own and sends the data in <code>msg.payload</code>.</p>
148
+ <p>Tick Enable Home Assistant MQTT to also publish the data to Home Assistant with auto-discovery.</p>
139
149
 
140
150
  <h3>Examples</h3>
141
151
 
142
152
  <h4>1. Basic Monitoring</h4>
143
- <p>Monitor your charging slots every 5 minutes:</p>
144
- <pre>[{"id":"1","type":"inject","name":"Every 5 min","props":[{"p":"payload"}],"repeat":"300","crontab":"","once":true,"topic":"","payload":"","payloadType":"date","x":130,"y":80,"wires":[["2"]]},{"id":"2","type":"octopus-intelligent","name":"Octopus Intelligent","account":"A-XXXXXXXX","apiKey":"sk_live_...","refreshInterval":"5","enableMqtt":false,"x":340,"y":80,"wires":[["3"]]},{"id":"3","type":"debug","name":"Debug Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":570,"y":80,"wires":[]}]</pre>
153
+ <p>The node polls on its own after deploy. Connect a Debug node to see the output. Add an Inject node only to force a refresh.</p>
154
+ <pre>[{"id":"2","type":"octopus-intelligent","name":"Octopus Intelligent","accountNumber":"A-XXXXXXXX","refreshInterval":"5","enableMqtt":false,"x":340,"y":80,"wires":[["3"]]},{"id":"3","type":"debug","name":"Debug Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":570,"y":80,"wires":[]}]</pre>
155
+ <p>Enter your API key in the node editor after you import the flow.</p>
145
156
 
146
157
  <h4>2. Set Preferences from Flow</h4>
147
- <p>Control charge limit and ready time programmatically:</p>
148
- <pre>[{"id":"1","type":"inject","name":"Set 85% by 07:30","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"topic":"","payload":"{\"set_limit\":85,\"set_time\":\"07:30\"}","payloadType":"json","x":150,"y":140,"wires":[["2"]]},{"id":"2","type":"octopus-intelligent","name":"Octopus Intelligent","account":"A-XXXXXXXX","apiKey":"sk_live_...","refreshInterval":"5","enableMqtt":true,"mqttBroker":"mqtt-broker","x":380,"y":140,"wires":[["3"]]},{"id":"3","type":"debug","name":"Confirmation","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":610,"y":140,"wires":[]}]</pre>
158
+ <p>Set the charge limit and ready-by time from a flow.</p>
159
+ <pre>[{"id":"1","type":"inject","name":"Set 85% by 07:30","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"topic":"","payload":"{\"set_limit\":85,\"set_time\":\"07:30\"}","payloadType":"json","x":150,"y":140,"wires":[["2"]]},{"id":"2","type":"octopus-intelligent","name":"Octopus Intelligent","accountNumber":"A-XXXXXXXX","refreshInterval":"5","enableMqtt":false,"x":380,"y":140,"wires":[["3"]]},{"id":"3","type":"debug","name":"Confirmation","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":610,"y":140,"wires":[]}]</pre>
160
+ <p>Enter your API key in the node editor after you import the flow.</p>
161
+
162
+ <p>The ready-by time can be any half-hour slot from 00:00 to 23:30, as in the Octopus app. Any other value gives a node error and nothing is sent to Octopus. The node clamps the charge limit to between 5 and 100 and rounds it to the nearest 5. A limit that is not a number above 0, such as <code>set_limit: 0</code>, gives a node error.</p>
163
+
164
+ <h4>Other commands</h4>
165
+ <p><code>set_timezone</code> takes an IANA name such as <code>Europe/London</code>. An empty value is ignored. <code>set_smart_charging</code> takes <code>true</code> or <code>false</code>, and any other value is ignored with no error. Each charging poll reads the smart charging state, so a change made in the Octopus app shows up in <code>smart_charging</code>.</p>
166
+ <pre>msg.payload = { set_smart_charging: false };
167
+ msg.payload = { set_timezone: "Europe/London" };</pre>
168
+ <p>The node checks the <code>set_timezone</code> name. A name it does not know, or one over 64 characters, writes an error to the Node-RED log and the timezone is not changed. It does not update the Home Assistant Timezone select.</p>
149
169
 
150
- <p>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&ndash;100 and round to 5; non-numeric values and <code>set_limit: 0</code> are rejected.</p>
170
+ <h4>Refresh</h4>
171
+ <p>Send any message without a command to refresh the charging data right away. There is no cooldown on this input. A message with a command never starts a refresh. A refresh updates the charging data only, not rates, gas, or account data.</p>
151
172
 
152
173
  <h4>Charge Cap</h4>
153
- <p>Limit smart charging to off-peak rates only (as in the Octopus app). Non-boolean values are ignored. Also available as the <strong>Charge Cap</strong> switch in Home Assistant:</p>
174
+ <p>Charge Cap limits smart charging to off-peak rates only, as in the Octopus app. The node ignores any value other than <code>true</code> or <code>false</code>. The <strong>Charge Cap</strong> switch in Home Assistant does the same job.</p>
154
175
  <pre>msg.payload = { set_charge_cap: true };</pre>
155
- <p>The <code>charge_cap</code> payload field is <code>true</code>/<code>false</code> when Charge Cap is on/off, and <code>null</code> when not applicable to the device.</p>
176
+ <p>The <code>charge_cap</code> payload field is <code>true</code> when Charge Cap is on, <code>false</code> when it is off, and <code>null</code> when the device does not support it.</p>
177
+
178
+ <h4>Boost Charge</h4>
179
+ <p>Start charging now, outside the Octopus plan. Send <code>false</code> to cancel the boost. Only <code>true</code> and <code>false</code> work. Any other value gives a node error and sends nothing. The <strong>Boost Charge</strong> switch in Home Assistant does the same job.</p>
180
+ <pre>msg.payload = { set_boost: true };</pre>
181
+ <p>This is not the same as <code>set_smart_charging</code>, which pauses or resumes Octopus control. Octopus can refuse a boost, for example when the car is unplugged. The node logs the Octopus error and does not retry. If Octopus refuses the same choice 3 times in 10 minutes, the node ignores that choice for 10 minutes and logs one warning.</p>
182
+ <p>The node sends one boost request at a time, at least 5 seconds apart, and only your last choice. When Octopus accepts it, the node polls Octopus soon after (it waits if 3 planned-dispatch queries already went out in the last minute). The switch shows what you asked for until Octopus agrees, for up to 2 minutes. After a refusal it does not poll. If the answer is not clear, the node leaves the switch as it was and polls to check. If Octopus does not answer within 75 seconds, the node gives up on that request, sets <code>boost_error</code>, and polls to check.</p>
183
+ <p>The <code>boosting</code> payload field is <code>true</code> while a boost runs, <code>false</code> when not, and <code>null</code> until known. <code>boosting</code> goes back to <code>null</code> if no charging poll has confirmed it for twice the refresh interval. <code>boost_error</code> holds the error from the last <code>set_boost</code> that failed. A boost that works clears it, and so does the first charging poll that reads the device state a minute or more later. A boost counts as charging, so <code>charging_now</code> is <code>true</code> during a boost.</p>
156
184
 
157
185
  <h4>Combining commands</h4>
158
- <p>One message can carry several commands, and each is applied independently:</p>
186
+ <p>One message can carry several commands, and the node applies each one separately.</p>
159
187
  <pre>msg.payload = { set_limit: 90, set_time: "06:30", set_charge_cap: true };</pre>
160
- <p><code>set_limit</code> and <code>set_time</code> are sent to Octopus together, so an invalid value in either rejects both; other commands in the same message still apply.</p>
188
+ <p>The node sends <code>set_limit</code> and <code>set_time</code> to Octopus together, so a bad value in either one stops both. The other commands in the same message still apply.</p>
161
189
 
162
190
  <h4>3. Home Assistant MQTT Integration</h4>
163
- <p>Automatically create Home Assistant entities via MQTT discovery:</p>
164
- <pre>[{"id":"1","type":"inject","name":"Every 5 min","props":[{"p":"payload"}],"repeat":"300","crontab":"","once":true,"topic":"","payload":"","payloadType":"date","x":130,"y":200,"wires":[["2"]]},{"id":"2","type":"octopus-intelligent","name":"Octopus Intelligent","account":"A-XXXXXXXX","apiKey":"sk_live_...","refreshInterval":"5","enableMqtt":true,"mqttBroker":"mqtt-broker","x":340,"y":200,"wires":[["3"]]},{"id":"3","type":"debug","name":"Debug Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":570,"y":200,"wires":[]},{"id":"mqtt-broker","type":"mqtt-broker","name":"Home Assistant MQTT","broker":"localhost","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]</pre>
191
+ <p>The node creates Home Assistant entities through MQTT discovery. It ignores retained messages on the command topics that change Octopus settings or start a poll (<code>submit_changes</code>, <code>refresh</code>, <code>set_smart_charging</code>, <code>set_charge_cap</code>, and <code>set_boost</code>), because the broker would replay them on every restart. It logs one warning per topic.</p>
192
+ <pre>[{"id":"2","type":"octopus-intelligent","name":"Octopus Intelligent","accountNumber":"A-XXXXXXXX","refreshInterval":"5","enableMqtt":true,"broker":"mqtt-broker","x":340,"y":200,"wires":[["3"]]},{"id":"3","type":"debug","name":"Debug Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":570,"y":200,"wires":[]},{"id":"mqtt-broker","type":"mqtt-broker","name":"Home Assistant MQTT","broker":"localhost","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]</pre>
193
+ <p>Enter your API key in the node editor after you import the flow.</p>
165
194
 
166
195
  <h3>Visual Examples</h3>
167
196
  <p><strong>Node-RED Flow Examples:</strong></p>
168
197
  <img src="https://raw.githubusercontent.com/ASomerN/node-red-contrib-octopus-intelligent/master/images/examples/basic-monitoring-flow.png" alt="Node-RED Flow Examples" style="max-width: 100%; border: 1px solid #ddd; border-radius: 4px;">
169
- <p style="margin-top: 8px;"><em>Reads by default, manually refreshable from a button, pass in commands to change charge time and percentage</em></p>
198
+ <p style="margin-top: 8px;"><em>The node polls on its own, refreshes from a button, and takes commands to change the charge target and ready-by time</em></p>
170
199
 
171
200
  <p style="margin-top: 16px;"><strong>MQTT Integration:</strong></p>
172
201
  <img src="https://raw.githubusercontent.com/ASomerN/node-red-contrib-octopus-intelligent/master/images/examples/mqtt-integration-flow.png" alt="MQTT Integration Flow" style="max-width: 100%; border: 1px solid #ddd; border-radius: 4px;">
173
- <p style="margin-top: 8px;"><em>Complete MQTT integration with Home Assistant</em></p>
202
+ <p style="margin-top: 8px;"><em>MQTT integration with Home Assistant</em></p>
174
203
 
175
204
  <p style="margin-top: 16px;"><strong>Home Assistant Device:</strong></p>
176
205
  <img src="https://raw.githubusercontent.com/ASomerN/node-red-contrib-octopus-intelligent/master/images/examples/homeassistant-device.png" alt="Home Assistant Device" style="max-width: 100%; border: 1px solid #ddd; border-radius: 4px;">
177
- <p style="margin-top: 8px;"><em>Octopus Intelligent device with all controls and sensors automatically configured</em></p>
206
+ <p style="margin-top: 8px;"><em>The Octopus Intelligent device, with its controls and sensors set up by MQTT discovery</em></p>
178
207
 
179
208
  <h3>Output Format</h3>
180
- <p>The node outputs a message with the following structure:</p>
209
+ <p>This is a short extract of the output message. The full payload has more than 150 fields, listed in the README.</p>
181
210
  <pre>{
182
211
  "payload": {
183
- "next_start": "2025-11-29T01:30:00Z",
212
+ "next_start": "2025-11-29 01:30:00+00:00",
184
213
  "total_energy": 42.5,
185
214
  "next_kwh": "15.20",
186
215
  "next_source": "smart-charge",
@@ -188,28 +217,39 @@
188
217
  "confirmed_time": "07:00",
189
218
  "charging_now": false,
190
219
  "charge_cap": false,
191
- "slot1_start": "2025-11-29T01:30:00Z",
192
- "slot1_end": "2025-11-29T05:30:00Z"
193
- },
194
- "debug": {
195
- "success": true,
196
- "step": "complete",
197
- "apiCalls": [...]
220
+ "boosting": false,
221
+ "boost_error": null,
222
+ "slot1_start": "2025-11-29 01:30:00+00:00",
223
+ "slot1_end": "2025-11-29 05:30:00+00:00"
198
224
  }
199
225
  }</pre>
226
+ <p>Time fields use the node timezone. Fields ending in <code>_raw</code> keep the original UTC string from Octopus.</p>
227
+ <p>Poll messages carry only <code>msg.payload</code>. Check the <code>*_error</code> fields, the node status, and the Node-RED log if data looks wrong. When <code>charging_now</code> changes, the node also sends a <code>msg.debug</code> object with <code>timestamp</code>, <code>trigger</code>, <code>previous_state</code>, and <code>new_state</code>. When a saving session, free electricity window or rate slot starts or ends, it sends a message whose <code>msg.debug</code> has <code>trigger: "active_fields_change"</code> and the <code>changed</code> fields. When a <code>set_boost</code> request fails, it sends a message whose <code>msg.debug</code> has <code>trigger: "boost_failed"</code>, <code>request</code> and <code>error</code>.</p>
200
228
 
201
- <h3>Home Assistant Integration</h3>
202
- <p>When MQTT is enabled, the node automatically creates:</p>
229
+ <h3>Errors and Retries</h3>
230
+ <p>Every request to Octopus gives up after 30 seconds with no answer.</p>
231
+ <p>When the charging poll fails, the node keeps the known plan. If Octopus can't return the charging plan (<code>KT-CT-4340</code>) or the charging preferences (<code>KT-CT-4339</code>), the node tries again after 30 seconds, 1 minute, and 2 minutes, then every 2 minutes, until it works or the next normal poll is due. Other errors wait for the next normal poll. <code>intelligent_error</code> and the node status show a short error with the Octopus code, for example <code>KT-CT-4340: Unable to fetch planned dispatches</code>. The Node-RED log shows a warning for each failed attempt and one line when it works again.</p>
232
+ <p>If only the charging preferences fail (<code>KT-CT-4339</code>), the poll still works and keeps the last confirmed target and ready-by time.</p>
233
+
234
+ <h3>SmartFlex Vehicle and Inverter</h3>
235
+ <p>If Octopus controls your car or charge point, the node adds its details to <code>msg.payload</code> every 30 minutes. You do not need to turn this on.</p>
203
236
  <ul>
204
- <li><strong>Controls:</strong> Target charge slider, ready time selector, apply changes button, Charge Cap switch</li>
205
- <li><strong>Sensors:</strong> Next charge time, total energy, charging status, individual slots</li>
206
- <li><strong>Binary Sensor:</strong> Charging now indicator (ON/OFF)</li>
237
+ <li><code>vehicle_make</code>, <code>vehicle_model</code>, <code>vehicle_battery_kwh</code>, <code>charger_power_kw</code></li>
238
+ <li><code>device_state</code>: what Octopus says the device is doing, for example <code>SMART_CONTROL_IN_PROGRESS</code>, <code>BOOSTING</code>, or <code>LOST_CONNECTION</code>. The charging poll reads it for a car or a charge point, so it updates every refresh interval.</li>
239
+ <li><code>device_alerts</code>: Octopus alert messages for the device, as a list of <code>{ message, published_at }</code>. The node keeps the 10 newest, newest first, and cuts each message to 250 characters.</li>
240
+ <li><code>charging_sessions</code>: your last 5 charging sessions, newest first. Each has <code>start</code>, <code>end</code>, <code>kwh_added</code>, <code>soc_change</code>, <code>soc_final</code>, <code>type</code>, <code>cost</code>, and <code>problems</code>. <code>last_session</code> is the latest finished one.</li>
241
+ <li><code>last_session_kwh</code>, <code>last_session_soc_final</code>, <code>last_session_problem</code>: the latest finished session, as single values.</li>
242
+ <li><code>smartflex_vehicle_error</code>: the last error, or <code>null</code>.</li>
207
243
  </ul>
208
- <p>All entities appear under a single "Octopus Intelligent" device in Home Assistant.</p>
244
+ <p><strong>Inverter (experimental).</strong> This is not yet verified on a real inverter. Tick <strong>Inverter</strong> to read solar, home battery, grid, and site power every 5 minutes. It only runs if Octopus lists a SmartFlex inverter on your account. Fields: <code>inverter_make</code>, <code>inverter_model</code>, <code>solar_peak_kw</code>, <code>inverter_power_kw</code>, <code>inverter_connection_status</code>, <code>inverter_online</code>, <code>home_battery_power_kw</code>, <code>home_battery_soc</code>, <code>solar_power_kw</code>, <code>grid_power_kw</code>, <code>site_consumption_kw</code>, <code>site_export_kw</code>, and <code>smartflex_inverter_error</code>. If the values look wrong, please open an issue.</p>
245
+ <p>With MQTT on, Home Assistant also gets matching sensors on the same Octopus Intelligent device. The session list and alerts are attributes of the Last Charge Session Energy sensor. The inverter entities appear only while the Inverter option is ticked. Unticking it removes them.</p>
246
+
247
+ <h3>Home Assistant Integration</h3>
248
+ <p>When MQTT is on, the node publishes the charging controls (including the Boost Charge switch when Octopus lists a car or charger it controls), sensors, rates, consumption, rewards, a Refresh button, an Update entity, and error state binary sensors. All entities appear under one "Octopus Intelligent" device. See the README for the full list.</p>
209
249
 
210
250
  <h3>Requirements</h3>
211
251
  <ul>
212
- <li>Octopus Energy account with Intelligent Octopus Go tariff</li>
252
+ <li>Octopus Energy account. EV charging features need the Intelligent Octopus Go tariff.</li>
213
253
  <li>API key from <a href="https://octopus.energy/dashboard/new/accounts/personal-details/api-access" target="_blank">Octopus dashboard</a></li>
214
254
  <li>MQTT broker (optional, for Home Assistant integration)</li>
215
255
  </ul>