@joshjohanning/homebridge-fakeswitch 1.0.0 → 1.0.1
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/.github/workflows/ci.yml +5 -2
- package/.github/workflows/publish.yml +2 -4
- package/CHANGELOG.md +29 -0
- package/LICENSE +21 -0
- package/README.md +114 -0
- package/index.js +4 -4
- package/package.json +7 -1
- package/readme.md +0 -49
package/.github/workflows/ci.yml
CHANGED
|
@@ -9,6 +9,9 @@ on:
|
|
|
9
9
|
jobs:
|
|
10
10
|
test:
|
|
11
11
|
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
node-version: [22, 24]
|
|
12
15
|
permissions:
|
|
13
16
|
contents: read
|
|
14
17
|
pull-requests: read
|
|
@@ -17,10 +20,10 @@ jobs:
|
|
|
17
20
|
- name: Checkout repository
|
|
18
21
|
uses: actions/checkout@v6
|
|
19
22
|
|
|
20
|
-
- name: Setup Node.js
|
|
23
|
+
- name: Setup Node.js ${{ matrix.node-version }}
|
|
21
24
|
uses: actions/setup-node@v6
|
|
22
25
|
with:
|
|
23
|
-
node-version:
|
|
26
|
+
node-version: ${{ matrix.node-version }}
|
|
24
27
|
cache: 'npm'
|
|
25
28
|
|
|
26
29
|
- name: Install dependencies
|
|
@@ -30,7 +30,7 @@ jobs:
|
|
|
30
30
|
- name: Setup Node.js
|
|
31
31
|
uses: actions/setup-node@v6
|
|
32
32
|
with:
|
|
33
|
-
node-version:
|
|
33
|
+
node-version: 22
|
|
34
34
|
cache: 'npm'
|
|
35
35
|
|
|
36
36
|
- name: Install dependencies
|
|
@@ -78,9 +78,7 @@ jobs:
|
|
|
78
78
|
run: npm install -g npm@latest
|
|
79
79
|
|
|
80
80
|
- name: NPM publish
|
|
81
|
-
run: npm publish *.tgz --
|
|
82
|
-
env:
|
|
83
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
81
|
+
run: npm publish *.tgz --provenance
|
|
84
82
|
|
|
85
83
|
publish_gh:
|
|
86
84
|
needs: build
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [1.0.1] - 2026-05-26
|
|
6
|
+
|
|
7
|
+
### Docs
|
|
8
|
+
|
|
9
|
+
- Added migration guide and example configurations to README
|
|
10
|
+
|
|
11
|
+
### Housekeeping
|
|
12
|
+
|
|
13
|
+
- Switched publish workflow to npm trusted publishing
|
|
14
|
+
- Fixed Node.js version in CI workflows to match engine requirements
|
|
15
|
+
- Added funding metadata
|
|
16
|
+
- Cleaned up whitespace in `index.js`
|
|
17
|
+
- Renamed `readme.md` to `README.md`
|
|
18
|
+
- Added `LICENSE` file
|
|
19
|
+
|
|
20
|
+
## [1.0.0] - 2025-05-26
|
|
21
|
+
|
|
22
|
+
### Initial Release
|
|
23
|
+
|
|
24
|
+
Fork of [thncode/homebridge-fakeswitch](https://github.com/thncode/homebridge-fakeswitch) with the following changes:
|
|
25
|
+
|
|
26
|
+
- Renamed package to `@joshjohanning/homebridge-fakeswitch`
|
|
27
|
+
- Updated Node.js engine requirement to `^22.12.0 || ^24.0.0`
|
|
28
|
+
- Updated Homebridge engine requirement to `^1.6.0 || ^2.0.0`
|
|
29
|
+
- Added CI and publish workflows for automated testing and package publishing
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Josh Johanning
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# "Dummy Switches" Plugin
|
|
2
|
+
|
|
3
|
+
> [!TIP]
|
|
4
|
+
> This is a drop-in replacement for the original [`homebridge-fakeswitch`](https://github.com/thncode/homebridge-fakeswitch) plugin with explicit Homebridge 2 support. See [Migrating from `homebridge-fakeswitch`](#migrating-from-homebridge-fakeswitch) for setup steps.
|
|
5
|
+
|
|
6
|
+
Example config.json:
|
|
7
|
+
|
|
8
|
+
```json
|
|
9
|
+
"accessories": [
|
|
10
|
+
{
|
|
11
|
+
"accessory": "FakeSwitch",
|
|
12
|
+
"name": "My Switch 1"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
With this plugin, you can create any number of fake switches that will do nothing when turned on (and will automatically turn off right afterward, simulating a stateless switch). This can be very useful for advanced automation with HomeKit scenes.
|
|
19
|
+
|
|
20
|
+
For instance, the Philips Hue app will automatically create HomeKit scenes for you based on Hue Scenes you create. But what if you want to create a scene that contains both Philips Hue actions and other actions (like turning on the coffee maker with a WeMo outlet)? You are forced to either modify the Hue-created scene (which can be a HUGE list of actions if you have lots of lights) or build your own HomeKit lighting scenes.
|
|
21
|
+
|
|
22
|
+
Instead, you can link scenes using these dummy switches. Let's say you have a Hue Scene called "Rise and Shine" that you want to activate in the morning. And you have also setup the system HomeKit scene "Good Morning" to turn on your coffee maker and disarm you security system. You can add a single dummy switch to your Good Morning scene, then create a Trigger based on the switching-on of the dummy switch that also activates Rise And Shine.
|
|
23
|
+
|
|
24
|
+
## Stateful Switches
|
|
25
|
+
|
|
26
|
+
The default behavior of a dummy switch is to turn itself off one second after being turned on. However you may want to create a dummy switch that remains on and must be manually turned off. You can do this by passing an argument in your config.json:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
"accessories": [
|
|
30
|
+
{
|
|
31
|
+
"accessory": "FakeSwitch",
|
|
32
|
+
"name": "My Stateful Switch 1",
|
|
33
|
+
"stateful": true
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Reverse Switches
|
|
40
|
+
|
|
41
|
+
You may also want to create a dummy switch that turns itself on one second after being turned off. This can be done by passing the 'reverse' argument in your config.json:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
"accessories": [
|
|
45
|
+
{
|
|
46
|
+
"accessory": "FakeSwitch",
|
|
47
|
+
"name": "My Stateful Switch 1",
|
|
48
|
+
"reverse": true
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Migrating from `homebridge-fakeswitch`
|
|
55
|
+
|
|
56
|
+
This package can be used as a drop-in replacement for the original [`homebridge-fakeswitch`](https://www.npmjs.com/package/homebridge-fakeswitch) plugin.
|
|
57
|
+
|
|
58
|
+
This fork still registers the Homebridge accessory as:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
"accessory": "FakeSwitch"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Existing Homebridge config entries can stay the same. Your existing HomeKit accessories should keep their identity as long as you do not delete cached accessories, rename existing switches, or remove/re-pair the Homebridge bridge.
|
|
65
|
+
|
|
66
|
+
### Safe migration steps
|
|
67
|
+
|
|
68
|
+
1. Back up Homebridge from the Homebridge UI.
|
|
69
|
+
2. Stop Homebridge:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
sudo hb-service stop
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
3. Remove the original plugin:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
sudo hb-service remove homebridge-magichome-dynamic-platform
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
4. Install this fork:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
sudo hb-service add @joshjohanning/homebridge-magichome-dynamic-platform
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
5. Start Homebridge:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
sudo hb-service start
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
6. Check the Homebridge logs:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
sudo hb-service logs
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
7. Verify your existing MagicHome lights still work in Apple Home.
|
|
100
|
+
|
|
101
|
+
### Important notes
|
|
102
|
+
|
|
103
|
+
Do not change existing plugin config from `FakeSwitch` during migration.
|
|
104
|
+
|
|
105
|
+
Do not remove cached FakeSwitch accessories from Homebridge unless you intentionally want HomeKit to recreate them. Removing cached accessories may break room assignments, scenes, and automations that reference those switches.
|
|
106
|
+
|
|
107
|
+
### Updating this fork
|
|
108
|
+
|
|
109
|
+
When a new version is published to npm, update it from the Homebridge UI, or run:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
sudo hb-service add @joshjohanning/homebridge-fakeswitch
|
|
113
|
+
sudo hb-service restart
|
|
114
|
+
```
|
package/index.js
CHANGED
|
@@ -16,11 +16,11 @@ function FakeSwitch(log, config) {
|
|
|
16
16
|
this.stateful = config.stateful;
|
|
17
17
|
this.reverse = config.reverse;
|
|
18
18
|
this._service = new Service.Switch(this.name);
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
this.cacheDirectory = HomebridgeAPI.user.persistPath();
|
|
21
21
|
this.storage = require('node-persist');
|
|
22
22
|
this.storage.initSync({dir:this.cacheDirectory, forgiveParseErrors: true});
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
this._service.getCharacteristic(Characteristic.On)
|
|
25
25
|
.on('set', this._setOn.bind(this));
|
|
26
26
|
|
|
@@ -53,10 +53,10 @@ FakeSwitch.prototype._setOn = function(on, callback) {
|
|
|
53
53
|
this._service.setCharacteristic(Characteristic.On, true);
|
|
54
54
|
}.bind(this), 1000);
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
if (this.stateful) {
|
|
58
58
|
this.storage.setItemSync(this.name, on);
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
callback();
|
|
62
62
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joshjohanning/homebridge-fakeswitch",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A simple fake/dummy switch plugin for Homebridge; forked from thncode/homebridge-fakeswitch",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -29,6 +29,12 @@
|
|
|
29
29
|
"url": "https://github.com/joshjohanning/homebridge-fakeswitch/issues"
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/joshjohanning/homebridge-fakeswitch#readme",
|
|
32
|
+
"funding": [
|
|
33
|
+
{
|
|
34
|
+
"type": "paypal",
|
|
35
|
+
"url": "https://www.paypal.com/paypalme/joshuajohanning"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
32
38
|
"main": "index.js",
|
|
33
39
|
"dependencies": {
|
|
34
40
|
"node-persist": "^4.0.4"
|
package/readme.md
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# "Dummy Switches" Plugin
|
|
2
|
-
|
|
3
|
-
Example config.json:
|
|
4
|
-
|
|
5
|
-
```
|
|
6
|
-
"accessories": [
|
|
7
|
-
{
|
|
8
|
-
"accessory": "DummySwitch",
|
|
9
|
-
"name": "My Switch 1"
|
|
10
|
-
}
|
|
11
|
-
]
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
With this plugin, you can create any number of fake switches that will do nothing when turned on (and will automatically turn off right afterward, simulating a stateless switch). This can be very useful for advanced automation with HomeKit scenes.
|
|
16
|
-
|
|
17
|
-
For instance, the Philips Hue app will automatically create HomeKit scenes for you based on Hue Scenes you create. But what if you want to create a scene that contains both Philips Hue actions and other actions (like turning on the coffee maker with a WeMo outlet)? You are forced to either modify the Hue-created scene (which can be a HUGE list of actions if you have lots of lights) or build your own HomeKit lighting scenes.
|
|
18
|
-
|
|
19
|
-
Instead, you can link scenes using these dummy switches. Let's say you have a Hue Scene called "Rise and Shine" that you want to activate in the morning. And you have also setup the system HomeKit scene "Good Morning" to turn on your coffee maker and disarm you security system. You can add a single dummy switch to your Good Morning scene, then create a Trigger based on the switching-on of the dummy switch that also activates Rise And Shine.
|
|
20
|
-
|
|
21
|
-
## Stateful Switches
|
|
22
|
-
|
|
23
|
-
The default behavior of a dummy switch is to turn itself off one second after being turned on. However you may want to create a dummy switch that remains on and must be manually turned off. You can do this by passing an argument in your config.json:
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
"accessories": [
|
|
27
|
-
{
|
|
28
|
-
"accessory": "DummySwitch",
|
|
29
|
-
"name": "My Stateful Switch 1",
|
|
30
|
-
"stateful": true
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Reverse Switches
|
|
37
|
-
|
|
38
|
-
You may also want to create a dummy switch that turns itself on one second after being turned off. This can be done by passing the 'reverse' argument in your config.json:
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
"accessories": [
|
|
42
|
-
{
|
|
43
|
-
"accessory": "DummySwitch",
|
|
44
|
-
"name": "My Stateful Switch 1",
|
|
45
|
-
"reverse": true
|
|
46
|
-
}
|
|
47
|
-
]
|
|
48
|
-
|
|
49
|
-
```
|