node-red-contrib-octopus-intelligent 1.0.3 → 1.0.4
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 +64 -0
- package/README.md +477 -432
- package/__tests__/README.md +220 -0
- package/__tests__/TEST-SUMMARY.md +194 -0
- package/__tests__/charging-now-validation.test.js +495 -0
- package/__tests__/charging-timers.test.js +601 -0
- package/__tests__/data-processing.test.js +478 -0
- package/__tests__/mqtt-refresh-cooldown.test.js +420 -0
- package/__tests__/reconciliation-loop.test.js +474 -0
- package/images/IMAGES_NEEDED.md +64 -0
- package/images/examples/basic-monitoring-flow.png +0 -0
- package/images/examples/homeassistant-device-v1.0.4.png +0 -0
- package/images/examples/homeassistant-device.png +0 -0
- package/images/examples/mqtt-integration-flow.png +0 -0
- package/octopus-intelligent.js +271 -22
- package/package.json +12 -1
- package/test-mocks.js +1038 -0
- package/NodeRed_Global_Setter.js +0 -76
- package/RELEASE.md +0 -140
package/NodeRed_Global_Setter.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Node-RED Global Context Setter for Octopus Intelligent Node
|
|
3
|
-
*
|
|
4
|
-
* This is a helper function that stores all data from the Octopus Intelligent node
|
|
5
|
-
* into Node-RED's global context for easy access across your flows.
|
|
6
|
-
*
|
|
7
|
-
* USAGE:
|
|
8
|
-
* 1. Add a Function node after your Octopus Intelligent node
|
|
9
|
-
* 2. Copy this code into the Function node
|
|
10
|
-
* 3. All data will be stored in global context with 'octopus_' prefix
|
|
11
|
-
*
|
|
12
|
-
* ACCESSING THE DATA:
|
|
13
|
-
* In any Function node:
|
|
14
|
-
* const chargingNow = global.get("octopus_charging_now");
|
|
15
|
-
* const nextStart = global.get("octopus_next_start");
|
|
16
|
-
* const allData = global.get("octopus_data"); // entire payload as object
|
|
17
|
-
*
|
|
18
|
-
* In Change nodes or templates:
|
|
19
|
-
* {{global.octopus_charging_now}}
|
|
20
|
-
* {{global.octopus_next_start}}
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
// Store all payload data to global context
|
|
24
|
-
function storeOctopusDataToGlobal(payload) {
|
|
25
|
-
// Store main charging data
|
|
26
|
-
global.set("octopus_next_start", payload.next_start);
|
|
27
|
-
global.set("octopus_total_energy", payload.total_energy);
|
|
28
|
-
global.set("octopus_next_kwh", payload.next_kwh);
|
|
29
|
-
global.set("octopus_next_source", payload.next_source);
|
|
30
|
-
|
|
31
|
-
// Store preferences (confirmed from API)
|
|
32
|
-
global.set("octopus_confirmed_limit", payload.confirmed_limit);
|
|
33
|
-
global.set("octopus_confirmed_time", payload.confirmed_time);
|
|
34
|
-
|
|
35
|
-
// Store pending preferences (user selections not yet submitted)
|
|
36
|
-
global.set("octopus_pending_limit", payload.pending_limit);
|
|
37
|
-
global.set("octopus_pending_time", payload.pending_time);
|
|
38
|
-
|
|
39
|
-
// Store charging status (boolean: true/false)
|
|
40
|
-
global.set("octopus_charging_now", payload.charging_now);
|
|
41
|
-
|
|
42
|
-
// Store individual charging slots (formatted timestamps)
|
|
43
|
-
global.set("octopus_slot1_start", payload.slot1_start);
|
|
44
|
-
global.set("octopus_slot1_end", payload.slot1_end);
|
|
45
|
-
global.set("octopus_slot2_start", payload.slot2_start);
|
|
46
|
-
global.set("octopus_slot2_end", payload.slot2_end);
|
|
47
|
-
global.set("octopus_slot3_start", payload.slot3_start);
|
|
48
|
-
global.set("octopus_slot3_end", payload.slot3_end);
|
|
49
|
-
|
|
50
|
-
// Store overall charging window (first start to last end)
|
|
51
|
-
global.set("octopus_window_start", payload.window_start);
|
|
52
|
-
global.set("octopus_window_end", payload.window_end);
|
|
53
|
-
|
|
54
|
-
// Store raw timestamp strings (exact API output)
|
|
55
|
-
global.set("octopus_next_start_raw", payload.next_start_raw);
|
|
56
|
-
global.set("octopus_slot1_start_raw", payload.slot1_start_raw);
|
|
57
|
-
global.set("octopus_slot1_end_raw", payload.slot1_end_raw);
|
|
58
|
-
global.set("octopus_slot2_start_raw", payload.slot2_start_raw);
|
|
59
|
-
global.set("octopus_slot2_end_raw", payload.slot2_end_raw);
|
|
60
|
-
global.set("octopus_slot3_start_raw", payload.slot3_start_raw);
|
|
61
|
-
global.set("octopus_slot3_end_raw", payload.slot3_end_raw);
|
|
62
|
-
global.set("octopus_window_start_raw", payload.window_start_raw);
|
|
63
|
-
global.set("octopus_window_end_raw", payload.window_end_raw);
|
|
64
|
-
|
|
65
|
-
// Store entire payload as single object for convenience
|
|
66
|
-
global.set("octopus_data", payload);
|
|
67
|
-
|
|
68
|
-
// Store last update timestamp
|
|
69
|
-
global.set("octopus_last_update", new Date().toISOString());
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Call the function with the incoming payload
|
|
73
|
-
storeOctopusDataToGlobal(msg.payload);
|
|
74
|
-
|
|
75
|
-
// Pass the message through unchanged
|
|
76
|
-
return msg;
|
package/RELEASE.md
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
# Release Checklist
|
|
2
|
-
|
|
3
|
-
Use this checklist when releasing a new version to ensure nothing is missed.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Phase 1: Development & Testing
|
|
8
|
-
|
|
9
|
-
- [ ] Create feature branch: `dev/feature-name`
|
|
10
|
-
- [ ] Make code changes and commit
|
|
11
|
-
- [ ] Update version in `package.json` (e.g., 1.0.2 → 1.0.3)
|
|
12
|
-
- [ ] Run unit tests: `npm test` - **ALL MUST PASS** ✅
|
|
13
|
-
- [ ] Build package: `npm pack`
|
|
14
|
-
- [ ] Test .tgz on Raspberry Pi Node-RED installation
|
|
15
|
-
- [ ] Verify functionality in Home Assistant
|
|
16
|
-
- [ ] Run `git status` - ensure no untracked files to commit
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## Phase 2: Documentation
|
|
21
|
-
|
|
22
|
-
- [ ] Update `CHANGELOG.md` with new version section:
|
|
23
|
-
```markdown
|
|
24
|
-
## [1.0.3] - YYYY-MM-DD
|
|
25
|
-
|
|
26
|
-
### Added
|
|
27
|
-
- New features listed here
|
|
28
|
-
|
|
29
|
-
### Changed
|
|
30
|
-
- Changes listed here
|
|
31
|
-
|
|
32
|
-
### Fixed
|
|
33
|
-
- Bug fixes listed here
|
|
34
|
-
```
|
|
35
|
-
- [ ] Review `README.md` for any needed updates
|
|
36
|
-
- [ ] Commit documentation updates
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
## Phase 3: Merge to Master
|
|
41
|
-
|
|
42
|
-
- [ ] Ensure all changes committed on dev branch
|
|
43
|
-
- [ ] Run final tests: `npm test`
|
|
44
|
-
- [ ] Switch to master: `git checkout master`
|
|
45
|
-
- [ ] Merge dev branch: `git merge dev/feature-name`
|
|
46
|
-
- [ ] Verify merged correctly: `git log --oneline -5`
|
|
47
|
-
|
|
48
|
-
---
|
|
49
|
-
|
|
50
|
-
## Phase 4: Git Release
|
|
51
|
-
|
|
52
|
-
- [ ] Create annotated tag: `git tag -a v1.0.3 -m "Release v1.0.3 - Description"`
|
|
53
|
-
- [ ] Push master branch: `git push origin master`
|
|
54
|
-
- [ ] Push tag: `git push origin v1.0.3`
|
|
55
|
-
- [ ] Verify on GitHub: https://github.com/ASomerN/node-red-contrib-octopus-intelligent/releases
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
## Phase 5: npm Publication
|
|
60
|
-
|
|
61
|
-
- [ ] Verify you're on master branch: `git branch`
|
|
62
|
-
- [ ] Verify version is correct: `npm view node-red-contrib-octopus-intelligent version`
|
|
63
|
-
- [ ] Publish to npm: `npm publish`
|
|
64
|
-
- [ ] Verify publication: `npm view node-red-contrib-octopus-intelligent version`
|
|
65
|
-
- [ ] Check package page: https://www.npmjs.com/package/node-red-contrib-octopus-intelligent
|
|
66
|
-
|
|
67
|
-
---
|
|
68
|
-
|
|
69
|
-
## Phase 6: Flow Library Update
|
|
70
|
-
|
|
71
|
-
- [ ] Go to: https://flows.nodered.org/node/node-red-contrib-octopus-intelligent
|
|
72
|
-
- [ ] Log in to flows.nodered.org
|
|
73
|
-
- [ ] Click "request refresh" link in sidebar (or resubmit via + button)
|
|
74
|
-
- [ ] Wait for sync (can take hours)
|
|
75
|
-
- [ ] Verify version updated on Flow Library page
|
|
76
|
-
- [ ] Check scorecard: https://flows.nodered.org/node/node-red-contrib-octopus-intelligent/scorecard
|
|
77
|
-
- [ ] All items should be ✅ green
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
## Phase 7: GitHub Release (Optional but Recommended)
|
|
82
|
-
|
|
83
|
-
- [ ] Go to: https://github.com/ASomerN/node-red-contrib-octopus-intelligent/releases/new
|
|
84
|
-
- [ ] Select tag: `v1.0.3`
|
|
85
|
-
- [ ] Release title: `v1.0.3 - Short Description`
|
|
86
|
-
- [ ] Copy CHANGELOG.md entry for this version into description
|
|
87
|
-
- [ ] Attach the `.tgz` file (optional)
|
|
88
|
-
- [ ] Publish release
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## Phase 8: Cleanup
|
|
93
|
-
|
|
94
|
-
- [ ] Delete local dev branch: `git branch -d dev/feature-name`
|
|
95
|
-
- [ ] Delete remote dev branch: `git push origin --delete dev/feature-name`
|
|
96
|
-
- [ ] Delete local `.tgz` file: `rm *.tgz`
|
|
97
|
-
- [ ] Celebrate! 🎉
|
|
98
|
-
|
|
99
|
-
---
|
|
100
|
-
|
|
101
|
-
## Quick Reference Commands
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
# Testing
|
|
105
|
-
npm test
|
|
106
|
-
|
|
107
|
-
# Build
|
|
108
|
-
npm pack
|
|
109
|
-
|
|
110
|
-
# Version check
|
|
111
|
-
npm view node-red-contrib-octopus-intelligent version
|
|
112
|
-
|
|
113
|
-
# Git workflow
|
|
114
|
-
git checkout master
|
|
115
|
-
git merge dev/feature-name
|
|
116
|
-
git tag -a v1.0.3 -m "Release v1.0.3"
|
|
117
|
-
git push origin master
|
|
118
|
-
git push origin v1.0.3
|
|
119
|
-
|
|
120
|
-
# Publish
|
|
121
|
-
npm publish
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
---
|
|
125
|
-
|
|
126
|
-
## Common Issues
|
|
127
|
-
|
|
128
|
-
### Flow Library not updating
|
|
129
|
-
- Wait 24 hours for automatic sync
|
|
130
|
-
- Try "request refresh" link when logged in
|
|
131
|
-
- If still not updating, resubmit via + button
|
|
132
|
-
|
|
133
|
-
### npm publish fails with "version already exists"
|
|
134
|
-
- Check version in package.json was bumped
|
|
135
|
-
- Verify with: `npm view node-red-contrib-octopus-intelligent version`
|
|
136
|
-
|
|
137
|
-
### Tests failing
|
|
138
|
-
- DO NOT proceed with release
|
|
139
|
-
- Fix tests first
|
|
140
|
-
- Re-test on Pi before publishing
|