node-red-contrib-octopus-intelligent 1.5.0 → 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.
- package/CHANGELOG.md +597 -442
- package/README.md +1234 -980
- package/examples/basic-monitoring.json +1 -1
- package/examples/boost-on-cheap-or-surplus.json +171 -0
- package/examples/charging-and-error-alerts.json +95 -0
- package/examples/cheapest-window-planner.json +165 -0
- package/examples/daily-charging-summary.json +165 -0
- package/examples/ha-dashboard.yaml +667 -599
- package/examples/mqtt-integration.json +1 -1
- package/examples/node-red-dashboard-flow.json +1377 -1199
- package/examples/set-preferences.json +1 -1
- package/lib/active-now.js +33 -0
- package/lib/api-metrics.js +31 -31
- package/lib/auth.js +25 -20
- package/lib/boost.js +85 -0
- package/lib/categories/account.js +32 -32
- package/lib/categories/applicable-rates.js +137 -127
- package/lib/categories/completed-dispatches.js +36 -35
- package/lib/categories/electricity.js +156 -146
- package/lib/categories/flex-planned-dispatches.js +36 -36
- package/lib/categories/free-electricity.js +73 -61
- package/lib/categories/gas.js +102 -95
- package/lib/categories/home-mini.js +45 -37
- package/lib/categories/intelligent.js +221 -124
- package/lib/categories/octoplus.js +35 -32
- package/lib/categories/saving-sessions.js +78 -64
- package/lib/categories/smartflex-inverter.js +95 -0
- package/lib/categories/smartflex-vehicle.js +198 -0
- package/lib/categories/wheel-of-fortune.js +50 -49
- package/lib/commands.js +69 -0
- package/lib/discovery-retry.js +16 -0
- package/lib/discovery.js +154 -85
- package/lib/graphql-errors.js +174 -0
- package/lib/graphql.js +141 -44
- package/lib/http-get-json.js +80 -22
- package/lib/payload.js +104 -88
- package/lib/poll-retry.js +71 -0
- package/lib/poll-tick.js +112 -44
- package/lib/preferences.js +34 -0
- package/lib/scheduler.js +85 -47
- package/lib/sensor-definitions.js +269 -0
- package/lib/timezone.js +67 -49
- package/lib/update-check.js +38 -38
- package/lib/values.js +47 -0
- package/octopus-intelligent.html +258 -205
- package/octopus-intelligent.js +2816 -1807
- package/package.json +54 -54
package/lib/poll-tick.js
CHANGED
|
@@ -1,44 +1,112 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { graphqlError, truncate, isNetworkError } = require('./graphql-errors');
|
|
4
|
+
|
|
5
|
+
// Every <category>_error is short text ("KT-CT-1111: Unauthorized" or the plain message),
|
|
6
|
+
// never the raw Kraken errors JSON, and under 255 characters: Home Assistant rejects a
|
|
7
|
+
// longer state.
|
|
8
|
+
function simplePoll(queryFn, parseFn, graphqlPost) {
|
|
9
|
+
return async function poll(token) {
|
|
10
|
+
const { query, variables, hostname } = queryFn();
|
|
11
|
+
const response = await graphqlPost({ query, variables }, token, hostname);
|
|
12
|
+
if (response.data.errors) throw graphqlError(response.data.errors);
|
|
13
|
+
if (!response.data.data) throw new Error('Response missing data');
|
|
14
|
+
return parseFn(response.data.data);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { isDue } = require('./scheduler');
|
|
19
|
+
const { mergePayload } = require('./payload');
|
|
20
|
+
|
|
21
|
+
// A category's error goes to <id>_error and, when the category sets errorField, to that field
|
|
22
|
+
// too (the export rates poll feeds the Electricity Export Rate Error sensors this way).
|
|
23
|
+
function errorUpdate(cat, value) {
|
|
24
|
+
const update = { [`${cat.id}_error`]: value };
|
|
25
|
+
if (cat.errorField) update[cat.errorField] = value;
|
|
26
|
+
return update;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Mark a category polled, unless it was forced due (forceCategoryDue bumps forceSeq) after
|
|
30
|
+
// `seq` was read: then it stays due, so the forced poll isn't lost behind one in flight.
|
|
31
|
+
function markPolled(cat, seq, at) {
|
|
32
|
+
cat.lastPolled = (cat.forceSeq || 0) !== seq ? 0 : at;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// After a failed token request a category is retried after 60 s, then 2, 4, 8 and at most
|
|
36
|
+
// 10 minutes while auth keeps failing, rather than waiting a whole interval (up to an hour)
|
|
37
|
+
// or trying again every second. Its normal slot still applies if that comes sooner.
|
|
38
|
+
const AUTH_RETRY_BASE_MS = 60000;
|
|
39
|
+
const AUTH_RETRY_MAX_MS = 600000;
|
|
40
|
+
|
|
41
|
+
function authRetryDelay(failures) {
|
|
42
|
+
return Math.min(AUTH_RETRY_BASE_MS * 2 ** (Math.max(failures, 1) - 1), AUTH_RETRY_MAX_MS);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// update_check reads npm, not Octopus: it sets needsToken: false.
|
|
46
|
+
const needsToken = (cat) => cat.needsToken !== false;
|
|
47
|
+
|
|
48
|
+
async function runTick({ categories, state, getToken, now = Date.now, isStale }) {
|
|
49
|
+
const due = categories.filter((c) => c.enabled && isDue(c));
|
|
50
|
+
if (due.length === 0) return { state, changes: {}, emitted: false };
|
|
51
|
+
// `changes` holds only what this tick wrote, so the caller can apply it onto its current
|
|
52
|
+
// state: anything written there while the tick waited on Octopus is kept.
|
|
53
|
+
let newState = state;
|
|
54
|
+
let changes = {};
|
|
55
|
+
const apply = (partial) => {
|
|
56
|
+
newState = mergePayload(newState, partial);
|
|
57
|
+
changes = mergePayload(changes, partial);
|
|
58
|
+
};
|
|
59
|
+
let toPoll = due;
|
|
60
|
+
let token;
|
|
61
|
+
if (due.some(needsToken)) {
|
|
62
|
+
const seqAtAuth = due.map((c) => c.forceSeq || 0);
|
|
63
|
+
try {
|
|
64
|
+
token = await getToken();
|
|
65
|
+
} catch (e) {
|
|
66
|
+
const text = truncate(`Auth failed: ${e.message}`);
|
|
67
|
+
due.forEach((cat, i) => {
|
|
68
|
+
if (!needsToken(cat)) return;
|
|
69
|
+
apply(errorUpdate(cat, text));
|
|
70
|
+
markPolled(cat, seqAtAuth[i], now());
|
|
71
|
+
cat.authFailures = (cat.authFailures || 0) + 1;
|
|
72
|
+
// A rate-limited token request (429 with Retry-After) waits at least that long.
|
|
73
|
+
const wait = Number.isFinite(e && e.retryAfterMs) ? Math.min(e.retryAfterMs, AUTH_RETRY_MAX_MS) : 0;
|
|
74
|
+
cat.authRetryAt = now() + Math.max(authRetryDelay(cat.authFailures), wait);
|
|
75
|
+
});
|
|
76
|
+
// Categories that need no token still run.
|
|
77
|
+
toPoll = due.filter((cat) => !needsToken(cat));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Set after the first time-out, dropped connection or HTTP 5xx from Octopus. The other
|
|
81
|
+
// Octopus categories are then left due for the next tick rather than each waiting up to
|
|
82
|
+
// 30 s here, so an outage can't make one tick run for 10 minutes.
|
|
83
|
+
let octopusDown = false;
|
|
84
|
+
// Marked polled only when the tick ends current: a tick replaced by a newer one (the
|
|
85
|
+
// watchdog in lib/scheduler.js) has its results dropped by the caller, so what it polled
|
|
86
|
+
// must stay due for the newer tick.
|
|
87
|
+
const polled = [];
|
|
88
|
+
for (const cat of toPoll) {
|
|
89
|
+
// A newer tick has taken over: stop here so categories aren't polled twice.
|
|
90
|
+
if (isStale && isStale()) break;
|
|
91
|
+
if (octopusDown && needsToken(cat)) continue;
|
|
92
|
+
const seq = cat.forceSeq || 0;
|
|
93
|
+
// Auth worked (or isn't needed): back to the normal interval.
|
|
94
|
+
cat.authFailures = 0;
|
|
95
|
+
cat.authRetryAt = null;
|
|
96
|
+
try {
|
|
97
|
+
const partial = await (isStale ? cat.poll(token, isStale) : cat.poll(token));
|
|
98
|
+
apply(partial);
|
|
99
|
+
// A poll that kept part of its data can report what failed in <id>_error.
|
|
100
|
+
const ownError = partial && partial[`${cat.id}_error`];
|
|
101
|
+
apply(errorUpdate(cat, ownError ? truncate(ownError) : null));
|
|
102
|
+
} catch (e) {
|
|
103
|
+
apply(errorUpdate(cat, truncate(e.message)));
|
|
104
|
+
if (needsToken(cat) && isNetworkError(e)) octopusDown = true;
|
|
105
|
+
}
|
|
106
|
+
polled.push({ cat, seq, at: now() });
|
|
107
|
+
}
|
|
108
|
+
if (!(isStale && isStale())) polled.forEach(({ cat, seq, at }) => markPolled(cat, seq, at));
|
|
109
|
+
return { state: newState, changes, emitted: true };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
module.exports = { simplePoll, runTick, AUTH_RETRY_BASE_MS, AUTH_RETRY_MAX_MS };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const { shown } = require('./values');
|
|
3
|
+
|
|
4
|
+
// Ready-by times offered by the Octopus app: every half hour, 00:00–23:30.
|
|
5
|
+
const TIME_OPTIONS = Array.from({ length: 48 }, (_, i) => {
|
|
6
|
+
const h = String(Math.floor(i / 2)).padStart(2, '0');
|
|
7
|
+
return `${h}:${i % 2 ? '30' : '00'}`;
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
function validateTime(time) {
|
|
11
|
+
if (typeof time === 'string' && TIME_OPTIONS.includes(time)) {
|
|
12
|
+
return { ok: true, time };
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
ok: false,
|
|
16
|
+
// shown(): at most 40 characters of the value, and no throw for a Symbol or a bare object
|
|
17
|
+
error: `Invalid ready-by time '${shown(time)}' — must be HH:MM on the hour or half hour (00:00–23:30)`,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function validateLimit(limit) {
|
|
22
|
+
// Plain decimal numbers or numeric strings only: no truncating '8O' to 8 (parseInt) and no
|
|
23
|
+
// coercing true/[90]/'0x5A'/'1e2' (Number). 0 is never a meaningful target.
|
|
24
|
+
let n = NaN;
|
|
25
|
+
if (typeof limit === 'number') n = limit;
|
|
26
|
+
else if (typeof limit === 'string' && /^\s*\d+(\.\d+)?\s*$/.test(limit)) n = Number(limit);
|
|
27
|
+
if (!Number.isFinite(n) || n <= 0) {
|
|
28
|
+
return { ok: false, error: `Invalid charge limit '${shown(limit)}' — must be a number between 5 and 100` };
|
|
29
|
+
}
|
|
30
|
+
const clamped = Math.min(100, Math.max(5, n));
|
|
31
|
+
return { ok: true, limit: Math.round(clamped / 5) * 5 };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = { TIME_OPTIONS, validateTime, validateLimit };
|
package/lib/scheduler.js
CHANGED
|
@@ -1,47 +1,85 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// A tick running longer than this is treated as stuck: later ticks may run again.
|
|
4
|
+
// A busy tick can make about 17 requests, each allowed 30 s, so stay well above that.
|
|
5
|
+
const STUCK_TICK_MS = 10 * 60 * 1000;
|
|
6
|
+
|
|
7
|
+
// Monotonic clock: a wall-clock jump (e.g. NTP on a Pi) must not look like a stuck tick.
|
|
8
|
+
// `performance` is only a global from Node 16; package.json allows Node 14, so fall back
|
|
9
|
+
// to perf_hooks. Looked up on each call so test fake timers still apply.
|
|
10
|
+
const { performance: perfHooksPerformance } = require('perf_hooks');
|
|
11
|
+
const monotonicNow = () => (typeof performance !== 'undefined' ? performance : perfHooksPerformance).now();
|
|
12
|
+
|
|
13
|
+
// A backward wall-clock step of at least this much re-polls what was polled "in the future".
|
|
14
|
+
// A smaller step (an NTP correction of a second or two) only moves lastPolled back to now.
|
|
15
|
+
const { CLOCK_STEP_BACK_MS } = require('./poll-retry');
|
|
16
|
+
|
|
17
|
+
function isDue(cat) {
|
|
18
|
+
if (!cat.enabled) return false;
|
|
19
|
+
if (cat.lastPolled === 0) return true;
|
|
20
|
+
// Polled "in the future": the wall clock has stepped back. After a large step, poll now
|
|
21
|
+
// rather than wait for the clock to catch up. After a small one, treat it as polled now,
|
|
22
|
+
// so a correction of a second or two does not re-poll every category.
|
|
23
|
+
const nowMs = Date.now();
|
|
24
|
+
if (cat.lastPolled > nowMs) {
|
|
25
|
+
if (cat.lastPolled - nowMs >= CLOCK_STEP_BACK_MS) return true;
|
|
26
|
+
cat.lastPolled = nowMs;
|
|
27
|
+
}
|
|
28
|
+
// A short retry after a failed token request (lib/poll-tick.js).
|
|
29
|
+
if (cat.authRetryAt && Date.now() >= cat.authRetryAt) return true;
|
|
30
|
+
const slot = ts => Math.floor(ts / cat.intervalMs);
|
|
31
|
+
return slot(Date.now()) > slot(cat.lastPolled);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function alignedStart(nowMs) {
|
|
35
|
+
const ms = nowMs % 1000;
|
|
36
|
+
return ms === 0 ? 1000 : 1000 - ms;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function wrapWithInFlightGuard(fn, { maxMs = STUCK_TICK_MS, onStuck } = {}) {
|
|
40
|
+
let inFlight = false;
|
|
41
|
+
let startedAt = 0;
|
|
42
|
+
let run = 0;
|
|
43
|
+
return async function guarded(...args) {
|
|
44
|
+
if (inFlight) {
|
|
45
|
+
const age = monotonicNow() - startedAt;
|
|
46
|
+
if (age < maxMs) return;
|
|
47
|
+
if (onStuck) onStuck(age);
|
|
48
|
+
}
|
|
49
|
+
const id = ++run;
|
|
50
|
+
inFlight = true;
|
|
51
|
+
startedAt = monotonicNow();
|
|
52
|
+
// The tick can ask whether a newer tick has replaced it, and stop.
|
|
53
|
+
const isStale = () => id !== run;
|
|
54
|
+
try {
|
|
55
|
+
return await fn(...args, isStale);
|
|
56
|
+
} finally {
|
|
57
|
+
// Only the newest tick may clear the flag; a stuck tick that ends late must not.
|
|
58
|
+
if (id === run) inFlight = false;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function createScheduler(onTick, { onStuck } = {}) {
|
|
64
|
+
const guarded = wrapWithInFlightGuard(onTick, { onStuck });
|
|
65
|
+
let startTimer = null;
|
|
66
|
+
let handle = null;
|
|
67
|
+
|
|
68
|
+
function start() {
|
|
69
|
+
const delay = alignedStart(Date.now());
|
|
70
|
+
startTimer = setTimeout(() => {
|
|
71
|
+
startTimer = null;
|
|
72
|
+
guarded();
|
|
73
|
+
handle = setInterval(guarded, 1000);
|
|
74
|
+
}, delay);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function stop() {
|
|
78
|
+
if (startTimer) { clearTimeout(startTimer); startTimer = null; }
|
|
79
|
+
if (handle) { clearInterval(handle); handle = null; }
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return { start, stop };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
module.exports = { isDue, alignedStart, createScheduler, wrapWithInFlightGuard, STUCK_TICK_MS, CLOCK_STEP_BACK_MS };
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Sensor Definitions (Read-Only)
|
|
4
|
+
// category: undefined = main, 'config' = Configuration, 'diagnostic' = Diagnostics
|
|
5
|
+
//
|
|
6
|
+
// NOTE: entries here must never carry category: 'config' — that HA entity_category
|
|
7
|
+
// means "user-configurable setting", and every sensor below is a read-only value
|
|
8
|
+
// reported from the Kraken API. Writable command entities (timezone select,
|
|
9
|
+
// smart-charging switch) are defined separately in octopus-intelligent.js, not here.
|
|
10
|
+
// Getting this wrong sticks the entity at "unavailable" on some HA Core versions and
|
|
11
|
+
// outright blocks registration on newer ones. Fixed for tariff codes in v1.3.0, for
|
|
12
|
+
// Octoplus binary sensors shortly after, and for the day/night/EV rate-band sensors
|
|
13
|
+
// below in v1.6.1.
|
|
14
|
+
const sensors = [
|
|
15
|
+
// --- EV Charging (main) ---
|
|
16
|
+
{ id: 'next_charge', name: 'Next Charge Time', class: 'timestamp', icon: 'mdi:timer', val: 'next_start' },
|
|
17
|
+
{ id: 'total_energy', name: 'Total Planned Energy', unit: 'kWh', class: 'energy', val: 'total_energy' },
|
|
18
|
+
{ id: 'next_kwh', name: 'Next Slot Energy', unit: 'kWh', class: 'energy', val: 'next_kwh' },
|
|
19
|
+
{ id: 'source', name: 'Charge Source', icon: 'mdi:help-circle', val: 'next_source' },
|
|
20
|
+
{ id: 'slot1_start', name: 'Slot 1 Start', class: 'timestamp', icon: 'mdi:timer-outline', val: 'slot1_start' },
|
|
21
|
+
{ id: 'slot1_end', name: 'Slot 1 End', class: 'timestamp', icon: 'mdi:timer-outline', val: 'slot1_end' },
|
|
22
|
+
{ id: 'slot2_start', name: 'Slot 2 Start', class: 'timestamp', icon: 'mdi:timer-outline', val: 'slot2_start' },
|
|
23
|
+
{ id: 'slot2_end', name: 'Slot 2 End', class: 'timestamp', icon: 'mdi:timer-outline', val: 'slot2_end' },
|
|
24
|
+
{ id: 'slot3_start', name: 'Slot 3 Start', class: 'timestamp', icon: 'mdi:timer-outline', val: 'slot3_start' },
|
|
25
|
+
{ id: 'slot3_end', name: 'Slot 3 End', class: 'timestamp', icon: 'mdi:timer-outline', val: 'slot3_end' },
|
|
26
|
+
{ id: 'window_start', name: 'Overall Window Start', class: 'timestamp', icon: 'mdi:timer-play', val: 'window_start' },
|
|
27
|
+
{ id: 'window_end', name: 'Overall Window End', class: 'timestamp', icon: 'mdi:timer-stop', val: 'window_end' },
|
|
28
|
+
|
|
29
|
+
// --- EV Charging (diagnostic) ---
|
|
30
|
+
{ id: 'next_poll', name: 'Next Poll Time', class: 'timestamp', icon: 'mdi:clock-outline', val: 'next_poll', category: 'diagnostic' },
|
|
31
|
+
{ id: 'refresh_available_at', name: 'Refresh Available At', class: 'timestamp', icon: 'mdi:timer-sand', val: 'refresh_available_at', category: 'diagnostic' },
|
|
32
|
+
{ id: 'api_requests_hour', name: 'API Requests (Last Hour)', icon: 'mdi:api', val: 'api_requests_hour', category: 'diagnostic' },
|
|
33
|
+
{ id: 'api_complexity_hour', name: 'API Complexity (Last Hour)', icon: 'mdi:chart-line', val: 'api_complexity_hour', category: 'diagnostic' },
|
|
34
|
+
{ id: 'api_complexity_percent', name: 'API Complexity Usage', unit: '%', icon: 'mdi:percent', val: 'api_complexity_percent', category: 'diagnostic' },
|
|
35
|
+
|
|
36
|
+
// --- Raw timestamps (diagnostic) ---
|
|
37
|
+
{ id: 'next_charge_raw', name: 'Next Charge Time (Raw)', icon: 'mdi:timer', val: 'next_start_raw', category: 'diagnostic' },
|
|
38
|
+
{ id: 'next_poll_raw', name: 'Next Poll Time (Raw)', icon: 'mdi:clock-outline', val: 'next_poll_raw', category: 'diagnostic' },
|
|
39
|
+
{ id: 'slot1_start_raw', name: 'Slot 1 Start (Raw)', icon: 'mdi:timer-outline', val: 'slot1_start_raw', category: 'diagnostic' },
|
|
40
|
+
{ id: 'slot1_end_raw', name: 'Slot 1 End (Raw)', icon: 'mdi:timer-outline', val: 'slot1_end_raw', category: 'diagnostic' },
|
|
41
|
+
{ id: 'slot2_start_raw', name: 'Slot 2 Start (Raw)', icon: 'mdi:timer-outline', val: 'slot2_start_raw', category: 'diagnostic' },
|
|
42
|
+
{ id: 'slot2_end_raw', name: 'Slot 2 End (Raw)', icon: 'mdi:timer-outline', val: 'slot2_end_raw', category: 'diagnostic' },
|
|
43
|
+
{ id: 'slot3_start_raw', name: 'Slot 3 Start (Raw)', icon: 'mdi:timer-outline', val: 'slot3_start_raw', category: 'diagnostic' },
|
|
44
|
+
{ id: 'slot3_end_raw', name: 'Slot 3 End (Raw)', icon: 'mdi:timer-outline', val: 'slot3_end_raw', category: 'diagnostic' },
|
|
45
|
+
{ id: 'window_start_raw', name: 'Overall Window Start (Raw)', icon: 'mdi:timer-play', val: 'window_start_raw', category: 'diagnostic' },
|
|
46
|
+
{ id: 'window_end_raw', name: 'Overall Window End (Raw)', icon: 'mdi:timer-stop', val: 'window_end_raw', category: 'diagnostic' },
|
|
47
|
+
|
|
48
|
+
// --- Locale timestamps (diagnostic) ---
|
|
49
|
+
{ id: 'next_charge_locale', name: 'Next Charge Time (Locale)', icon: 'mdi:timer', val: 'next_start_locale', category: 'diagnostic' },
|
|
50
|
+
{ id: 'slot1_start_locale', name: 'Slot 1 Start (Locale)', icon: 'mdi:timer-outline', val: 'slot1_start_locale', category: 'diagnostic' },
|
|
51
|
+
{ id: 'slot1_end_locale', name: 'Slot 1 End (Locale)', icon: 'mdi:timer-outline', val: 'slot1_end_locale', category: 'diagnostic' },
|
|
52
|
+
{ id: 'slot2_start_locale', name: 'Slot 2 Start (Locale)', icon: 'mdi:timer-outline', val: 'slot2_start_locale', category: 'diagnostic' },
|
|
53
|
+
{ id: 'slot2_end_locale', name: 'Slot 2 End (Locale)', icon: 'mdi:timer-outline', val: 'slot2_end_locale', category: 'diagnostic' },
|
|
54
|
+
{ id: 'slot3_start_locale', name: 'Slot 3 Start (Locale)', icon: 'mdi:timer-outline', val: 'slot3_start_locale', category: 'diagnostic' },
|
|
55
|
+
{ id: 'slot3_end_locale', name: 'Slot 3 End (Locale)', icon: 'mdi:timer-outline', val: 'slot3_end_locale', category: 'diagnostic' },
|
|
56
|
+
{ id: 'window_start_locale', name: 'Overall Window Start (Locale)', icon: 'mdi:timer-play', val: 'window_start_locale', category: 'diagnostic' },
|
|
57
|
+
{ id: 'window_end_locale', name: 'Overall Window End (Locale)', icon: 'mdi:timer-stop', val: 'window_end_locale', category: 'diagnostic' },
|
|
58
|
+
{ id: 'timezone_detected', name: 'Timezone Detected', icon: 'mdi:earth', val: 'timezone_detected', category: 'diagnostic' },
|
|
59
|
+
{ id: 'timezone_applied', name: 'Timezone Applied', icon: 'mdi:earth-plus', val: 'timezone_applied', category: 'diagnostic' },
|
|
60
|
+
// --- Electricity (main) ---
|
|
61
|
+
{ id: 'electricity_standing_charge', name: 'Electricity Standing Charge', unit: 'p/day', icon: 'mdi:cash', val: 'electricity_standing_charge' },
|
|
62
|
+
{ id: 'electricity_consumption_kwh', name: 'Electricity Consumption', unit: 'kWh', class: 'energy', val: 'electricity_consumption_kwh' },
|
|
63
|
+
// --- Electricity (main) ---
|
|
64
|
+
{ id: 'electricity_unit_rate', name: 'Electricity Unit Rate', unit: 'p/kWh', icon: 'mdi:flash', val: 'electricity_unit_rate' },
|
|
65
|
+
{ id: 'electricity_day_rate', name: 'Electricity Day Rate', unit: 'p/kWh', icon: 'mdi:weather-sunny', val: 'electricity_day_rate' },
|
|
66
|
+
{ id: 'electricity_night_rate', name: 'Electricity Night Rate', unit: 'p/kWh', icon: 'mdi:weather-night', val: 'electricity_night_rate' },
|
|
67
|
+
{ id: 'electricity_ev_peak_rate', name: 'Electricity EV Peak Rate', unit: 'p/kWh', icon: 'mdi:car-electric-outline', val: 'electricity_ev_peak_rate' },
|
|
68
|
+
{ id: 'electricity_ev_off_peak_rate', name: 'Electricity EV Off-Peak Rate', unit: 'p/kWh', icon: 'mdi:car-electric', val: 'electricity_ev_off_peak_rate' },
|
|
69
|
+
{ id: 'electricity_tariff_code', name: 'Electricity Tariff Code', icon: 'mdi:tag', val: 'electricity_tariff_code' },
|
|
70
|
+
{ id: 'electricity_valid_from', name: 'Electricity Tariff Valid From', class: 'timestamp', icon: 'mdi:calendar-start', val: 'electricity_valid_from' },
|
|
71
|
+
{ id: 'electricity_valid_to', name: 'Electricity Tariff Valid To', class: 'timestamp', icon: 'mdi:calendar-end', val: 'electricity_valid_to' },
|
|
72
|
+
// --- Electricity (diagnostic) ---
|
|
73
|
+
{ id: 'electricity_consumption_from', name: 'Electricity Consumption From', class: 'timestamp', icon: 'mdi:calendar-clock', val: 'electricity_consumption_from', category: 'diagnostic' },
|
|
74
|
+
{ id: 'electricity_consumption_to', name: 'Electricity Consumption To', class: 'timestamp', icon: 'mdi:calendar-clock', val: 'electricity_consumption_to', category: 'diagnostic' },
|
|
75
|
+
{ id: 'electricity_rates_error', name: 'Electricity Rates Error', icon: 'mdi:alert-circle', val: 'electricity_rates_error', category: 'diagnostic' },
|
|
76
|
+
{ id: 'electricity_consumption_error', name: 'Electricity Consumption Error', icon: 'mdi:alert-circle', val: 'electricity_consumption_error', category: 'diagnostic' },
|
|
77
|
+
|
|
78
|
+
// --- Electricity Export (main) ---
|
|
79
|
+
{ id: 'electricity_export_consumption_kwh', name: 'Electricity Export Consumption', unit: 'kWh', class: 'energy', val: 'electricity_export_consumption_kwh' },
|
|
80
|
+
{ id: 'electricity_export_rate_current_pence', name: 'Current Electricity Export Rate', unit: 'p/kWh', icon: 'mdi:cash-clock', val: 'electricity_export_rate_current_pence' },
|
|
81
|
+
{ id: 'electricity_export_rate_current_gbp', name: 'Electricity Export Rate', unit: 'GBP/kWh', icon: 'mdi:cash-clock', stateClass: 'measurement', val: 'electricity_export_rate_current_gbp' },
|
|
82
|
+
// --- Electricity Export (main) ---
|
|
83
|
+
// Solar/export users have a second agreement with productCode containing "OUTGOING".
|
|
84
|
+
// unit_rate is null for half-hourly export tariffs (e.g. Agile Outgoing) — current
|
|
85
|
+
// half-hourly export rate comes from electricity_export_rate_current_pence.
|
|
86
|
+
{ id: 'electricity_export_unit_rate', name: 'Electricity Export Unit Rate', unit: 'p/kWh', icon: 'mdi:transmission-tower-export', val: 'electricity_export_unit_rate' },
|
|
87
|
+
{ id: 'electricity_export_standing_charge',name: 'Electricity Export Standing Charge',unit: 'p/day', icon: 'mdi:cash', val: 'electricity_export_standing_charge' },
|
|
88
|
+
{ id: 'electricity_export_tariff_code', name: 'Electricity Export Tariff Code', icon: 'mdi:tag', val: 'electricity_export_tariff_code' },
|
|
89
|
+
{ id: 'electricity_export_valid_from', name: 'Electricity Export Tariff Valid From', class: 'timestamp', icon: 'mdi:calendar-start', val: 'electricity_export_valid_from' },
|
|
90
|
+
{ id: 'electricity_export_valid_to', name: 'Electricity Export Tariff Valid To', class: 'timestamp', icon: 'mdi:calendar-end', val: 'electricity_export_valid_to' },
|
|
91
|
+
// --- Electricity Export (diagnostic) ---
|
|
92
|
+
{ id: 'electricity_export_consumption_from', name: 'Electricity Export Consumption From', class: 'timestamp', icon: 'mdi:calendar-clock', val: 'electricity_export_consumption_from', category: 'diagnostic' },
|
|
93
|
+
{ id: 'electricity_export_consumption_to', name: 'Electricity Export Consumption To', class: 'timestamp', icon: 'mdi:calendar-clock', val: 'electricity_export_consumption_to', category: 'diagnostic' },
|
|
94
|
+
{ id: 'electricity_export_rate_count', name: 'Electricity Export Rate Slots', icon: 'mdi:format-list-numbered', val: 'electricity_export_rate_count', category: 'diagnostic' },
|
|
95
|
+
{ id: 'electricity_export_rate_prev_pence', name: 'Electricity Export Rate Prev', unit: 'p/kWh', icon: 'mdi:cash-clock', val: 'electricity_export_rate_prev_pence', category: 'diagnostic' },
|
|
96
|
+
{ id: 'electricity_export_rate_prev_to', name: 'Electricity Export Rate Prev Ends', class: 'timestamp', icon: 'mdi:calendar-clock', val: 'electricity_export_rate_prev_to', category: 'diagnostic' },
|
|
97
|
+
{ id: 'electricity_export_rate_next_pence', name: 'Electricity Export Rate Next', unit: 'p/kWh', icon: 'mdi:cash-clock', val: 'electricity_export_rate_next_pence', category: 'diagnostic' },
|
|
98
|
+
{ id: 'electricity_export_rate_next_from', name: 'Electricity Export Rate Next From', class: 'timestamp', icon: 'mdi:calendar-clock', val: 'electricity_export_rate_next_from', category: 'diagnostic' },
|
|
99
|
+
{ id: 'electricity_export_rate_prev_gbp', name: 'Electricity Export Rate Prev (GBP)', unit: 'GBP/kWh', icon: 'mdi:cash-clock', val: 'electricity_export_rate_prev_gbp', stateClass: 'measurement', category: 'diagnostic' },
|
|
100
|
+
{ id: 'electricity_export_rate_next_gbp', name: 'Electricity Export Rate Next (GBP)', unit: 'GBP/kWh', icon: 'mdi:cash-clock', val: 'electricity_export_rate_next_gbp', stateClass: 'measurement', category: 'diagnostic' },
|
|
101
|
+
{ id: 'electricity_export_rate_error', name: 'Electricity Export Rate Error', icon: 'mdi:alert-circle', val: 'electricity_export_rate_error', category: 'diagnostic' },
|
|
102
|
+
|
|
103
|
+
// --- Gas (main) ---
|
|
104
|
+
{ id: 'gas_standing_charge', name: 'Gas Standing Charge', unit: 'p/day', icon: 'mdi:cash', val: 'gas_standing_charge' },
|
|
105
|
+
{ id: 'gas_consumption_kwh', name: 'Gas Consumption', unit: 'kWh', class: 'energy', val: 'gas_consumption_kwh' },
|
|
106
|
+
// --- Gas (main) ---
|
|
107
|
+
{ id: 'gas_unit_rate', name: 'Gas Unit Rate', unit: 'p/kWh', icon: 'mdi:fire', val: 'gas_unit_rate' },
|
|
108
|
+
{ id: 'gas_tariff_code', name: 'Gas Tariff Code', icon: 'mdi:tag', val: 'gas_tariff_code' },
|
|
109
|
+
{ id: 'gas_valid_from', name: 'Gas Tariff Valid From', class: 'timestamp', icon: 'mdi:calendar-start', val: 'gas_valid_from' },
|
|
110
|
+
{ id: 'gas_valid_to', name: 'Gas Tariff Valid To', class: 'timestamp', icon: 'mdi:calendar-end', val: 'gas_valid_to' },
|
|
111
|
+
// --- Gas (diagnostic) ---
|
|
112
|
+
{ id: 'gas_consumption_from', name: 'Gas Consumption From', class: 'timestamp', icon: 'mdi:calendar-clock', val: 'gas_consumption_from', category: 'diagnostic' },
|
|
113
|
+
{ id: 'gas_consumption_to', name: 'Gas Consumption To', class: 'timestamp', icon: 'mdi:calendar-clock', val: 'gas_consumption_to', category: 'diagnostic' },
|
|
114
|
+
{ id: 'gas_rates_error', name: 'Gas Rates Error', icon: 'mdi:alert-circle', val: 'gas_rates_error', category: 'diagnostic' },
|
|
115
|
+
{ id: 'gas_consumption_error', name: 'Gas Consumption Error', icon: 'mdi:alert-circle', val: 'gas_consumption_error', category: 'diagnostic' },
|
|
116
|
+
|
|
117
|
+
// --- Applicable Rates (main) ---
|
|
118
|
+
{ id: 'applicable_rates_current_pence', name: 'Current Electricity Rate', unit: 'p/kWh', icon: 'mdi:cash-clock', val: 'applicable_rates_current_pence' },
|
|
119
|
+
{ id: 'applicable_rates_current_gbp', name: 'Electricity Rate', unit: 'GBP/kWh', icon: 'mdi:cash-clock', stateClass: 'measurement', val: 'applicable_rates_current_gbp' },
|
|
120
|
+
// --- Applicable Rates (diagnostic) ---
|
|
121
|
+
{ id: 'applicable_rates_count', name: 'Applicable Rates Slots', icon: 'mdi:format-list-numbered', val: 'applicable_rates_count', category: 'diagnostic' },
|
|
122
|
+
{ id: 'applicable_rates_error', name: 'Applicable Rates Error', icon: 'mdi:alert-circle', val: 'applicable_rates_error', category: 'diagnostic' },
|
|
123
|
+
{ id: 'applicable_rates_prev_pence', name: 'Applicable Rate Prev', unit: 'p/kWh', icon: 'mdi:cash-clock', val: 'applicable_rates_prev_pence', category: 'diagnostic' },
|
|
124
|
+
{ id: 'applicable_rates_prev_gbp', name: 'Applicable Rate Prev (GBP)', unit: 'GBP/kWh', icon: 'mdi:cash-clock', val: 'applicable_rates_prev_gbp', stateClass: 'measurement', category: 'diagnostic' },
|
|
125
|
+
{ id: 'applicable_rates_prev_to', name: 'Applicable Rate Prev Ends', class: 'timestamp', icon: 'mdi:calendar-clock', val: 'applicable_rates_prev_to', category: 'diagnostic' },
|
|
126
|
+
{ id: 'applicable_rates_next_pence', name: 'Applicable Rate Next', unit: 'p/kWh', icon: 'mdi:cash-clock', val: 'applicable_rates_next_pence', category: 'diagnostic' },
|
|
127
|
+
{ id: 'applicable_rates_next_gbp', name: 'Applicable Rate Next (GBP)', unit: 'GBP/kWh', icon: 'mdi:cash-clock', val: 'applicable_rates_next_gbp', stateClass: 'measurement', category: 'diagnostic' },
|
|
128
|
+
{ id: 'applicable_rates_next_from', name: 'Applicable Rate Next From', class: 'timestamp', icon: 'mdi:calendar-clock', val: 'applicable_rates_next_from', category: 'diagnostic' },
|
|
129
|
+
// Applicable rates — 24h schedule stats (v1.5)
|
|
130
|
+
{ id: 'applicable_rates_min_pence', name: 'Applicable Rates Min', unit: 'p/kWh', icon: 'mdi:arrow-down', val: 'applicable_rates_min_pence', category: 'diagnostic' },
|
|
131
|
+
{ id: 'applicable_rates_max_pence', name: 'Applicable Rates Max', unit: 'p/kWh', icon: 'mdi:arrow-up', val: 'applicable_rates_max_pence', category: 'diagnostic' },
|
|
132
|
+
{ id: 'applicable_rates_median_pence', name: 'Applicable Rates Median', unit: 'p/kWh', icon: 'mdi:approximately-equal', val: 'applicable_rates_median_pence', category: 'diagnostic' },
|
|
133
|
+
{ id: 'applicable_rates_avg_pence', name: 'Applicable Rates Avg', unit: 'p/kWh', icon: 'mdi:chart-line', val: 'applicable_rates_avg_pence', category: 'diagnostic' },
|
|
134
|
+
{ id: 'electricity_export_rate_min_pence', name: 'Electricity Export Rate Min', unit: 'p/kWh', icon: 'mdi:arrow-down', val: 'electricity_export_rate_min_pence', category: 'diagnostic' },
|
|
135
|
+
{ id: 'electricity_export_rate_max_pence', name: 'Electricity Export Rate Max', unit: 'p/kWh', icon: 'mdi:arrow-up', val: 'electricity_export_rate_max_pence', category: 'diagnostic' },
|
|
136
|
+
{ id: 'electricity_export_rate_median_pence', name: 'Electricity Export Rate Median', unit: 'p/kWh', icon: 'mdi:approximately-equal', val: 'electricity_export_rate_median_pence', category: 'diagnostic' },
|
|
137
|
+
{ id: 'electricity_export_rate_avg_pence', name: 'Electricity Export Rate Avg', unit: 'p/kWh', icon: 'mdi:chart-line', val: 'electricity_export_rate_avg_pence', category: 'diagnostic' },
|
|
138
|
+
|
|
139
|
+
// --- Account (main) ---
|
|
140
|
+
{ id: 'account_balance_pounds', name: 'Account Balance', unit: '£', icon: 'mdi:cash-multiple', val: 'account_balance_pounds' },
|
|
141
|
+
// --- Account (diagnostic) ---
|
|
142
|
+
{ id: 'account_balance_pence', name: 'Account Balance (Pence)', unit: 'p', icon: 'mdi:cash', val: 'account_balance_pence', category: 'diagnostic' },
|
|
143
|
+
{ id: 'account_error', name: 'Account Error', icon: 'mdi:alert-circle', val: 'account_error', category: 'diagnostic' },
|
|
144
|
+
|
|
145
|
+
// --- Octoplus (main) ---
|
|
146
|
+
// octoplus_enrolled and octoplus_loyalty_points_user are booleans — published as
|
|
147
|
+
// binary_sensor entities further down. Leaving them out of this array.
|
|
148
|
+
{ id: 'octoplus_enrollment_status', name: 'Octoplus Status', icon: 'mdi:star-circle-outline', val: 'octoplus_enrollment_status' },
|
|
149
|
+
// --- Octoplus (diagnostic) ---
|
|
150
|
+
{ id: 'octoplus_error', name: 'Octoplus Error', icon: 'mdi:alert-circle', val: 'octoplus_error', category: 'diagnostic' },
|
|
151
|
+
|
|
152
|
+
// --- Wheel of Fortune (main) ---
|
|
153
|
+
{ id: 'wheel_of_fortune_electricity_spins', name: 'WoF Electricity Spins', icon: 'mdi:star-circle', val: 'wheel_of_fortune_electricity_spins' },
|
|
154
|
+
{ id: 'wheel_of_fortune_gas_spins', name: 'WoF Gas Spins', icon: 'mdi:star-circle', val: 'wheel_of_fortune_gas_spins' },
|
|
155
|
+
// --- Wheel of Fortune (diagnostic) ---
|
|
156
|
+
{ id: 'wheel_of_fortune_electricity_max', name: 'WoF Electricity Max', icon: 'mdi:star-outline', val: 'wheel_of_fortune_electricity_max', category: 'diagnostic' },
|
|
157
|
+
{ id: 'wheel_of_fortune_electricity_used', name: 'WoF Electricity Used', icon: 'mdi:star-outline', val: 'wheel_of_fortune_electricity_used', category: 'diagnostic' },
|
|
158
|
+
{ id: 'wheel_of_fortune_gas_max', name: 'WoF Gas Max', icon: 'mdi:star-outline', val: 'wheel_of_fortune_gas_max', category: 'diagnostic' },
|
|
159
|
+
{ id: 'wheel_of_fortune_gas_used', name: 'WoF Gas Used', icon: 'mdi:star-outline', val: 'wheel_of_fortune_gas_used', category: 'diagnostic' },
|
|
160
|
+
{ id: 'wheel_of_fortune_error', name: 'WoF Error', icon: 'mdi:alert-circle', val: 'wheel_of_fortune_error', category: 'diagnostic' },
|
|
161
|
+
|
|
162
|
+
// --- Home Mini (main) ---
|
|
163
|
+
{ id: 'mini_demand_kw', name: 'Home Mini Demand', unit: 'kW', class: 'power', icon: 'mdi:home-lightning-bolt', val: 'mini_demand_kw' },
|
|
164
|
+
{ id: 'mini_consumption_delta_kwh', name: 'Home Mini Period Consumption', unit: 'kWh', class: 'energy', icon: 'mdi:home-lightning-bolt', val: 'mini_consumption_delta_kwh' },
|
|
165
|
+
// --- Home Mini (diagnostic) ---
|
|
166
|
+
{ id: 'mini_read_at', name: 'Home Mini Reading Time', class: 'timestamp', icon: 'mdi:clock-outline', val: 'mini_read_at', category: 'diagnostic' },
|
|
167
|
+
{ id: 'home_mini_error', name: 'Home Mini Error', icon: 'mdi:alert-circle', val: 'home_mini_error', category: 'diagnostic' },
|
|
168
|
+
|
|
169
|
+
// --- Saving Sessions (main) ---
|
|
170
|
+
{ id: 'saving_session_points', name: 'Octopus Points', icon: 'mdi:star', val: 'saving_session_points' },
|
|
171
|
+
// --- Saving Sessions (main) ---
|
|
172
|
+
{ id: 'saving_session_start', name: 'Saving Session Start', class: 'timestamp', icon: 'mdi:calendar-clock', val: 'saving_session_start' },
|
|
173
|
+
{ id: 'saving_session_end', name: 'Saving Session End', class: 'timestamp', icon: 'mdi:calendar-clock', val: 'saving_session_end' },
|
|
174
|
+
// --- Saving Sessions (diagnostic) ---
|
|
175
|
+
{ id: 'saving_sessions_error', name: 'Saving Sessions Error', icon: 'mdi:alert-circle', val: 'saving_sessions_error', category: 'diagnostic' },
|
|
176
|
+
|
|
177
|
+
// --- Free Electricity (main) ---
|
|
178
|
+
{ id: 'free_electricity_start', name: 'Free Electricity Start', class: 'timestamp', icon: 'mdi:flash-circle', val: 'free_electricity_start' },
|
|
179
|
+
{ id: 'free_electricity_end', name: 'Free Electricity End', class: 'timestamp', icon: 'mdi:flash-circle', val: 'free_electricity_end' },
|
|
180
|
+
// --- Free Electricity (diagnostic) ---
|
|
181
|
+
{ id: 'free_electricity_error', name: 'Free Electricity Error', icon: 'mdi:alert-circle', val: 'free_electricity_error', category: 'diagnostic' },
|
|
182
|
+
|
|
183
|
+
// --- Dispatches (main) ---
|
|
184
|
+
{ id: 'completed_dispatches_count', name: 'Completed Dispatches', icon: 'mdi:history', val: 'completed_dispatches_count' },
|
|
185
|
+
{ id: 'flex_planned_dispatches_count', name: 'Flex Planned Dispatches', icon: 'mdi:lightning-bolt-circle', val: 'flex_planned_dispatches_count' },
|
|
186
|
+
// --- Dispatches (diagnostic) ---
|
|
187
|
+
{ id: 'completed_dispatches_error', name: 'Completed Dispatches Error', icon: 'mdi:alert-circle', val: 'completed_dispatches_error', category: 'diagnostic' },
|
|
188
|
+
{ id: 'flex_planned_dispatches_error', name: 'Flex Planned Dispatches Error', icon: 'mdi:alert-circle', val: 'flex_planned_dispatches_error', category: 'diagnostic' },
|
|
189
|
+
{ id: 'intelligent_error', name: 'Intelligent Error', icon: 'mdi:alert-circle', val: 'intelligent_error', category: 'diagnostic' },
|
|
190
|
+
|
|
191
|
+
// v1.5 — update check (the MQTT update entity is published in announceControls())
|
|
192
|
+
{ id: 'installed_version', name: 'Installed Version', icon: 'mdi:package-variant', val: 'installed_version', category: 'diagnostic' },
|
|
193
|
+
{ id: 'latest_version', name: 'Latest Version', icon: 'mdi:package-variant-closed-plus', val: 'latest_version', category: 'diagnostic' },
|
|
194
|
+
{ id: 'update_check_at', name: 'Update Check At', class: 'timestamp', icon: 'mdi:clock-check-outline', val: 'update_check_at', category: 'diagnostic' },
|
|
195
|
+
{ id: 'update_check_error', name: 'Update Check Error', icon: 'mdi:alert-circle', val: 'update_check_error', category: 'diagnostic' },
|
|
196
|
+
];
|
|
197
|
+
|
|
198
|
+
// v1.5 — derived binary_sensors for the unified <category>_error fields.
|
|
199
|
+
// OFF when the underlying field is null/empty (healthy), ON when populated.
|
|
200
|
+
// The string sensors stay; these are additional indicators.
|
|
201
|
+
const errorSensors = [
|
|
202
|
+
{ id: 'intelligent_error_state', name: 'Intelligent Error State', val: 'intelligent_error' },
|
|
203
|
+
{ id: 'electricity_rates_error_state', name: 'Electricity Rates Error State', val: 'electricity_rates_error' },
|
|
204
|
+
{ id: 'electricity_consumption_error_state', name: 'Electricity Consumption Error State', val: 'electricity_consumption_error' },
|
|
205
|
+
{ id: 'electricity_export_rate_error_state', name: 'Electricity Export Rate Error State', val: 'electricity_export_rate_error' },
|
|
206
|
+
{ id: 'gas_rates_error_state', name: 'Gas Rates Error State', val: 'gas_rates_error' },
|
|
207
|
+
{ id: 'gas_consumption_error_state', name: 'Gas Consumption Error State', val: 'gas_consumption_error' },
|
|
208
|
+
{ id: 'applicable_rates_error_state', name: 'Applicable Rates Error State', val: 'applicable_rates_error' },
|
|
209
|
+
{ id: 'account_error_state', name: 'Account Error State', val: 'account_error' },
|
|
210
|
+
{ id: 'octoplus_error_state', name: 'Octoplus Error State', val: 'octoplus_error' },
|
|
211
|
+
{ id: 'wheel_of_fortune_error_state', name: 'Wheel of Fortune Error State', val: 'wheel_of_fortune_error' },
|
|
212
|
+
{ id: 'home_mini_error_state', name: 'Home Mini Error State', val: 'home_mini_error' },
|
|
213
|
+
{ id: 'saving_sessions_error_state', name: 'Saving Sessions Error State', val: 'saving_sessions_error' },
|
|
214
|
+
{ id: 'free_electricity_error_state', name: 'Free Electricity Error State', val: 'free_electricity_error' },
|
|
215
|
+
{ id: 'completed_dispatches_error_state', name: 'Completed Dispatches Error State', val: 'completed_dispatches_error' },
|
|
216
|
+
{ id: 'flex_planned_dispatches_error_state', name: 'Flex Planned Dispatches Error State', val: 'flex_planned_dispatches_error' },
|
|
217
|
+
];
|
|
218
|
+
|
|
219
|
+
// v1.7.0 — SmartFlex vehicle / charge point sensors. Kept out of `sensors` because they are
|
|
220
|
+
// only announced when product discovery finds a vehicle or charge point; otherwise their
|
|
221
|
+
// discovery topics are cleared. Names are frozen into HA entity_ids at first discovery:
|
|
222
|
+
// never rename these. The last-session problem flag is a boolean, so it is a binary_sensor
|
|
223
|
+
// in octopus-intelligent.js.
|
|
224
|
+
// nullUnavailable: a text sensor whose null value should read Unavailable in Home Assistant,
|
|
225
|
+
// not the text "None" (review L1). Error text sensors keep "None" for healthy, as before.
|
|
226
|
+
const vehicleSensors = [
|
|
227
|
+
// state_class total: last_reset is the session end (octopus-intelligent.js), so each new
|
|
228
|
+
// finished session adds its kWh to the long-term statistics once (review L2).
|
|
229
|
+
{ id: 'last_session_kwh', name: 'Last Charge Session Energy', unit: 'kWh', class: 'energy', stateClass: 'total', icon: 'mdi:ev-station', val: 'last_session_kwh' },
|
|
230
|
+
// No device_class (review L5): battery would feed low-battery alerts and the device's
|
|
231
|
+
// battery display with a value that is only the charge at the end of the last session.
|
|
232
|
+
{ id: 'last_session_soc_final', name: 'Last Charge Session Final Charge', unit: '%', stateClass: 'measurement', icon: 'mdi:battery-charging', val: 'last_session_soc_final' },
|
|
233
|
+
{ id: 'vehicle_make', name: 'Vehicle Make', icon: 'mdi:car-info', val: 'vehicle_make', category: 'diagnostic', nullUnavailable: true },
|
|
234
|
+
{ id: 'vehicle_model', name: 'Vehicle Model', icon: 'mdi:car-info', val: 'vehicle_model', category: 'diagnostic', nullUnavailable: true },
|
|
235
|
+
{ id: 'vehicle_battery_kwh', name: 'Vehicle Battery Size', unit: 'kWh', class: 'energy_storage', icon: 'mdi:car-battery', val: 'vehicle_battery_kwh', category: 'diagnostic' },
|
|
236
|
+
{ id: 'charger_power_kw', name: 'Charger Power', unit: 'kW', class: 'power', icon: 'mdi:ev-plug-type2', val: 'charger_power_kw', category: 'diagnostic' },
|
|
237
|
+
{ id: 'vehicle_device_state', name: 'Vehicle Device State', icon: 'mdi:car-connected', val: 'device_state', category: 'diagnostic', nullUnavailable: true },
|
|
238
|
+
{ id: 'smartflex_vehicle_error', name: 'SmartFlex Vehicle Error', icon: 'mdi:alert-circle', val: 'smartflex_vehicle_error', category: 'diagnostic' },
|
|
239
|
+
];
|
|
240
|
+
|
|
241
|
+
const vehicleErrorSensors = [
|
|
242
|
+
{ id: 'smartflex_vehicle_error_state', name: 'SmartFlex Vehicle Error State', val: 'smartflex_vehicle_error' },
|
|
243
|
+
];
|
|
244
|
+
|
|
245
|
+
// v1.7.0 — SmartFlex inverter sensors, EXPERIMENTAL (not yet verified on a real inverter).
|
|
246
|
+
// Kept out of `sensors` because they are only announced when the editor option
|
|
247
|
+
// enableSmartflexInverter is ticked AND discovery finds an inverter; otherwise their
|
|
248
|
+
// discovery topics are cleared.
|
|
249
|
+
// inverter_online is a boolean, so it is a binary_sensor in octopus-intelligent.js.
|
|
250
|
+
const inverterSensors = [
|
|
251
|
+
{ id: 'solar_power_kw', name: 'Solar Power', unit: 'kW', class: 'power', stateClass: 'measurement', icon: 'mdi:solar-power', val: 'solar_power_kw' },
|
|
252
|
+
{ id: 'home_battery_power_kw', name: 'Home Battery Power', unit: 'kW', class: 'power', stateClass: 'measurement', icon: 'mdi:home-battery', val: 'home_battery_power_kw' },
|
|
253
|
+
{ id: 'home_battery_soc', name: 'Home Battery Charge', unit: '%', class: 'battery', stateClass: 'measurement', val: 'home_battery_soc' },
|
|
254
|
+
{ id: 'grid_power_kw', name: 'Grid Power', unit: 'kW', class: 'power', stateClass: 'measurement', icon: 'mdi:transmission-tower', val: 'grid_power_kw' },
|
|
255
|
+
{ id: 'site_consumption_kw', name: 'Site Consumption', unit: 'kW', class: 'power', stateClass: 'measurement', icon: 'mdi:home-lightning-bolt', val: 'site_consumption_kw' },
|
|
256
|
+
{ id: 'site_export_kw', name: 'Site Export', unit: 'kW', class: 'power', stateClass: 'measurement', icon: 'mdi:transmission-tower-export', val: 'site_export_kw' },
|
|
257
|
+
{ id: 'inverter_power_kw', name: 'Inverter Power', unit: 'kW', class: 'power', stateClass: 'measurement', icon: 'mdi:solar-power-variant', val: 'inverter_power_kw' },
|
|
258
|
+
{ id: 'inverter_make', name: 'Inverter Make', icon: 'mdi:information-outline', val: 'inverter_make', category: 'diagnostic', nullUnavailable: true },
|
|
259
|
+
{ id: 'inverter_model', name: 'Inverter Model', icon: 'mdi:information-outline', val: 'inverter_model', category: 'diagnostic', nullUnavailable: true },
|
|
260
|
+
{ id: 'solar_peak_kw', name: 'Solar Peak Power', unit: 'kW', class: 'power', icon: 'mdi:solar-panel-large', val: 'solar_peak_kw', category: 'diagnostic' },
|
|
261
|
+
{ id: 'inverter_connection_status', name: 'Inverter Connection Status', icon: 'mdi:lan-connect', val: 'inverter_connection_status', category: 'diagnostic', nullUnavailable: true },
|
|
262
|
+
{ id: 'smartflex_inverter_error', name: 'SmartFlex Inverter Error', icon: 'mdi:alert-circle', val: 'smartflex_inverter_error', category: 'diagnostic' },
|
|
263
|
+
];
|
|
264
|
+
|
|
265
|
+
const inverterErrorSensors = [
|
|
266
|
+
{ id: 'smartflex_inverter_error_state', name: 'SmartFlex Inverter Error State', val: 'smartflex_inverter_error' },
|
|
267
|
+
];
|
|
268
|
+
|
|
269
|
+
module.exports = { sensors, errorSensors, vehicleSensors, vehicleErrorSensors, inverterSensors, inverterErrorSensors };
|