node-red-contrib-octopus-intelligent 1.3.1 → 1.3.2
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 +12 -0
- package/lib/categories/account.js +3 -1
- package/lib/categories/electricity.js +3 -2
- package/lib/categories/gas.js +3 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.3.2] — 2026-05-14
|
|
9
|
+
|
|
10
|
+
Defensive hardening pass following the v1.3.1 hotfix audit. No user-facing behaviour change against the current live Kraken API — every affected field already arrives as a JSON number today. The fix forecloses the same latent crash class (`TypeError: ...toFixed is not a function`) if Kraken ever serialises these scalars as strings, matching how `energyAddedKwh` is already returned.
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- `lib/categories/electricity.js` — `tariff.unitRate` and `tariff.standingCharge` (both import and export branches) now coerce via `parseFloat()` before emitting. Prevents string passthrough that would (a) break `device_class: monetary` sensors in HA and (b) crash any downstream arithmetic.
|
|
14
|
+
- `lib/categories/gas.js` — same treatment for `tariff.unitRate` and `tariff.standingCharge`.
|
|
15
|
+
- `lib/categories/account.js` — `balance` (pence) now coerces via `parseFloat()` before emitting `account_balance_pence`. JavaScript's `/` operator was already coercing for `account_balance_pounds`, so this only tightens type consistency on the integer pence field.
|
|
16
|
+
|
|
17
|
+
### Tests
|
|
18
|
+
- Added string-input regression tests for each coerced field, asserting `typeof === 'number'`. 4 new tests, 237 total (was 233).
|
|
19
|
+
|
|
8
20
|
## [1.3.1] — 2026-05-14
|
|
9
21
|
|
|
10
22
|
Critical hotfix for v1.3.0. Users on 1.3.0 should upgrade immediately.
|
|
@@ -13,7 +13,9 @@ function buildQuery(account) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function parseResponse(data) {
|
|
16
|
-
|
|
16
|
+
// Kraken numeric scalars can serialise as strings — coerce defensively
|
|
17
|
+
const raw = ((data.account || {}).balance) ?? null;
|
|
18
|
+
const balancePence = raw !== null ? parseFloat(raw) : null;
|
|
17
19
|
return {
|
|
18
20
|
account_balance_pence: balancePence,
|
|
19
21
|
account_balance_pounds: balancePence !== null ? parseFloat((balancePence / 100).toFixed(2)) : null,
|
|
@@ -55,9 +55,10 @@ function parseRatesResponse(data) {
|
|
|
55
55
|
const fieldsFor = (prefix, agreements) => {
|
|
56
56
|
const latest = agreements[0];
|
|
57
57
|
const tariff = (latest && latest.tariff) || {};
|
|
58
|
+
// Kraken Float scalars can serialise as strings — coerce defensively
|
|
58
59
|
return {
|
|
59
|
-
[`${prefix}_unit_rate`]: tariff.unitRate
|
|
60
|
-
[`${prefix}_standing_charge`]: tariff.standingCharge
|
|
60
|
+
[`${prefix}_unit_rate`]: tariff.unitRate != null ? parseFloat(tariff.unitRate) : null,
|
|
61
|
+
[`${prefix}_standing_charge`]: tariff.standingCharge != null ? parseFloat(tariff.standingCharge) : null,
|
|
61
62
|
[`${prefix}_tariff_code`]: tariff.productCode || null,
|
|
62
63
|
[`${prefix}_valid_from`]: (latest && latest.validFrom) || null,
|
|
63
64
|
[`${prefix}_valid_to`]: (latest && latest.validTo) || null,
|
package/lib/categories/gas.js
CHANGED
|
@@ -52,9 +52,10 @@ function parseRatesResponse(data) {
|
|
|
52
52
|
}
|
|
53
53
|
const latest = agreements[0];
|
|
54
54
|
const tariff = latest.tariff || {};
|
|
55
|
+
// Kraken Float scalars can serialise as strings — coerce defensively
|
|
55
56
|
return {
|
|
56
|
-
gas_unit_rate: tariff.unitRate
|
|
57
|
-
gas_standing_charge: tariff.standingCharge
|
|
57
|
+
gas_unit_rate: tariff.unitRate != null ? parseFloat(tariff.unitRate) : null,
|
|
58
|
+
gas_standing_charge: tariff.standingCharge != null ? parseFloat(tariff.standingCharge) : null,
|
|
58
59
|
gas_tariff_code: tariff.productCode || null,
|
|
59
60
|
gas_valid_from: latest.validFrom || null,
|
|
60
61
|
gas_valid_to: latest.validTo || null,
|
package/package.json
CHANGED