node-red-contrib-octopus-intelligent 1.0.2 → 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 +209 -118
- 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/examples/basic-monitoring.json +1 -0
- package/examples/mqtt-integration.json +1 -0
- package/examples/set-preferences.json +1 -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 +1163 -861
- package/package.json +58 -46
- package/test-mocks.js +1038 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,118 +1,209 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [1.0.
|
|
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
|
-
-
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
- **
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
- **
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
- **
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
- **
|
|
76
|
-
-
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
-
|
|
90
|
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
-
- Home Assistant
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
-
|
|
111
|
-
-
|
|
112
|
-
-
|
|
113
|
-
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
-
|
|
117
|
-
-
|
|
118
|
-
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.4] - 2025-12-11
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Manual Refresh Button (MQTT)** - "Octopus Refresh API" button in Home Assistant
|
|
12
|
+
- Hardcoded 30-second rate limiting to prevent API spam
|
|
13
|
+
- Shows warning in Node-RED when rate limited
|
|
14
|
+
- Publishes refresh cooldown state to MQTT
|
|
15
|
+
- **Refresh Available At Sensor** - Diagnostic timestamp sensor
|
|
16
|
+
- Shows ISO timestamp when manual refresh becomes available
|
|
17
|
+
- Displays as countdown in Home Assistant ("in 25 seconds")
|
|
18
|
+
- Automatically clears to `null` after 30 seconds
|
|
19
|
+
- Leverages Home Assistant's native timestamp handling
|
|
20
|
+
- **Next Poll Time Sensors** - Shows when next automatic poll will occur
|
|
21
|
+
- `sensor.octopus_next_poll_time` - Main sensor (timestamp class)
|
|
22
|
+
- `sensor.octopus_next_poll_time_raw` - Diagnostic raw timestamp
|
|
23
|
+
- Updates after each successful poll
|
|
24
|
+
- **API Complexity Tracking** - Monitor API usage against 50,000 hourly limit
|
|
25
|
+
- `sensor.octopus_api_requests_hour` - Count of requests (last 60 min)
|
|
26
|
+
- `sensor.octopus_api_complexity_hour` - Total complexity used
|
|
27
|
+
- `sensor.octopus_api_complexity_usage` - Percentage of limit used
|
|
28
|
+
- Estimated complexity: Regular poll (300), Mutation (250), Pre-validation (200)
|
|
29
|
+
- All API complexity sensors in Diagnostics section
|
|
30
|
+
- **Enhanced Debug Output** - `msg.debug` now includes:
|
|
31
|
+
- `responseHeaders` - Full HTTP response headers from API
|
|
32
|
+
- `extensions` - GraphQL extensions field (if present)
|
|
33
|
+
- `api_usage` - Comprehensive API usage metrics per request
|
|
34
|
+
- **Comprehensive Test Coverage** - Added 5 new tests
|
|
35
|
+
- Tests for MQTT refresh button rate limiting
|
|
36
|
+
- Tests for countdown expiry behavior
|
|
37
|
+
- Validates countdown doesn't go negative
|
|
38
|
+
- Tests timer cleanup and MQTT message structure
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
- **Rate Limiting Strategy** - Different behavior for MQTT vs Node-RED
|
|
42
|
+
- MQTT Button: Hardcoded 30-second cooldown (enforced)
|
|
43
|
+
- Node-RED Input: No rate limiting (programmers control this)
|
|
44
|
+
- Timestamp-based cooldown (not seconds counter)
|
|
45
|
+
- **State Output** - Node-RED now outputs state on every poll
|
|
46
|
+
- Previously only output on changes
|
|
47
|
+
- Now outputs full `statusPayload` every poll cycle
|
|
48
|
+
- Better for automations and monitoring
|
|
49
|
+
- **Global Setter** - Updated `NodeRed_Global_Setter.js` with new fields:
|
|
50
|
+
- `octopus_next_poll`
|
|
51
|
+
- `octopus_refresh_available_at`
|
|
52
|
+
- `octopus_api_requests_hour`
|
|
53
|
+
- `octopus_api_complexity_hour`
|
|
54
|
+
- `octopus_api_complexity_percent`
|
|
55
|
+
|
|
56
|
+
### Fixed
|
|
57
|
+
- **Cooldown Timer Expiry** - Properly publishes `null` at 30 seconds
|
|
58
|
+
- Prevents countdown showing negative values in Home Assistant
|
|
59
|
+
- Timer cleanup prevents memory leaks
|
|
60
|
+
- Exactly 2 MQTT messages per refresh (start + expiry)
|
|
61
|
+
|
|
62
|
+
### Technical Details
|
|
63
|
+
- **API Complexity Estimation** - Since Octopus API doesn't provide actual complexity:
|
|
64
|
+
- Uses estimated values based on query types
|
|
65
|
+
- Tracks rolling 60-minute window
|
|
66
|
+
- If actual complexity becomes available, will use it automatically
|
|
67
|
+
- **Timestamp-Based Cooldown** - Uses ISO timestamps instead of seconds
|
|
68
|
+
- Home Assistant handles countdown display automatically
|
|
69
|
+
- Zero MQTT spam during countdown
|
|
70
|
+
- Clean `null` state when ready
|
|
71
|
+
|
|
72
|
+
## [1.0.3] - 2025-12-04
|
|
73
|
+
|
|
74
|
+
### Added
|
|
75
|
+
- **State reconciliation loop** for charging detection (every 10 seconds)
|
|
76
|
+
- Automatically detects charging state based on cached slot timestamps
|
|
77
|
+
- No API calls - uses local data only
|
|
78
|
+
- Handles imminent/immediate slots when car is plugged in
|
|
79
|
+
- Self-healing: corrects state if timers miss edge cases
|
|
80
|
+
- **Flow Library scorecard compliance**
|
|
81
|
+
- Added `version` field to `node-red` section in package.json (>=2.0.0)
|
|
82
|
+
- Added `examples/` folder with 3 demonstration flows
|
|
83
|
+
- Satisfies Node-RED Flow Library requirements
|
|
84
|
+
|
|
85
|
+
### Fixed
|
|
86
|
+
- **Home Assistant sensors going "unknown"** when adjusting controls
|
|
87
|
+
- Sensors now maintain last known values while editing pending preferences
|
|
88
|
+
- Only update when fresh data arrives from API
|
|
89
|
+
- Added `lastKnownState` cache and state merging in `publishCurrentState()`
|
|
90
|
+
- **Charging state not updating** for imminent/immediate slots
|
|
91
|
+
- Fixed edge case where slots starting <30s after poll were not detected
|
|
92
|
+
- Reconciliation loop catches these within 10 seconds
|
|
93
|
+
- Ensures accurate "Charging Now" sensor in Home Assistant
|
|
94
|
+
|
|
95
|
+
### Changed
|
|
96
|
+
- Improved charging state management with redundant detection methods
|
|
97
|
+
- Enhanced MQTT state publishing to preserve sensor data during control updates
|
|
98
|
+
|
|
99
|
+
## [1.0.2] - 2025-11-30
|
|
100
|
+
|
|
101
|
+
### Changed
|
|
102
|
+
- Updated flow example description in Node-RED help panel for better clarity
|
|
103
|
+
- Improved explanation of default behavior: reads by default, manually refreshable, and accepts commands
|
|
104
|
+
|
|
105
|
+
## [1.0.1] - 2025-11-30
|
|
106
|
+
|
|
107
|
+
### Added
|
|
108
|
+
- **Node.js and Node-RED version requirements** in package.json engines field
|
|
109
|
+
- Minimum Node.js: >=14.0.0
|
|
110
|
+
- Minimum Node-RED: >=2.0.0
|
|
111
|
+
- Addresses Flow Library scorecard requirements
|
|
112
|
+
- **Comprehensive example flows** in Node-RED help panel
|
|
113
|
+
- Basic monitoring flow (inject every 5 min)
|
|
114
|
+
- Set preferences from flow (JSON payload with set_limit/set_time)
|
|
115
|
+
- Home Assistant MQTT integration example
|
|
116
|
+
- **Visual documentation** with screenshots
|
|
117
|
+
- Node-RED flow examples showing monitoring, preferences, and preset buttons
|
|
118
|
+
- MQTT integration flow example
|
|
119
|
+
- Home Assistant device page with all entities
|
|
120
|
+
- **Visual Examples section** in Node-RED help panel with embedded GitHub-hosted images
|
|
121
|
+
- **Screenshots section** in README.md showing real-world usage
|
|
122
|
+
|
|
123
|
+
### Changed
|
|
124
|
+
- Updated README.md with Screenshots section after Features
|
|
125
|
+
- Updated .npmignore to exclude images/ folder (keeps npm package lightweight)
|
|
126
|
+
- Updated .gitignore to exclude local documentation files
|
|
127
|
+
|
|
128
|
+
### Fixed
|
|
129
|
+
- Flow Library scorecard now shows supported Node-RED and Node.js versions
|
|
130
|
+
- Flow Library scorecard "Nodes have examples" requirement now satisfied
|
|
131
|
+
|
|
132
|
+
## [1.0.0] - 2025-11-30
|
|
133
|
+
|
|
134
|
+
### Added
|
|
135
|
+
- Initial public release
|
|
136
|
+
- **Octopus Energy GraphQL API integration**
|
|
137
|
+
- Authentication via API key
|
|
138
|
+
- Fetch planned charging dispatches (smart-charge and bump-charge slots)
|
|
139
|
+
- Query vehicle charging preferences (target SOC and ready time)
|
|
140
|
+
- Update charging preferences via GraphQL mutations
|
|
141
|
+
- **Home Assistant MQTT auto-discovery**
|
|
142
|
+
- Number entity: Target charge limit (50-100%)
|
|
143
|
+
- Select entity: Ready time (04:00-11:00)
|
|
144
|
+
- Button entity: Apply changes
|
|
145
|
+
- Sensor entities: Confirmed settings, next charge time, total energy, slot times
|
|
146
|
+
- Binary sensor: Charging now (ON/OFF)
|
|
147
|
+
- Organized into Controls, Sensors, and Diagnostics categories
|
|
148
|
+
- **Real-time charging slot detection**
|
|
149
|
+
- Detects currently active charging slots
|
|
150
|
+
- Calculates next charging start time
|
|
151
|
+
- Provides individual slot start/end times (up to 3 slots)
|
|
152
|
+
- Calculates overall charging window
|
|
153
|
+
- Shows charge source (smart-charge vs bump-charge)
|
|
154
|
+
- **Exponential backoff validation**
|
|
155
|
+
- Smart retry mechanism when updating preferences
|
|
156
|
+
- Prevents sensors from becoming "unavailable" during API updates
|
|
157
|
+
- Validates changes at 15s, 30s, 60s, 120s intervals
|
|
158
|
+
- **Comprehensive debugging**
|
|
159
|
+
- Full API call tracking in msg.debug
|
|
160
|
+
- Success/failure status for each operation
|
|
161
|
+
- Detailed error messages
|
|
162
|
+
- **Node-RED flow control**
|
|
163
|
+
- Accept input messages to set preferences programmatically
|
|
164
|
+
- Output payload with all charging data
|
|
165
|
+
- 5-minute default refresh interval (configurable)
|
|
166
|
+
- **Octopus Energy branding**
|
|
167
|
+
- Professional pink theme (#E8146F)
|
|
168
|
+
- Device branded as "Octopus Intelligent" in Home Assistant
|
|
169
|
+
- Suggested "Energy" area in Home Assistant
|
|
170
|
+
- **Unit test coverage**
|
|
171
|
+
- Data processing tests (10 tests)
|
|
172
|
+
- Timer management tests (10 tests)
|
|
173
|
+
- Mock API responses for consistent testing
|
|
174
|
+
|
|
175
|
+
### Security
|
|
176
|
+
- API key stored securely as Node-RED credential (not exposed in flows)
|
|
177
|
+
- Account numbers sanitized in MQTT topics and entity IDs
|
|
178
|
+
|
|
179
|
+
### Documentation
|
|
180
|
+
- Comprehensive README.md with:
|
|
181
|
+
- Feature list and capabilities
|
|
182
|
+
- Installation instructions (npm and palette manager)
|
|
183
|
+
- Configuration guide
|
|
184
|
+
- Home Assistant setup instructions
|
|
185
|
+
- Node-RED usage examples
|
|
186
|
+
- Home Assistant automation examples
|
|
187
|
+
- Troubleshooting section
|
|
188
|
+
- Support options (GitHub Star, Sponsor, PayPal donate)
|
|
189
|
+
- MIT License
|
|
190
|
+
- GitHub repository with issue tracking
|
|
191
|
+
|
|
192
|
+
## Release Notes
|
|
193
|
+
|
|
194
|
+
### Version Numbering
|
|
195
|
+
This project follows [Semantic Versioning](https://semver.org/):
|
|
196
|
+
- **MAJOR** version (X.0.0): Breaking changes
|
|
197
|
+
- **MINOR** version (1.X.0): New features (backwards compatible)
|
|
198
|
+
- **PATCH** version (1.0.X): Bug fixes (backwards compatible)
|
|
199
|
+
|
|
200
|
+
### Links
|
|
201
|
+
- [npm Package](https://www.npmjs.com/package/node-red-contrib-octopus-intelligent)
|
|
202
|
+
- [GitHub Repository](https://github.com/ASomerN/node-red-contrib-octopus-intelligent)
|
|
203
|
+
- [Node-RED Flow Library](https://flows.nodered.org/node/node-red-contrib-octopus-intelligent)
|
|
204
|
+
- [Issues & Bug Reports](https://github.com/ASomerN/node-red-contrib-octopus-intelligent/issues)
|
|
205
|
+
|
|
206
|
+
### Support
|
|
207
|
+
- ⭐ [Star on GitHub](https://github.com/ASomerN/node-red-contrib-octopus-intelligent)
|
|
208
|
+
- 💖 [Become a Sponsor](https://github.com/sponsors/ASomerN)
|
|
209
|
+
- ☕ [Donate via PayPal](https://www.paypal.com/donate?hosted_button_id=A2B8ZFEJBE2S6)
|