homebridge-dummy 1.2.0 → 1.3.0-beta.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/CHANGELOG.md +13 -5
- package/README.md +61 -24
- package/config.schema.json +92 -0
- package/dist/accessory/base.d.ts +2 -2
- package/dist/accessory/base.js +12 -7
- package/dist/accessory/base.js.map +1 -1
- package/dist/accessory/group.d.ts +1 -1
- package/dist/accessory/group.js +2 -2
- package/dist/accessory/group.js.map +1 -1
- package/dist/accessory/helpers.d.ts +1 -1
- package/dist/accessory/helpers.js +9 -9
- package/dist/accessory/helpers.js.map +1 -1
- package/dist/accessory/lock.d.ts +1 -1
- package/dist/accessory/lock.js +22 -16
- package/dist/accessory/lock.js.map +1 -1
- package/dist/accessory/onoff/lightbulb.d.ts +1 -1
- package/dist/accessory/onoff/lightbulb.js +16 -11
- package/dist/accessory/onoff/lightbulb.js.map +1 -1
- package/dist/accessory/onoff/onoff.d.ts +1 -1
- package/dist/accessory/onoff/onoff.js +17 -14
- package/dist/accessory/onoff/onoff.js.map +1 -1
- package/dist/accessory/position/position.d.ts +1 -1
- package/dist/accessory/position/position.js +22 -16
- package/dist/accessory/position/position.js.map +1 -1
- package/dist/accessory/sensor.d.ts +0 -1
- package/dist/accessory/sensor.js +6 -4
- package/dist/accessory/sensor.js.map +1 -1
- package/dist/accessory/thermostat.d.ts +1 -1
- package/dist/accessory/thermostat.js +33 -20
- package/dist/accessory/thermostat.js.map +1 -1
- package/dist/homebridge/platform.js +4 -3
- package/dist/homebridge/platform.js.map +1 -1
- package/dist/homebridge-ui/public/index.html +1 -1
- package/dist/homebridge-ui/public/ui.js +1 -1
- package/dist/i18n/en.d.ts +94 -67
- package/dist/i18n/en.js +94 -67
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/i18n.d.ts +95 -69
- package/dist/i18n/i18n.js +0 -6
- package/dist/i18n/i18n.js.map +1 -1
- package/dist/i18n/template.d.ts +96 -69
- package/dist/i18n/template.js +2 -2
- package/dist/i18n/template.js.map +1 -1
- package/dist/model/enums.d.ts +17 -2
- package/dist/model/enums.js +30 -2
- package/dist/model/enums.js.map +1 -1
- package/dist/model/types.d.ts +8 -1
- package/dist/model/webhook.js +6 -1
- package/dist/model/webhook.js.map +1 -1
- package/dist/timeout/limiter.d.ts +18 -0
- package/dist/timeout/limiter.js +147 -0
- package/dist/timeout/limiter.js.map +1 -0
- package/dist/timeout/schedule.d.ts +0 -1
- package/dist/timeout/schedule.js +11 -6
- package/dist/timeout/schedule.js.map +1 -1
- package/dist/timeout/timeout.d.ts +6 -2
- package/dist/timeout/timeout.js +62 -58
- package/dist/timeout/timeout.js.map +1 -1
- package/dist/timeout/timer.d.ts +1 -1
- package/dist/timeout/timer.js +13 -5
- package/dist/timeout/timer.js.map +1 -1
- package/dist/tools/storage.d.ts +14 -5
- package/dist/tools/storage.js +35 -20
- package/dist/tools/storage.js.map +1 -1
- package/package.json +4 -8
- package/dist/i18n/zz.d.ts +0 -206
- package/dist/i18n/zz.js +0 -6
- package/dist/i18n/zz.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,11 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to homebridge-dummy will be documented in this file.
|
|
4
4
|
|
|
5
|
-
## 1.
|
|
5
|
+
## 1.3.0-beta.1 (2025-10-03)
|
|
6
6
|
|
|
7
7
|
### ‼️ WARNING — Read this if upgrading from v0.9.2 or earlier…
|
|
8
|
+
Automations and scenes using Homebridge Dummy accessories will need to be reconfigured. After upgrading, you must **RESTART HOMEBRIDGE SERVICE & UI** (not just *RESTART HOMEBRIDGE*). After restarting, open the Homebridge Dummy plugin settings to run the accessory migration helper. Full details [here](https://github.com/mpatfield/homebridge-dummy?tab=readme-ov-file#v1.0-migration).
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Time Limits ([documentation](https://github.com/mpatfield/homebridge-dummy?tab=readme-ov-file#limiter))
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- Accessory states are properly retained and recovered after plugin or Homebridge restart ([#191](https://github.com/mpatfield/homebridge-dummy/issues/191))
|
|
15
|
+
- Improved error messaging for invalid config values
|
|
16
|
+
|
|
17
|
+
### Notes
|
|
18
|
+
Would you like to see Homebridge Dummy in your language? Please consider [getting involved](https://github.com/mpatfield/homebridge-dummy/issues/105). No coding experience required!
|
|
8
19
|
|
|
9
|
-
|
|
20
|
+
## 1.2.0 (2025-10-02)
|
|
10
21
|
|
|
11
22
|
### Added
|
|
12
23
|
- Webhooks ([documentation](https://github.com/mpatfield/homebridge-dummy#webhooks))
|
|
@@ -18,9 +29,6 @@ Automations and scenes using Homebridge Dummy accessories will need to be reconf
|
|
|
18
29
|
- Updated dependencies
|
|
19
30
|
- Code changes to speed future feature development
|
|
20
31
|
|
|
21
|
-
### Notes
|
|
22
|
-
Would you like to see Homebridge Dummy in your language? Please consider [getting involved](https://github.com/mpatfield/homebridge-dummy/issues/105). No coding experience required!
|
|
23
|
-
|
|
24
32
|
## 1.1.0 (2025-08-14)
|
|
25
33
|
|
|
26
34
|
### Added
|
package/README.md
CHANGED
|
@@ -104,7 +104,13 @@ Using the Homebridge Config UI is the easiest way to set up this plugin. However
|
|
|
104
104
|
"sensor": {
|
|
105
105
|
"type": "CarbonDioxideSensor | CarbonMonoxideSensor | ContactSensor | LeakSensor | MotionSensor | OccupancySensor | SmokeSensor",
|
|
106
106
|
"timerControlled": true | false
|
|
107
|
-
}
|
|
107
|
+
},
|
|
108
|
+
"limiter": {
|
|
109
|
+
"id": "string",
|
|
110
|
+
"limit": number,
|
|
111
|
+
"units": "MILLISECONDS | SECONDS | MINUTES | HOURS",
|
|
112
|
+
"period": "HOUR | DAY | WEEK | MONTH",
|
|
113
|
+
},
|
|
108
114
|
"temperatureUnits": "C" | "F",
|
|
109
115
|
"defaultOn": true | false,
|
|
110
116
|
"defaultBrightness": 0-100,
|
|
@@ -119,11 +125,11 @@ Using the Homebridge Config UI is the easiest way to set up this plugin. However
|
|
|
119
125
|
"commandOpen": "string",
|
|
120
126
|
"commandClose": "string",
|
|
121
127
|
"commandTemperature": "string",
|
|
122
|
-
"enableWebook": true | false
|
|
128
|
+
"enableWebook": true | false,
|
|
123
129
|
"resetOnRestart": true | false,
|
|
124
130
|
"disableLogging": true | false
|
|
125
131
|
}
|
|
126
|
-
|
|
132
|
+
…
|
|
127
133
|
],
|
|
128
134
|
"platform": "HomebridgeDummy"
|
|
129
135
|
}
|
|
@@ -131,18 +137,36 @@ Using the Homebridge Config UI is the easiest way to set up this plugin. However
|
|
|
131
137
|
|
|
132
138
|
All fields are optional unless noted with an asterisk (*)
|
|
133
139
|
|
|
140
|
+
### General
|
|
134
141
|
- `id`* - A unique identifier for the accessory. Changing this value will create a new accessory.
|
|
135
|
-
|
|
136
142
|
- `name`* - The display name for the accessory in HomeKit
|
|
137
|
-
- `type`* - The type of accessory
|
|
138
|
-
|
|
143
|
+
- `type`* - The type of accessory
|
|
144
|
+
|
|
145
|
+
Valid values for `type` are:
|
|
146
|
+
- `Door`
|
|
147
|
+
- `Lightbulb`
|
|
148
|
+
- `LockMechanism`
|
|
149
|
+
- `Outlet`
|
|
150
|
+
- `Switch`
|
|
151
|
+
- `Thermostat`
|
|
152
|
+
- `Window`
|
|
153
|
+
- `WindowCovering`
|
|
154
|
+
|
|
155
|
+
### Group
|
|
139
156
|
- `groupName` - Items sharing the same group name will be collected together in the Home app UI
|
|
140
|
-
|
|
157
|
+
|
|
158
|
+
⚠️ Adding/removing/changing the group name will require you to reconfigure any HomeKit scenes or automations
|
|
159
|
+
|
|
160
|
+
### Timer
|
|
161
|
+
Return the accessory to its default value after the specified delay
|
|
141
162
|
|
|
142
163
|
- `timer.delay` — If defined, the switch will automatically toggle after this many milliseconds/seconds/minutes/hours
|
|
143
164
|
- `timer.units` — The units to use for delay above (`MILLISECONDS`, `SECONDS`, `MINUTES`, or `HOURS`). *Required if delay is set.
|
|
144
165
|
- `timer.random` — If true, the delay will be randomized with a maximum value of `timer.delay`
|
|
145
166
|
|
|
167
|
+
### Schedule
|
|
168
|
+
Set the accessory to its opposite (non-default) value at specified interval or times
|
|
169
|
+
|
|
146
170
|
- `schedule.type` — Automatically set the accessory to it's non-default value
|
|
147
171
|
- `schedule.interval` — Trigger the accessory after this many milliseconds/seconds/minutes/hours. *Required if `schedule.type` = `INTERVAL`
|
|
148
172
|
- `schedule.units` — The units to use for the interval (`MILLISECONDS`, `SECONDS`, `MINUTES`, or `HOURS`) *Required if `schedule.type` = `INTERVAL`
|
|
@@ -151,36 +175,49 @@ All fields are optional unless noted with an asterisk (*)
|
|
|
151
175
|
- `schedule.cronCustom` - Custom cron string for triggering the accessory. *Required if `schedule.cron` = `CUSTOM_CRON`
|
|
152
176
|
- See [crontab.guru](http://crontab.guru) for help
|
|
153
177
|
|
|
178
|
+
### Limiter
|
|
179
|
+
Restrict the total time this accessory can be set to its non-default value, for each specified period
|
|
180
|
+
|
|
181
|
+
- `limiter.id` - A random id (such as UUID) for storing the limit. Change this value to reset the limit.
|
|
182
|
+
- `limiter.limit` - The total time number of seconds/minutes/hours that this accessory may run for each `period`
|
|
183
|
+
- `limiter.units` - The units to use for delay above (`MILLISECONDS`, `SECONDS`, `MINUTES`, or `HOURS`). *Required if limit is set.
|
|
184
|
+
- `limiter.period` - How often the limit is reset (`HOUR`, `DAY`, `WEEK`, `MONTH`) *Required if limit is set.
|
|
185
|
+
- `HOUR` is reset at X:00:00, `DAY` at local midnight, `WEEK` on Monday, and `MONTH` on the 1st day
|
|
186
|
+
|
|
187
|
+
### Sensor
|
|
154
188
|
- `sensor.type` - Optionally attach a sensor that mirrors the state of the parent accessory
|
|
155
|
-
- Valid values are `CarbonDioxideSensor`, `CarbonMonoxideSensor`, `ContactSensor`, `LeakSensor`, `MotionSensor`, `OccupancySensor`, or `SmokeSensor`
|
|
156
189
|
- `sensor.timerControlled` - If true, sensor will be activated if accessory is reset by timer but not if it is reset manually
|
|
157
190
|
|
|
158
|
-
|
|
191
|
+
Valid values for sensor are:
|
|
192
|
+
- `CarbonDioxideSensor`
|
|
193
|
+
- `CarbonMonoxideSensor`
|
|
194
|
+
- `ContactSensor`
|
|
195
|
+
- `LeakSensor`
|
|
196
|
+
- `MotionSensor`
|
|
197
|
+
- `OccupancySensor`
|
|
198
|
+
- `SmokeSensor`
|
|
159
199
|
|
|
160
|
-
|
|
200
|
+
### Commands
|
|
201
|
+
Execute arbitrary commands (e.g. curl) when the accessory changes state
|
|
161
202
|
|
|
162
|
-
- `
|
|
203
|
+
- `onCommand` - Arbitrary command to execute when lightbulb/outlet/switch/thermostat turns on
|
|
204
|
+
- `offCommand` - Arbitrary command to execute when lightbulb/outlet/switch/thermostat turns off
|
|
205
|
+
- `lockCommand` - Arbitrary command to execute when lock mechanism is locked
|
|
206
|
+
- `unlockCommand` - Arbitrary command to execute when lock mechanism is unlocked
|
|
207
|
+
- `commandTemperature` - Arbitrary command to execute when temperature changes
|
|
163
208
|
|
|
209
|
+
### Defaults
|
|
210
|
+
- `temperatureUnits` - Units to use for thermostats, either 'C' or 'F'
|
|
211
|
+
- `defaultOn` — Initial value. Default _ON_ = true, default _OFF_ = false
|
|
164
212
|
- `defaultBrightness` — If set, lightbulb will have additional dimmer settings with this default brightness percentage
|
|
165
|
-
|
|
166
213
|
- `defaultLockState` - The initial value for the lock, "locked" or "unlocked"
|
|
167
|
-
|
|
168
214
|
- `defaultPosition` — Initial position for the door/window/blinds, "open" or "closed"
|
|
169
|
-
|
|
170
215
|
- `defaultThermostatState` - The initial state for the thermostat, "auto", "heat", "cool", or "off"
|
|
171
|
-
|
|
172
216
|
- `defaultTemperature` - The default temperature for the thermostat in `temperatureUnits` defined above
|
|
173
217
|
|
|
174
|
-
|
|
175
|
-
- `
|
|
176
|
-
|
|
177
|
-
- `lockCommand` - Arbitrary command to execute when lock mechanism is locked
|
|
178
|
-
- `unlockCommand` - Arbitrary command to execute when lock mechanism is unlocked
|
|
179
|
-
|
|
180
|
-
- `commandTemperature` - Arbitrary command to execute when temperature changes
|
|
181
|
-
|
|
218
|
+
### Options
|
|
219
|
+
- `enableWebook` - Turn on webhooks for this accessory. See [Webhooks](https://github.com/mpatfield/homebridge-dummy#webhooks) section below for details.
|
|
182
220
|
- `resetOnRestart` _ If true, accessory will return to default state when Homebridge restarts
|
|
183
|
-
|
|
184
221
|
- `disableLogging` — If true, state changes will not be logged
|
|
185
222
|
|
|
186
223
|
## Webhooks
|
package/config.schema.json
CHANGED
|
@@ -143,6 +143,68 @@
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
]
|
|
146
|
+
},
|
|
147
|
+
"limiter": {
|
|
148
|
+
"type": "object",
|
|
149
|
+
"properties": {
|
|
150
|
+
"id": {
|
|
151
|
+
"type": "string"
|
|
152
|
+
},
|
|
153
|
+
"limit": {
|
|
154
|
+
"type": "number",
|
|
155
|
+
"title": "${config.title.limit}"
|
|
156
|
+
},
|
|
157
|
+
"units": {
|
|
158
|
+
"type": "string",
|
|
159
|
+
"title": "${config.title.units}",
|
|
160
|
+
"enum": [ "SECONDS", "MINUTES", "HOURS"],
|
|
161
|
+
"enumNames": ["${config.enumNames.seconds}", "${config.enumNames.minutes}", "${config.enumNames.hours}"]
|
|
162
|
+
},
|
|
163
|
+
"period": {
|
|
164
|
+
"type": "string",
|
|
165
|
+
"title": "${config.title.period}",
|
|
166
|
+
"enum": [ "HOUR", "DAY", "WEEK", "MONTH"],
|
|
167
|
+
"enumNames": ["${config.enumNames.hour}", "${config.enumNames.day}", "${config.enumNames.week}", "${config.enumNames.month}"]
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"allOf": [
|
|
171
|
+
{
|
|
172
|
+
"if": {
|
|
173
|
+
"properties": {
|
|
174
|
+
"limit": {
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"required": ["limit"]
|
|
178
|
+
},
|
|
179
|
+
"then": {
|
|
180
|
+
"required": ["units", "period"]
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"if": {
|
|
185
|
+
"properties": {
|
|
186
|
+
"units" : {
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
"required": [ "units" ]
|
|
190
|
+
},
|
|
191
|
+
"then": {
|
|
192
|
+
"required": [ "limit"]
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"if": {
|
|
197
|
+
"properties": {
|
|
198
|
+
"period" : {
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
"required": [ "period" ]
|
|
202
|
+
},
|
|
203
|
+
"then": {
|
|
204
|
+
"required": [ "limit"]
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
]
|
|
146
208
|
}
|
|
147
209
|
},
|
|
148
210
|
"properties": {
|
|
@@ -176,6 +238,7 @@
|
|
|
176
238
|
"sensor": { "$ref": "#/definitions/sensor" },
|
|
177
239
|
"timer": { "$ref": "#/definitions/timer" },
|
|
178
240
|
"schedule": { "$ref": "#/definitions/schedule" },
|
|
241
|
+
"limiter": { "$ref": "#/definitions/limiter" },
|
|
179
242
|
"temperatureUnits": {
|
|
180
243
|
"type": "string",
|
|
181
244
|
"title": "${config.title.units}",
|
|
@@ -511,6 +574,35 @@
|
|
|
511
574
|
}
|
|
512
575
|
]
|
|
513
576
|
},
|
|
577
|
+
{
|
|
578
|
+
"type": "fieldset",
|
|
579
|
+
"title": "${config.title.limiter}",
|
|
580
|
+
"description": "${config.description.limiter}",
|
|
581
|
+
"condition": {
|
|
582
|
+
"functionBody": "const type = model.accessories?.[arguments[1]]?.type; return type !== undefined && type !== 'Thermostat';"
|
|
583
|
+
},
|
|
584
|
+
"items": [
|
|
585
|
+
{
|
|
586
|
+
"type": "div",
|
|
587
|
+
"displayFlex": true,
|
|
588
|
+
"flex-direction": "row",
|
|
589
|
+
"items": [
|
|
590
|
+
{
|
|
591
|
+
"key": "accessories[].limiter.limit",
|
|
592
|
+
"flex": "1 1 33%"
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
"key": "accessories[].limiter.units",
|
|
596
|
+
"flex": "1 1 33%"
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
"key": "accessories[].limiter.period",
|
|
600
|
+
"flex": "1 1 33%"
|
|
601
|
+
}
|
|
602
|
+
]
|
|
603
|
+
}
|
|
604
|
+
]
|
|
605
|
+
},
|
|
514
606
|
{
|
|
515
607
|
"type": "fieldset",
|
|
516
608
|
"title": "${config.title.commands}",
|
package/dist/accessory/base.d.ts
CHANGED
|
@@ -10,13 +10,13 @@ export declare abstract class DummyAccessory<C extends DummyConfig> {
|
|
|
10
10
|
protected readonly accessory: PlatformAccessory;
|
|
11
11
|
protected readonly config: C;
|
|
12
12
|
protected readonly log: Log;
|
|
13
|
-
protected readonly persistPath: string;
|
|
14
13
|
protected sensor?: SensorAccessory;
|
|
15
14
|
static identifier(config: DummyConfig): string;
|
|
16
15
|
protected readonly accessoryService: Service;
|
|
17
16
|
private readonly _schedule?;
|
|
18
17
|
private readonly _timer?;
|
|
19
|
-
|
|
18
|
+
private readonly _limiter?;
|
|
19
|
+
constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: C, log: Log, isGrouped: boolean);
|
|
20
20
|
protected abstract getAccessoryType(): AccessoryType;
|
|
21
21
|
protected abstract schedule(): Promise<void>;
|
|
22
22
|
protected abstract reset(): Promise<void>;
|
package/dist/accessory/base.js
CHANGED
|
@@ -3,9 +3,9 @@ import { PLATFORM_NAME, PLUGIN_ALIAS } from '../homebridge/settings.js';
|
|
|
3
3
|
import { SensorAccessory } from './sensor.js';
|
|
4
4
|
import { strings } from '../i18n/i18n.js';
|
|
5
5
|
import { AccessoryType } from '../model/enums.js';
|
|
6
|
+
import Limiter from '../timeout/limiter.js';
|
|
6
7
|
import { Schedule } from '../timeout/schedule.js';
|
|
7
8
|
import { Timer } from '../timeout/timer.js';
|
|
8
|
-
import { STORAGE_KEY_SUFFIX_DEFAULT_STATE } from '../tools/storage.js';
|
|
9
9
|
import getVersion from '../tools/version.js';
|
|
10
10
|
export class DummyAccessory {
|
|
11
11
|
Service;
|
|
@@ -13,7 +13,6 @@ export class DummyAccessory {
|
|
|
13
13
|
accessory;
|
|
14
14
|
config;
|
|
15
15
|
log;
|
|
16
|
-
persistPath;
|
|
17
16
|
sensor;
|
|
18
17
|
static identifier(config) {
|
|
19
18
|
return config.id ?? `${PLATFORM_NAME}:${config.type}:${config.name.replace(/\s+/g, '')}`;
|
|
@@ -21,13 +20,13 @@ export class DummyAccessory {
|
|
|
21
20
|
accessoryService;
|
|
22
21
|
_schedule;
|
|
23
22
|
_timer;
|
|
24
|
-
|
|
23
|
+
_limiter;
|
|
24
|
+
constructor(Service, Characteristic, accessory, config, log, isGrouped) {
|
|
25
25
|
this.Service = Service;
|
|
26
26
|
this.Characteristic = Characteristic;
|
|
27
27
|
this.accessory = accessory;
|
|
28
28
|
this.config = config;
|
|
29
29
|
this.log = log;
|
|
30
|
-
this.persistPath = persistPath;
|
|
31
30
|
this.sensor = SensorAccessory.new(Service, Characteristic, accessory, this.name, log, this.config.disableLogging === true, config.sensor);
|
|
32
31
|
if (config.timer) {
|
|
33
32
|
this._timer = Timer.new(config.timer, config.name, log, config.disableLogging === true);
|
|
@@ -35,6 +34,9 @@ export class DummyAccessory {
|
|
|
35
34
|
if (config.schedule) {
|
|
36
35
|
this._schedule = Schedule.new(config.schedule, config.name, log, config.disableLogging === true, this.schedule.bind(this));
|
|
37
36
|
}
|
|
37
|
+
if (config.limiter) {
|
|
38
|
+
this._limiter = Limiter.new(config.limiter, config.name, log, config.disableLogging === true);
|
|
39
|
+
}
|
|
38
40
|
const serviceInstance = Service[this.getAccessoryType()];
|
|
39
41
|
if (isGrouped) {
|
|
40
42
|
let accessoryService = accessory.getServiceById(serviceInstance, this.identifier);
|
|
@@ -66,6 +68,7 @@ export class DummyAccessory {
|
|
|
66
68
|
teardown() {
|
|
67
69
|
this._timer?.teardown();
|
|
68
70
|
this._schedule?.teardown();
|
|
71
|
+
this._limiter?.teardown();
|
|
69
72
|
}
|
|
70
73
|
get identifier() {
|
|
71
74
|
return DummyAccessory.identifier(this.config);
|
|
@@ -77,21 +80,23 @@ export class DummyAccessory {
|
|
|
77
80
|
return this._timer === undefined && this._schedule === undefined && !this.config.resetOnRestart;
|
|
78
81
|
}
|
|
79
82
|
get defaultStateStorageKey() {
|
|
80
|
-
return `${this.identifier}
|
|
83
|
+
return `${this.identifier}:DefaultState`;
|
|
81
84
|
}
|
|
82
85
|
startTimer() {
|
|
83
86
|
this._timer?.start(this.reset.bind(this));
|
|
87
|
+
this._limiter?.start(this.reset.bind(this));
|
|
84
88
|
}
|
|
85
89
|
cancelTimer() {
|
|
86
90
|
this._timer?.cancel();
|
|
91
|
+
this._limiter?.cancel();
|
|
87
92
|
}
|
|
88
93
|
executeCommand(command) {
|
|
89
94
|
exec(command, (_error, stdout, stderr) => {
|
|
90
95
|
if (stderr) {
|
|
91
|
-
this.log.error(`${strings.
|
|
96
|
+
this.log.error(`${strings.command.error}: %s\n%s`, this.name, command, stderr);
|
|
92
97
|
}
|
|
93
98
|
else {
|
|
94
|
-
this.logIfDesired(`${strings.
|
|
99
|
+
this.logIfDesired(`${strings.command.executed}: %s\n%s`, this.name, command, stdout);
|
|
95
100
|
}
|
|
96
101
|
});
|
|
97
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/accessory/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGrC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAExE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIlD,OAAO,
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","s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A+B;QAExE,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;YAC/B,OAAO;QACT,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,UAAU,CAAC,CAAC;IACrD,CAAC;CACF"}
|
|
@@ -5,6 +5,6 @@ import { Log } from '../tools/log.js';
|
|
|
5
5
|
export declare class GroupAccessory {
|
|
6
6
|
static identifier(groupName: string): string;
|
|
7
7
|
private readonly accessories;
|
|
8
|
-
constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: GroupConfig, log: Log,
|
|
8
|
+
constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: GroupConfig, log: Log, webhookManager: WebhookManager);
|
|
9
9
|
teardown(): void;
|
|
10
10
|
}
|
package/dist/accessory/group.js
CHANGED
|
@@ -6,7 +6,7 @@ export class GroupAccessory {
|
|
|
6
6
|
return `${PLATFORM_NAME}:Group:${groupName.replace(/\s+/g, '')})}`;
|
|
7
7
|
}
|
|
8
8
|
accessories = [];
|
|
9
|
-
constructor(Service, Characteristic, accessory, config, log,
|
|
9
|
+
constructor(Service, Characteristic, accessory, config, log, webhookManager) {
|
|
10
10
|
accessory.getService(Service.AccessoryInformation)
|
|
11
11
|
.setCharacteristic(Characteristic.Manufacturer, PLUGIN_ALIAS)
|
|
12
12
|
.setCharacteristic(Characteristic.Model, GroupAccessory.name)
|
|
@@ -14,7 +14,7 @@ export class GroupAccessory {
|
|
|
14
14
|
.setCharacteristic(Characteristic.FirmwareRevision, getVersion());
|
|
15
15
|
const keepSubtypes = new Set();
|
|
16
16
|
for (const dummyConfig of config.accessories) {
|
|
17
|
-
const dummyAccessory = createDummyAccessory(Service, Characteristic, accessory, dummyConfig, log,
|
|
17
|
+
const dummyAccessory = createDummyAccessory(Service, Characteristic, accessory, dummyConfig, log, true);
|
|
18
18
|
if (!dummyAccessory) {
|
|
19
19
|
continue;
|
|
20
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.js","sourceRoot":"","sources":["../../src/accessory/group.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAMpD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C,MAAM,OAAO,cAAc;IAElB,MAAM,CAAC,UAAU,CAAC,SAAiB;QACxC,OAAO,GAAG,aAAa,UAAU,SAAS,CAAC,OAAO,CAAC,MAAM,EAAC,EAAE,CAAC,IAAI,CAAC;IACpE,CAAC;IAEgB,WAAW,GAAoC,EAAE,CAAC;IAEnE,YACE,OAAoB,EACpB,cAAkC,EAClC,SAA4B,EAC5B,MAAmB,EACnB,GAAQ,EACR,
|
|
1
|
+
{"version":3,"file":"group.js","sourceRoot":"","sources":["../../src/accessory/group.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAMpD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C,MAAM,OAAO,cAAc;IAElB,MAAM,CAAC,UAAU,CAAC,SAAiB;QACxC,OAAO,GAAG,aAAa,UAAU,SAAS,CAAC,OAAO,CAAC,MAAM,EAAC,EAAE,CAAC,IAAI,CAAC;IACpE,CAAC;IAEgB,WAAW,GAAoC,EAAE,CAAC;IAEnE,YACE,OAAoB,EACpB,cAAkC,EAClC,SAA4B,EAC5B,MAAmB,EACnB,GAAQ,EACR,cAA8B;QAG9B,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,oBAAoB,CAAE;aAChD,iBAAiB,CAAC,cAAc,CAAC,YAAY,EAAE,YAAY,CAAC;aAC5D,iBAAiB,CAAC,cAAc,CAAC,KAAK,EAAE,cAAc,CAAC,IAA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from '../model/types.js';
|
|
4
4
|
import { Log } from '../tools/log.js';
|
|
5
|
-
export declare function createDummyAccessory(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: DummyConfig, log: Log,
|
|
5
|
+
export declare function createDummyAccessory(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: DummyConfig, log: Log, isGrouped?: boolean): DummyAccessory<DummyConfig> | null;
|
|
@@ -8,24 +8,24 @@ import { ThermostatAccessory } from './thermostat.js';
|
|
|
8
8
|
import { WindowAccessory } from './position/window.js';
|
|
9
9
|
import { strings } from '../i18n/i18n.js';
|
|
10
10
|
import { AccessoryType } from '../model/enums.js';
|
|
11
|
-
export function createDummyAccessory(Service, Characteristic, accessory, config, log,
|
|
11
|
+
export function createDummyAccessory(Service, Characteristic, accessory, config, log, isGrouped = false) {
|
|
12
12
|
switch (config.type) {
|
|
13
13
|
case AccessoryType.Door:
|
|
14
|
-
return new DoorAccessory(Service, Characteristic, accessory, config, log,
|
|
14
|
+
return new DoorAccessory(Service, Characteristic, accessory, config, log, isGrouped);
|
|
15
15
|
case AccessoryType.Lightbulb:
|
|
16
|
-
return new LightbulbAccessory(Service, Characteristic, accessory, config, log,
|
|
16
|
+
return new LightbulbAccessory(Service, Characteristic, accessory, config, log, isGrouped);
|
|
17
17
|
case AccessoryType.LockMechanism:
|
|
18
|
-
return new LockAccessory(Service, Characteristic, accessory, config, log,
|
|
18
|
+
return new LockAccessory(Service, Characteristic, accessory, config, log, isGrouped);
|
|
19
19
|
case AccessoryType.Outlet:
|
|
20
|
-
return new OutletAccessory(Service, Characteristic, accessory, config, log,
|
|
20
|
+
return new OutletAccessory(Service, Characteristic, accessory, config, log, isGrouped);
|
|
21
21
|
case AccessoryType.Switch:
|
|
22
|
-
return new SwitchAccessory(Service, Characteristic, accessory, config, log,
|
|
22
|
+
return new SwitchAccessory(Service, Characteristic, accessory, config, log, isGrouped);
|
|
23
23
|
case AccessoryType.Thermostat:
|
|
24
|
-
return new ThermostatAccessory(Service, Characteristic, accessory, config, log,
|
|
24
|
+
return new ThermostatAccessory(Service, Characteristic, accessory, config, log, isGrouped);
|
|
25
25
|
case AccessoryType.Window:
|
|
26
|
-
return new WindowAccessory(Service, Characteristic, accessory, config, log,
|
|
26
|
+
return new WindowAccessory(Service, Characteristic, accessory, config, log, isGrouped);
|
|
27
27
|
case AccessoryType.WindowCovering:
|
|
28
|
-
return new BlindAccessory(Service, Characteristic, accessory, config, log,
|
|
28
|
+
return new BlindAccessory(Service, Characteristic, accessory, config, log, isGrouped);
|
|
29
29
|
default:
|
|
30
30
|
log.error(strings.startup.unsupportedType, `'${config.type}'`);
|
|
31
31
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/accessory/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKlD,MAAM,UAAU,oBAAoB,CAClC,OAAoB,EACpB,cAAkC,EAClC,SAA4B,EAC5B,MAAmB,EACnB,GAAQ,EACR,
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/accessory/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE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AC,MAAM;YACvB,OAAO,IAAI,eAAe,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QACzF,KAAK,aAAa,CAAC,UAAU;YAC3B,OAAO,IAAI,mBAAmB,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QAC7F,KAAK,aAAa,CAAC,MAAM;YACvB,OAAO,IAAI,eAAe,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QACzF,KAAK,aAAa,CAAC,cAAc;YAC/B,OAAO,IAAI,cAAc,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QACxF;YACE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;YAC/D,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/accessory/lock.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { Webhook } from '../model/webhook.js';
|
|
|
6
6
|
import { Log } from '../tools/log.js';
|
|
7
7
|
export declare class LockAccessory extends DummyAccessory<LockConfig> {
|
|
8
8
|
private state;
|
|
9
|
-
constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: LockConfig, log: Log,
|
|
9
|
+
constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: LockConfig, log: Log, isGrouped: boolean);
|
|
10
10
|
private initializeState;
|
|
11
11
|
getAccessoryType(): AccessoryType;
|
|
12
12
|
webhooks(): Webhook[];
|
package/dist/accessory/lock.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { DummyAccessory } from './base.js';
|
|
2
2
|
import { strings } from '../i18n/i18n.js';
|
|
3
|
-
import { AccessoryType, DefaultLockState, WebhookCommand } from '../model/enums.js';
|
|
3
|
+
import { AccessoryType, DefaultLockState, isValidLockState, printableValues, WebhookCommand } from '../model/enums.js';
|
|
4
4
|
import { Webhook } from '../model/webhook.js';
|
|
5
|
-
import {
|
|
5
|
+
import { storageGet_Deprecated, Storage } from '../tools/storage.js';
|
|
6
6
|
export class LockAccessory extends DummyAccessory {
|
|
7
7
|
state;
|
|
8
|
-
constructor(Service, Characteristic, accessory, config, log,
|
|
9
|
-
super(Service, Characteristic, accessory, config, log,
|
|
8
|
+
constructor(Service, Characteristic, accessory, config, log, isGrouped) {
|
|
9
|
+
super(Service, Characteristic, accessory, config, log, isGrouped);
|
|
10
|
+
if (!isValidLockState(this.config.defaultLockState)) {
|
|
11
|
+
this.log.warning(strings.lock.badDefault, this.name, `'${config.defaultLockState}'`, printableValues(DefaultLockState));
|
|
12
|
+
}
|
|
10
13
|
this.state = this.defaultLockState;
|
|
11
14
|
this.accessoryService.getCharacteristic(Characteristic.LockTargetState)
|
|
12
15
|
.onGet(this.getState.bind(this))
|
|
@@ -16,11 +19,16 @@ export class LockAccessory extends DummyAccessory {
|
|
|
16
19
|
this.initializeState();
|
|
17
20
|
}
|
|
18
21
|
async initializeState() {
|
|
19
|
-
if (this.isStateful) {
|
|
20
|
-
this.
|
|
22
|
+
if (!this.isStateful) {
|
|
23
|
+
this.accessoryService.updateCharacteristic(this.Characteristic.LockTargetState, this.state);
|
|
24
|
+
this.accessoryService.updateCharacteristic(this.Characteristic.LockCurrentState, this.state);
|
|
25
|
+
return;
|
|
21
26
|
}
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
const state = await storageGet_Deprecated(this.defaultStateStorageKey);
|
|
28
|
+
if (state === undefined) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
await this.setState(state);
|
|
24
32
|
}
|
|
25
33
|
getAccessoryType() {
|
|
26
34
|
return AccessoryType.LockMechanism;
|
|
@@ -52,15 +60,13 @@ export class LockAccessory extends DummyAccessory {
|
|
|
52
60
|
}
|
|
53
61
|
this.state = value;
|
|
54
62
|
if (this.isStateful) {
|
|
55
|
-
await
|
|
63
|
+
await Storage.set(this.defaultStateStorageKey, this.state);
|
|
64
|
+
}
|
|
65
|
+
if (this.state !== this.defaultLockState) {
|
|
66
|
+
this.startTimer();
|
|
56
67
|
}
|
|
57
68
|
else {
|
|
58
|
-
|
|
59
|
-
this.startTimer();
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
this.cancelTimer();
|
|
63
|
-
}
|
|
69
|
+
this.cancelTimer();
|
|
64
70
|
}
|
|
65
71
|
this.accessoryService.updateCharacteristic(this.Characteristic.LockTargetState, this.state);
|
|
66
72
|
this.accessoryService.updateCharacteristic(this.Characteristic.LockCurrentState, this.state);
|
|
@@ -89,7 +95,7 @@ export class LockAccessory extends DummyAccessory {
|
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
logTemplateForCV(value) {
|
|
92
|
-
return value === this.Characteristic.LockTargetState.SECURED ? strings.
|
|
98
|
+
return value === this.Characteristic.LockTargetState.SECURED ? strings.lock.secured : strings.lock.unsecured;
|
|
93
99
|
}
|
|
94
100
|
logLockState(value) {
|
|
95
101
|
this.logIfDesired(this.logTemplateForCV(value));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock.js","sourceRoot":"","sources":["../../src/accessory/lock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAO,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"lock.js","sourceRoot":"","sources":["../../src/accessory/lock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,OAAO,EAA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;QAC/C,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;IAClD,CAAC;CACF"}
|
|
@@ -6,7 +6,7 @@ import { Webhook } from '../../model/webhook.js';
|
|
|
6
6
|
import { Log } from '../../tools/log.js';
|
|
7
7
|
export declare class LightbulbAccessory extends OnOffAccessory<LightbulbConfig> {
|
|
8
8
|
private brightness;
|
|
9
|
-
constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: LightbulbConfig, log: Log,
|
|
9
|
+
constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: LightbulbConfig, log: Log, isGrouped: boolean);
|
|
10
10
|
private get isDimmer();
|
|
11
11
|
private get defaultBrightnessStorageKey();
|
|
12
12
|
getAccessoryType(): AccessoryType;
|