Commit 3673b9c
committed
v4.0.0 (#330)
* Complete rewrite with unified hybrid BLE/API architecture
* No backward compatibility with v3.x - migration required
* Single `SwitchBot` class replaces `SwitchBotBLE` and `SwitchBotOpenAPI`
* Device access via `switchbot.devices` manager pattern
* Full TypeScript rewrite with comprehensive type definitions
* **Hybrid Architecture**: Unified BLE-first approach with automatic OpenAPI fallback
* **Automatic Discovery**: Combined BLE + OpenAPI device discovery in single call
* **Smart Fallback**: Commands automatically retry via API when BLE fails
* **Device Manager**: Centralized device management with `get()`, `list()`, and `clear()` methods
* **Expanded Device Coverage**: Added support and parsing updates across newly modeled devices and accessories in the v4 architecture.
* **macOS BLE Support**: Enabled BLE functionality on macOS in addition to Linux
* Platform detection now includes macOS (`darwin`) using `@stoprocent/noble`
* BLE now works on Linux and macOS systems
* Windows remains unsupported for BLE operations
* **Bot Password Protection**: Added BLE password support for Bot (`WoHand`) devices
* Password encryption using CRC32 checksums
* Password validation for 4 alphanumeric characters, case-sensitive
* Methods: `setPassword()`, `clearPassword()`, `hasPassword()`
* Automatic encrypted command execution when password is set
* Example: `examples/bot-password.js`
* Based on [homebridge-switchbot PR #1337](OpenWonderLabs/homebridge-switchbot#1337)
* **Advanced Resilience Features**: Enterprise-grade reliability enhancements
* Retry logic with exponential backoff and jitter
* Circuit breaker pattern to prevent cascading failures
* Connection intelligence tracking per-device success and failure rates
* Custom fallback handler system for logging, metrics, and alerting
* Intelligent connection selection based on historical performance
* **Event-Driven**: EventEmitter-based architecture for discovery and command events
* **TypeScript Native**: Written in TypeScript with full type safety and exports
* **Custom Errors**: Specific error classes for better error handling
* **BLE-Only Mode**: Works without OpenAPI credentials on Linux/macOS systems
* **API-Only Mode**: Works without BLE on Windows systems
* **Exports and API Surface Updates**: Updated `src/index.ts` exports for final v4 public API packaging.
* **Comprehensive Examples**: Updated and aligned example files for v4 usage patterns.
* Complete ES2022 module implementation
* Improved error handling with custom error classes
* Better connection management and timeout handling
* Enhanced logging with configurable log levels
* Hardened dependency graph with security overrides for vulnerable transitive packages
* Full JSDoc documentation coverage
* Comprehensive TypeScript type definitions for all devices
* Reworked test suite structure and coverage for APIs, devices, and utilities
* Auto-formatting and linting with @antfu/eslint-config
* Updated README with v4 quick start and migration guide
* 6 usage examples in `examples/` directory
* Migration guide from v3.x to v4.0.0
* Added password protection section to [BLE.md](BLE.md)
* Updated [README.md](README.md) with password examples
* Created comprehensive password protection example
* Updated examples index with `bot-password.js`
* Updated platform support documentation to reflect macOS BLE support
* Updated Linux-only references to Linux/macOS where applicable
* Added comprehensive prerequisites guidance for BLE setup on macOS and Linux
* macOS: Xcode and Bluetooth permissions requirements
* Linux: system packages, non-root setup, and Raspberry Pi notes
* Based on [@stoprocent/noble prerequisites](https://github.com/stoprocent/noble?tab=readme-ov-file#prerequisites)
* Full API documentation via TypeDoc
* Added 14 comprehensive password protection tests
* Validation for CRC32 encryption, command building, and response parsing
* Extended fallback and retry behavior coverage across BLE/API paths
* 58 test files and 243 passing tests at release validation
**Full Changelog**: v3.6.8...v4.0.0
chore(release): v3.6.9 [skip ci]1 parent 72965a5 commit 3673b9c
542 files changed
Lines changed: 27697 additions & 19907 deletions
File tree
- .github
- workflows
- docs
- assets
- classes
- enums
- functions
- interfaces
- media
- types
- variables
- examples
- src
- devices
- types
- utils
- test
- apis
- devices
- types
- utils
- todo
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
| 24 | + | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
29 | 43 | | |
30 | 44 | | |
31 | 45 | | |
| |||
116 | 130 | | |
117 | 131 | | |
118 | 132 | | |
119 | | - | |
| 133 | + | |
120 | 134 | | |
121 | | - | |
| 135 | + | |
122 | 136 | | |
123 | 137 | | |
124 | 138 | | |
| |||
156 | 170 | | |
157 | 171 | | |
158 | 172 | | |
159 | | - | |
| 173 | + | |
160 | 174 | | |
161 | 175 | | |
162 | 176 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 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 | + | |
12 | 57 | | |
13 | 58 | | |
| 59 | + | |
14 | 60 | | |
15 | 61 | | |
16 | 62 | | |
17 | 63 | | |
18 | 64 | | |
19 | 65 | | |
| 66 | + | |
20 | 67 | | |
21 | 68 | | |
22 | 69 | | |
23 | 70 | | |
24 | 71 | | |
25 | 72 | | |
26 | | - | |
| 73 | + | |
27 | 74 | | |
| 75 | + | |
28 | 76 | | |
29 | 77 | | |
30 | 78 | | |
| |||
39 | 87 | | |
40 | 88 | | |
41 | 89 | | |
| 90 | + | |
42 | 91 | | |
43 | | - | |
44 | 92 | | |
45 | 93 | | |
46 | 94 | | |
47 | 95 | | |
48 | 96 | | |
49 | 97 | | |
50 | | - | |
| 98 | + | |
51 | 99 | | |
52 | | - | |
| 100 | + | |
53 | 101 | | |
54 | 102 | | |
55 | 103 | | |
56 | 104 | | |
57 | 105 | | |
58 | 106 | | |
59 | 107 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
64 | 113 | | |
65 | 114 | | |
66 | | - | |
| 115 | + | |
67 | 116 | | |
68 | | - | |
69 | | - | |
| 117 | + | |
| 118 | + | |
70 | 119 | | |
71 | 120 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
5 | 13 | | |
6 | 14 | | |
7 | 15 | | |
| |||
0 commit comments