@uboness/homebridge-mqtt 0.0.3 → 0.0.5
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 +4 -0
- package/README.md +129 -15
- package/dist/service/Fan.d.ts +2 -2
- package/dist/service/Fan.d.ts.map +1 -1
- package/dist/service/Fan.js +50 -6
- package/dist/service/Fan.js.map +1 -1
- package/dist/service/MqttService.d.ts +5 -0
- package/dist/service/MqttService.d.ts.map +1 -1
- package/dist/service/StatefulScene.d.ts +12 -0
- package/dist/service/StatefulScene.d.ts.map +1 -0
- package/dist/service/StatefulScene.js +27 -0
- package/dist/service/StatefulScene.js.map +1 -0
- package/dist/service/StatelessScene.d.ts +12 -0
- package/dist/service/StatelessScene.d.ts.map +1 -0
- package/dist/service/StatelessScene.js +27 -0
- package/dist/service/StatelessScene.js.map +1 -0
- package/dist/service/characteristic/active.d.ts +1 -1
- package/dist/service/characteristic/active.d.ts.map +1 -1
- package/dist/service/characteristic/archetype/BooleanValue.d.ts +13 -7
- package/dist/service/characteristic/archetype/BooleanValue.d.ts.map +1 -1
- package/dist/service/characteristic/archetype/BooleanValue.js +15 -6
- package/dist/service/characteristic/archetype/BooleanValue.js.map +1 -1
- package/dist/service/characteristic/archetype/Converter.d.ts +2 -1
- package/dist/service/characteristic/archetype/Converter.d.ts.map +1 -1
- package/dist/service/characteristic/archetype/Converter.js +23 -6
- package/dist/service/characteristic/archetype/Converter.js.map +1 -1
- package/dist/service/characteristic/archetype/EnumValue.d.ts +12 -7
- package/dist/service/characteristic/archetype/EnumValue.d.ts.map +1 -1
- package/dist/service/characteristic/archetype/EnumValue.js +14 -6
- package/dist/service/characteristic/archetype/EnumValue.js.map +1 -1
- package/dist/service/characteristic/archetype/NumericValue.d.ts.map +1 -1
- package/dist/service/characteristic/archetype/NumericValue.js +7 -11
- package/dist/service/characteristic/archetype/NumericValue.js.map +1 -1
- package/dist/service/characteristic/archetype/OneZeroValue.d.ts +14 -8
- package/dist/service/characteristic/archetype/OneZeroValue.d.ts.map +1 -1
- package/dist/service/characteristic/archetype/OneZeroValue.js +24 -9
- package/dist/service/characteristic/archetype/OneZeroValue.js.map +1 -1
- package/dist/service/characteristic/archetype/common.d.ts +3 -3
- package/dist/service/characteristic/archetype/common.d.ts.map +1 -1
- package/dist/service/characteristic/archetype/common.js +3 -0
- package/dist/service/characteristic/archetype/common.js.map +1 -1
- package/dist/service/characteristic/carbonDioxideDetected.d.ts +1 -1
- package/dist/service/characteristic/carbonDioxideDetected.d.ts.map +1 -1
- package/dist/service/characteristic/carbonMonoxideDetected.d.ts +1 -1
- package/dist/service/characteristic/carbonMonoxideDetected.d.ts.map +1 -1
- package/dist/service/characteristic/chargingState.d.ts +1 -1
- package/dist/service/characteristic/chargingState.d.ts.map +1 -1
- package/dist/service/characteristic/contactSensorState.d.ts +1 -1
- package/dist/service/characteristic/contactSensorState.d.ts.map +1 -1
- package/dist/service/characteristic/index.d.ts +5 -3
- package/dist/service/characteristic/index.d.ts.map +1 -1
- package/dist/service/characteristic/index.js +3 -1
- package/dist/service/characteristic/index.js.map +1 -1
- package/dist/service/characteristic/leakDetected.d.ts +1 -1
- package/dist/service/characteristic/leakDetected.d.ts.map +1 -1
- package/dist/service/characteristic/lockPhysicalControls.d.ts +1 -1
- package/dist/service/characteristic/lockPhysicalControls.d.ts.map +1 -1
- package/dist/service/characteristic/lockTargetState.d.ts +1 -1
- package/dist/service/characteristic/lockTargetState.d.ts.map +1 -1
- package/dist/service/characteristic/momentaryOn.d.ts +10 -0
- package/dist/service/characteristic/momentaryOn.d.ts.map +1 -0
- package/dist/service/characteristic/momentaryOn.js +21 -0
- package/dist/service/characteristic/momentaryOn.js.map +1 -0
- package/dist/service/characteristic/motionDetected.d.ts +1 -1
- package/dist/service/characteristic/motionDetected.d.ts.map +1 -1
- package/dist/service/characteristic/mute.d.ts +1 -1
- package/dist/service/characteristic/mute.d.ts.map +1 -1
- package/dist/service/characteristic/obstructionDetected.d.ts +1 -1
- package/dist/service/characteristic/obstructionDetected.d.ts.map +1 -1
- package/dist/service/characteristic/occupancyDetected.d.ts +1 -1
- package/dist/service/characteristic/occupancyDetected.d.ts.map +1 -1
- package/dist/service/characteristic/on.d.ts +1 -1
- package/dist/service/characteristic/on.d.ts.map +1 -1
- package/dist/service/characteristic/outletInUse.d.ts +1 -1
- package/dist/service/characteristic/outletInUse.d.ts.map +1 -1
- package/dist/service/characteristic/rotationDirection.d.ts +1 -1
- package/dist/service/characteristic/rotationDirection.d.ts.map +1 -1
- package/dist/service/characteristic/rotationSpeed.d.ts +1 -1
- package/dist/service/characteristic/rotationSpeed.d.ts.map +1 -1
- package/dist/service/characteristic/rotationSpeed.js +10 -4
- package/dist/service/characteristic/rotationSpeed.js.map +1 -1
- package/dist/service/characteristic/smokeDetected.d.ts +1 -1
- package/dist/service/characteristic/smokeDetected.d.ts.map +1 -1
- package/dist/service/characteristic/statusFault.d.ts +1 -1
- package/dist/service/characteristic/statusFault.d.ts.map +1 -1
- package/dist/service/characteristic/statusLowBattery.d.ts +1 -1
- package/dist/service/characteristic/statusLowBattery.d.ts.map +1 -1
- package/dist/service/characteristic/statusTampered.d.ts +1 -1
- package/dist/service/characteristic/statusTampered.d.ts.map +1 -1
- package/dist/service/characteristic/stickyOn.d.ts +11 -0
- package/dist/service/characteristic/stickyOn.d.ts.map +1 -0
- package/dist/service/characteristic/stickyOn.js +29 -0
- package/dist/service/characteristic/stickyOn.js.map +1 -0
- package/dist/service/characteristic/swingMode.d.ts +1 -1
- package/dist/service/characteristic/swingMode.d.ts.map +1 -1
- package/dist/service/characteristic/targetFanState.d.ts +1 -1
- package/dist/service/characteristic/targetFanState.d.ts.map +1 -1
- package/dist/service/characteristic/temperatureDisplayUnits.d.ts +1 -1
- package/dist/service/characteristic/temperatureDisplayUnits.d.ts.map +1 -1
- package/dist/service/index.d.ts.map +1 -1
- package/dist/service/index.js +4 -0
- package/dist/service/index.js.map +1 -1
- package/dist/service/until.d.ts +3 -3
- package/dist/service/until.d.ts.map +1 -1
- package/dist/service/until.js +8 -2
- package/dist/service/until.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [0.0.5](https://github.com/uboness/{{name}}/compare/v0.0.4...v0.0.5) (2025-01-26)
|
|
6
|
+
|
|
7
|
+
## [0.0.4](https://github.com/uboness/{{name}}/compare/v0.0.3...v0.0.4) (2025-01-26)
|
|
8
|
+
|
|
5
9
|
## [0.0.3](https://github.com/uboness/{{name}}/compare/v0.0.2...v0.0.3) (2025-01-25)
|
|
6
10
|
|
|
7
11
|
## [0.0.2](https://github.com/uboness/{{name}}/compare/v0.0.1...v0.0.2) (2025-01-25)
|
package/README.md
CHANGED
|
@@ -1307,13 +1307,35 @@ Other values can be converted using a converter (as shown below).
|
|
|
1307
1307
|
"topics": {
|
|
1308
1308
|
"lockTargetState": {
|
|
1309
1309
|
"get": "<read_topic>",
|
|
1310
|
-
"
|
|
1310
|
+
"set": "<write_topic>",
|
|
1311
1311
|
"converter"?: "boolean" | { "secured": "<value indicating 'secured'>", "unsecured": "value indicating 'unsecured'" } // a boolean 'true' indicates 'secured'
|
|
1312
1312
|
}
|
|
1313
1313
|
}
|
|
1314
1314
|
}
|
|
1315
1315
|
```
|
|
1316
1316
|
|
|
1317
|
+
|
|
1318
|
+
### <code style="color: green">momentaryOn</code>
|
|
1319
|
+
|
|
1320
|
+
This is a special case of an 'on' characteristic when turned on it immediately turns back off.
|
|
1321
|
+
When turned on, it publishes the configured value to the configured topic.
|
|
1322
|
+
|
|
1323
|
+
#### Services
|
|
1324
|
+
- [stateless-scene](#stateless-scene)
|
|
1325
|
+
|
|
1326
|
+
#### Configuration
|
|
1327
|
+
|
|
1328
|
+
```typescript
|
|
1329
|
+
{
|
|
1330
|
+
"topics": {
|
|
1331
|
+
"momentaryOn": {
|
|
1332
|
+
"get": "<read_topic>",
|
|
1333
|
+
"value": number | string | boolean // the published value
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
```
|
|
1338
|
+
|
|
1317
1339
|
### <code style="color: green">motionDetected</code>
|
|
1318
1340
|
|
|
1319
1341
|
Indicates if a sensor detected motion. By default, will look for `true` (indicating "detected")
|
|
@@ -1944,6 +1966,29 @@ This characteristic is optional on all sensor services.
|
|
|
1944
1966
|
}
|
|
1945
1967
|
```
|
|
1946
1968
|
|
|
1969
|
+
### <code style="color: green">stickyOn</code>
|
|
1970
|
+
|
|
1971
|
+
This is a special case of an 'on' characteristic that is associated with a value. When turned on,
|
|
1972
|
+
it publishes this value to the configured `set` topic, and it stays turned on until it receives a
|
|
1973
|
+
different value from the configured `get` topic. Trying to force it off will cause it to "silently" turn back
|
|
1974
|
+
on ("silently" in that it will not publish the value to the `set` topic).
|
|
1975
|
+
|
|
1976
|
+
#### Services
|
|
1977
|
+
- [stateful-scene](#stateful-scene)
|
|
1978
|
+
|
|
1979
|
+
#### Configuration
|
|
1980
|
+
|
|
1981
|
+
```typescript
|
|
1982
|
+
{
|
|
1983
|
+
"topics": {
|
|
1984
|
+
"stickyOn": {
|
|
1985
|
+
"get": "<read_topic>",
|
|
1986
|
+
"set": "<write_topic>",
|
|
1987
|
+
"value": number | string | boolean // the published value
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
```
|
|
1947
1992
|
|
|
1948
1993
|
### <code style="color: green">swingMode</code>
|
|
1949
1994
|
|
|
@@ -2310,6 +2355,8 @@ Other values can be converted using the [Percentages](#percentages-) converter.
|
|
|
2310
2355
|
- [security-system](#security-system)
|
|
2311
2356
|
- [smoke-sensor](#smoke-sensor)
|
|
2312
2357
|
- [speaker](#speaker)
|
|
2358
|
+
- [stateful-scene](#stateful-scene)
|
|
2359
|
+
- [stateless-scene](#stateless-scene)
|
|
2313
2360
|
- [switch](#switch)
|
|
2314
2361
|
- [temperature-sensor](#temperature-sensor)
|
|
2315
2362
|
- [thermostat](#thermostat)
|
|
@@ -2679,11 +2726,11 @@ Characteristics:
|
|
|
2679
2726
|
### fan
|
|
2680
2727
|
|
|
2681
2728
|
Characteristics:
|
|
2682
|
-
- [active](#code-stylecolor-greenactivecode) (required)
|
|
2683
|
-
- [
|
|
2684
|
-
- [
|
|
2729
|
+
- [active](#code-stylecolor-greenactivecode) (required if `rotationSpeed` is not configured)
|
|
2730
|
+
- [rotationSpeed](#code-stylecolor-greenrotationSpeedcode) (required if `active` is not configured)
|
|
2731
|
+
- [currentState](#code-stylecolor-greencurrentFanStatecode) (optional) (can also be `currentFanState`)
|
|
2732
|
+
- [targetState](#code-stylecolor-greentargetFanStatecode) (optional) (can also be `targetFanState`)
|
|
2685
2733
|
- [rotationDirection](#code-stylecolor-greenrotationDirectioncode) (optional)
|
|
2686
|
-
- [rotationSpeed](#code-stylecolor-greenrotationSpeedcode) (optional)
|
|
2687
2734
|
- [swingMode](#code-stylecolor-greenswingModecode) (optional)
|
|
2688
2735
|
- [lockPhysicalControls](#code-stylecolor-greenlockPhysicalControlscode) (optional)
|
|
2689
2736
|
- [statusFault](#code-stylecolor-greenstatusFaultcode) (optional)
|
|
@@ -2694,12 +2741,17 @@ Characteristics:
|
|
|
2694
2741
|
"name": "<custom name>",
|
|
2695
2742
|
"type": "fan",
|
|
2696
2743
|
"topics": {
|
|
2697
|
-
"active": { //required
|
|
2744
|
+
"active": { // required if 'rotationSpeed' is not configured
|
|
2698
2745
|
"get": "<read_topic>",
|
|
2699
2746
|
"set": "<write_topic>",
|
|
2700
|
-
"converter"?: "boolean" | { "
|
|
2747
|
+
"converter"?: "boolean" | { "on": "'active' state value'", "off": "'inactive' state value" }
|
|
2701
2748
|
},
|
|
2702
|
-
"
|
|
2749
|
+
"rotationSpeed"?: { // required if 'active' is not configured
|
|
2750
|
+
"get": "<read_topic>",
|
|
2751
|
+
"set": "<write_topic>",
|
|
2752
|
+
"converter"?: "decimal" | { "min": <number>, "max": <number> } | <number> | string[]
|
|
2753
|
+
},
|
|
2754
|
+
"currentState"?: { // optional
|
|
2703
2755
|
"get": "<read_topic>",
|
|
2704
2756
|
"converter"?: {
|
|
2705
2757
|
"inactive"?: "'inactive' state value",
|
|
@@ -2707,7 +2759,7 @@ Characteristics:
|
|
|
2707
2759
|
"blowingAir"?: "'blowing air' state value"
|
|
2708
2760
|
}
|
|
2709
2761
|
},
|
|
2710
|
-
"targetState"
|
|
2762
|
+
"targetState"?: { // optional
|
|
2711
2763
|
"get": "<read_topic>",
|
|
2712
2764
|
"set": "<write_topic>",
|
|
2713
2765
|
"converter"?: { "auto": "'auto' state value", "manual": "'manual' state value"}
|
|
@@ -2717,11 +2769,6 @@ Characteristics:
|
|
|
2717
2769
|
"set": "<write_topic>",
|
|
2718
2770
|
"converter"?: { "clockwise": "value representing 'clockwise'", "counter-clockwise": "value representing 'counter-clockwise'" }
|
|
2719
2771
|
},
|
|
2720
|
-
"rotationSpeed"?: { // optional
|
|
2721
|
-
"get": "<read_topic>",
|
|
2722
|
-
"set": "<write_topic>",
|
|
2723
|
-
"converter"?: "decimal" | { "min": <number>, "max": <number> } | <number> | string[]
|
|
2724
|
-
},
|
|
2725
2772
|
"swingMode"?: { // optional
|
|
2726
2773
|
"get": "<read_topic>",
|
|
2727
2774
|
"set": "<write_topic>",
|
|
@@ -3289,6 +3336,73 @@ Characteristics:
|
|
|
3289
3336
|
}
|
|
3290
3337
|
```
|
|
3291
3338
|
|
|
3339
|
+
### stateful-scene
|
|
3340
|
+
|
|
3341
|
+
This can be a useful tool to implement a multi-state switch over a single topic. For example,
|
|
3342
|
+
if there is a device that can have 3 states = `off`, `low` and `high`. These states are published
|
|
3343
|
+
to a single topic. You can then set up a `stateful-scene` device. The primary service will
|
|
3344
|
+
represent the `off` state, and two additional `stateful-scene` sub-services will represent the other
|
|
3345
|
+
`low` and `high` states. This will translate to a HomeKit grouped accessory with 3 switches where
|
|
3346
|
+
only the switch representing the current state can be on at any given time. Trying to turn it off
|
|
3347
|
+
will fail - it will only turn off if you turn on any of the other switches (which effectively changing
|
|
3348
|
+
the state of the device).
|
|
3349
|
+
|
|
3350
|
+
Characteristics:
|
|
3351
|
+
- [stickyOn](#code-stylecolor-greenstickyOncode) (required)
|
|
3352
|
+
- [statusFault](#code-stylecolor-greenstatusFaultcode) (optional)
|
|
3353
|
+
- [faultMessage](#code-stylecolor-greenfaultMessagecode) (optional)
|
|
3354
|
+
|
|
3355
|
+
```json
|
|
3356
|
+
{
|
|
3357
|
+
"name": "<custom name>",
|
|
3358
|
+
"type": "speaker",
|
|
3359
|
+
"topics": {
|
|
3360
|
+
"stickyOn": { // required
|
|
3361
|
+
"get": "<read_topic>",
|
|
3362
|
+
"set": "<write_topic>",
|
|
3363
|
+
"value": string | number | boolean // the published value
|
|
3364
|
+
},
|
|
3365
|
+
"statusFault"?: { // optional
|
|
3366
|
+
"get": "<read_topic>",
|
|
3367
|
+
"converter"?: "boolean" | { "on": "'fault' value", "off": "'no fault' value"}
|
|
3368
|
+
},
|
|
3369
|
+
"faultMessage"?: { // optional
|
|
3370
|
+
"get": "<topic>"
|
|
3371
|
+
}
|
|
3372
|
+
}
|
|
3373
|
+
}
|
|
3374
|
+
```
|
|
3375
|
+
|
|
3376
|
+
### stateless-scene
|
|
3377
|
+
|
|
3378
|
+
This can be useful to define a device that simply triggers a scene. It only publishes a value and
|
|
3379
|
+
ignores any other values that are published on the MQTT broker.
|
|
3380
|
+
|
|
3381
|
+
Characteristics:
|
|
3382
|
+
- [momentaryOn](#code-stylecolor-greenmomentaryOncode) (required)
|
|
3383
|
+
- [statusFault](#code-stylecolor-greenstatusFaultcode) (optional)
|
|
3384
|
+
- [faultMessage](#code-stylecolor-greenfaultMessagecode) (optional)
|
|
3385
|
+
|
|
3386
|
+
```json
|
|
3387
|
+
{
|
|
3388
|
+
"name": "<custom name>",
|
|
3389
|
+
"type": "speaker",
|
|
3390
|
+
"topics": {
|
|
3391
|
+
"momentaryOn": { // required
|
|
3392
|
+
"set": "<write_topic>",
|
|
3393
|
+
"value": string | number | boolean // the published value
|
|
3394
|
+
},
|
|
3395
|
+
"statusFault"?: { // optional
|
|
3396
|
+
"get": "<read_topic>",
|
|
3397
|
+
"converter"?: "boolean" | { "on": "'fault' value", "off": "'no fault' value"}
|
|
3398
|
+
},
|
|
3399
|
+
"faultMessage"?: { // optional
|
|
3400
|
+
"get": "<topic>"
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
3404
|
+
```
|
|
3405
|
+
|
|
3292
3406
|
### switch
|
|
3293
3407
|
|
|
3294
3408
|
Characteristics:
|
|
@@ -3299,7 +3413,7 @@ Characteristics:
|
|
|
3299
3413
|
```json
|
|
3300
3414
|
{
|
|
3301
3415
|
"name": "<custom name>",
|
|
3302
|
-
"type": "
|
|
3416
|
+
"type": "switch",
|
|
3303
3417
|
"topics": {
|
|
3304
3418
|
"on": { // required
|
|
3305
3419
|
"get": "<read_topic>",
|
package/dist/service/Fan.d.ts
CHANGED
|
@@ -5,11 +5,11 @@ export declare namespace Fan {
|
|
|
5
5
|
type Config = {
|
|
6
6
|
type: typeof TYPE;
|
|
7
7
|
name: string;
|
|
8
|
-
topics: Active & Partial<CurrentFanState> & {
|
|
8
|
+
topics: Partial<Active> & Partial<RotationSpeed> & Partial<CurrentFanState> & {
|
|
9
9
|
currentState?: CurrentFanState['currentFanState'];
|
|
10
10
|
} & Partial<TargetFanState> & {
|
|
11
11
|
targetState?: TargetFanState['targetFanState'];
|
|
12
|
-
} & Partial<RotationDirection> & Partial<
|
|
12
|
+
} & Partial<RotationDirection> & Partial<SwingMode> & Partial<LockPhysicalControls> & MqttService.StandardTopics;
|
|
13
13
|
};
|
|
14
14
|
const create: MqttService.Factory;
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fan.d.ts","sourceRoot":"","sources":["../../src/service/Fan.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Fan.d.ts","sourceRoot":"","sources":["../../src/service/Fan.ts"],"names":[],"mappings":"AAGA,OAAO,EAEH,MAAM,EAEN,eAAe,EAGf,oBAAoB,EAEpB,iBAAiB,EAEjB,aAAa,EAEb,SAAS,EAET,cAAc,EACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,yBAAiB,GAAG,CAAC;IAEV,MAAM,IAAI,OAAiB,CAAC;IAEnC,KAAY,MAAM,GAAG;QACjB,IAAI,EAAE,OAAO,IAAI,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAGF,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,GAExC,OAAO,CAAC,eAAe,CAAC,GAAG;YAAE,YAAY,CAAC,EAAE,eAAe,CAAC,iBAAiB,CAAC,CAAA;SAAE,GAChF,OAAO,CAAC,cAAc,CAAC,GAAG;YAAE,WAAW,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAA;SAAE,GAC5E,OAAO,CAAC,iBAAiB,CAAC,GAC1B,OAAO,CAAC,SAAS,CAAC,GAClB,OAAO,CAAC,oBAAoB,CAAC,GAC7B,WAAW,CAAC,cAAc,CAAA;KACjC,CAAA;IAEM,MAAM,MAAM,EAAE,WAAW,CAAC,OA6DhC,CAAC;CA+BL"}
|
package/dist/service/Fan.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Fan = void 0;
|
|
4
|
+
const common_js_1 = require("../common.js");
|
|
4
5
|
const index_js_1 = require("./characteristic/index.js");
|
|
5
6
|
const until_js_1 = require("./until.js");
|
|
6
7
|
var Fan;
|
|
@@ -13,10 +14,27 @@ var Fan;
|
|
|
13
14
|
}
|
|
14
15
|
const config = serviceConfig;
|
|
15
16
|
const { service, cleanup, online, ctx } = await (0, until_js_1.defineService)(platform, mqtt, accessory, platform.Service.Fanv2, serviceConfig, primary);
|
|
16
|
-
if (!config.topics.active) {
|
|
17
|
-
throw new Error(`Could not create Fan service [${config.name}] for device [${accessory.context.deviceId}].
|
|
17
|
+
if (!config.topics.active && !config.topics.rotationSpeed) {
|
|
18
|
+
throw new Error(`Could not create Fan service [${config.name}] for device [${accessory.context.deviceId}]. Either 'active' or 'rotationSpeed' topics must be defined`);
|
|
19
|
+
}
|
|
20
|
+
let activeChar;
|
|
21
|
+
if (config.topics.active) {
|
|
22
|
+
activeChar = await (0, index_js_1.active)(platform, mqtt, accessory, service, config.topics.active, ctx);
|
|
23
|
+
cleanup.push(activeChar);
|
|
24
|
+
}
|
|
25
|
+
let speedChar;
|
|
26
|
+
if (config.topics.rotationSpeed) {
|
|
27
|
+
speedChar = await (0, index_js_1.rotationSpeed)(platform, mqtt, accessory, service, config.topics.rotationSpeed, ctx);
|
|
28
|
+
cleanup.push(speedChar);
|
|
29
|
+
}
|
|
30
|
+
if (!activeChar && speedChar) {
|
|
31
|
+
activeChar = defaultActiveCharacteristic(platform, service, speedChar);
|
|
32
|
+
cleanup.push(activeChar);
|
|
33
|
+
}
|
|
34
|
+
if (!speedChar && activeChar) {
|
|
35
|
+
speedChar = defaultSpeedCharacteristic(platform, service, activeChar);
|
|
36
|
+
cleanup.push(speedChar);
|
|
18
37
|
}
|
|
19
|
-
cleanup.push(await (0, index_js_1.active)(platform, mqtt, accessory, service, config.topics.active, ctx));
|
|
20
38
|
if (config.topics.currentFanState || config.topics.currentState) {
|
|
21
39
|
const charConfig = (_a = config.topics.currentFanState) !== null && _a !== void 0 ? _a : config.topics.currentState;
|
|
22
40
|
cleanup.push(await (0, index_js_1.currentFanState)(platform, mqtt, accessory, service, charConfig, ctx));
|
|
@@ -28,9 +46,6 @@ var Fan;
|
|
|
28
46
|
if (config.topics.rotationDirection) {
|
|
29
47
|
cleanup.push(await (0, index_js_1.rotationDirection)(platform, mqtt, accessory, service, config.topics.rotationDirection, ctx));
|
|
30
48
|
}
|
|
31
|
-
if (config.topics.rotationSpeed) {
|
|
32
|
-
cleanup.push(await (0, index_js_1.rotationSpeed)(platform, mqtt, accessory, service, config.topics.rotationSpeed, ctx));
|
|
33
|
-
}
|
|
34
49
|
if (config.topics.swingMode) {
|
|
35
50
|
cleanup.push(await (0, index_js_1.swingMode)(platform, mqtt, accessory, service, config.topics.swingMode, ctx));
|
|
36
51
|
}
|
|
@@ -44,5 +59,34 @@ var Fan;
|
|
|
44
59
|
setConnected: value => online.setValue(value)
|
|
45
60
|
};
|
|
46
61
|
};
|
|
62
|
+
const defaultActiveCharacteristic = (platform, service, speed) => {
|
|
63
|
+
var _a;
|
|
64
|
+
const active = (_a = service.getCharacteristic(platform.Characteristic.Active)) !== null && _a !== void 0 ? _a : service.addCharacteristic(platform.Characteristic.Active);
|
|
65
|
+
active.onSet((value, ctx) => {
|
|
66
|
+
if (!(ctx === null || ctx === void 0 ? void 0 : ctx.fromSpeed) && !value) {
|
|
67
|
+
(0, common_js_1.nextTick)(() => speed.setValue(0));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const detachable = speed.on('set', value => {
|
|
71
|
+
(0, common_js_1.nextTick)(() => active.updateValue(value !== 0, { fromSpeed: true }));
|
|
72
|
+
});
|
|
73
|
+
return index_js_1.DetachableCharacteristic.mixin(active, detachable);
|
|
74
|
+
};
|
|
75
|
+
const defaultSpeedCharacteristic = (platform, service, active) => {
|
|
76
|
+
var _a;
|
|
77
|
+
const speed = (_a = service.getCharacteristic(platform.Characteristic.RotationSpeed)) !== null && _a !== void 0 ? _a : service.addCharacteristic(platform.Characteristic.RotationSpeed)
|
|
78
|
+
.setProps({
|
|
79
|
+
minValue: 0,
|
|
80
|
+
maxValue: 100,
|
|
81
|
+
minStep: 100
|
|
82
|
+
});
|
|
83
|
+
speed.onSet(value => {
|
|
84
|
+
active.setValue(value !== 0);
|
|
85
|
+
});
|
|
86
|
+
const detachable = active.on('set', value => {
|
|
87
|
+
speed.updateValue(value ? 100 : 0);
|
|
88
|
+
});
|
|
89
|
+
return index_js_1.DetachableCharacteristic.mixin(speed, detachable);
|
|
90
|
+
};
|
|
47
91
|
})(Fan = exports.Fan || (exports.Fan = {}));
|
|
48
92
|
//# sourceMappingURL=Fan.js.map
|
package/dist/service/Fan.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fan.js","sourceRoot":"","sources":["../../src/service/Fan.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Fan.js","sourceRoot":"","sources":["../../src/service/Fan.ts"],"names":[],"mappings":";;;AACA,4CAAkD;AAElD,wDAgBmC;AAEnC,yCAA2C;AAE3C,IAAiB,GAAG,CAgHnB;AAhHD,WAAiB,GAAG;IAEH,QAAI,GAAG,KAAc,CAAC;IAkBtB,UAAM,GAAwB,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,EAAE;;QACnG,IAAI,aAAa,CAAC,IAAI,KAAK,IAAA,IAAI,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAA,IAAI,UAAU,CAAC,CAAC;SAC7D;QACD,MAAM,MAAM,GAAG,aAA2B,CAAC;QAE3C,MAAM,EACF,OAAO,EACP,OAAO,EACP,MAAM,EACN,GAAG,EACN,GAAG,MAAM,IAAA,wBAAa,EAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;QAEnG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE;YACvD,MAAM,IAAI,KAAK,CAAC,iCAAiC,MAAM,CAAC,IAAI,iBAAiB,SAAS,CAAC,OAAO,CAAC,QAAQ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AAC;QACP,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;YAChB,MAAM,CAAC,QAAQ,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE;YACxC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;QACH,OAAO,mCAAwB,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAC7D,CAAC,CAAC;AAEN,CAAC,EAhHgB,GAAG,GAAH,WAAG,KAAH,WAAG,QAgHnB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import EventEmitter from 'events';
|
|
1
3
|
import { PlatformAccessory, Service } from 'homebridge';
|
|
2
4
|
import { Mqtt } from '../Mqtt.js';
|
|
3
5
|
import { MqttPlatform } from '../MqttPlatform.js';
|
|
@@ -9,6 +11,9 @@ export type MqttService<Config extends MqttService.Config = MqttService.Config>
|
|
|
9
11
|
setConnected: (connected: boolean) => void;
|
|
10
12
|
};
|
|
11
13
|
export declare namespace MqttService {
|
|
14
|
+
type Context = {
|
|
15
|
+
emitter: EventEmitter;
|
|
16
|
+
};
|
|
12
17
|
type StandardTopics = Partial<StatusFault> & Partial<FaultMessage>;
|
|
13
18
|
type StandardSensorTopics = StandardTopics & Partial<StatusLowBattery> & Partial<StatusTampered>;
|
|
14
19
|
type Config = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MqttService.d.ts","sourceRoot":"","sources":["../../src/service/MqttService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OA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E,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;CAExN"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StickyOn } from './characteristic/index.js';
|
|
2
|
+
import { MqttService } from './MqttService.js';
|
|
3
|
+
export declare namespace StatefulScene {
|
|
4
|
+
const TYPE: "stateful-scene";
|
|
5
|
+
type Config = MqttService.Config & {
|
|
6
|
+
type: typeof TYPE;
|
|
7
|
+
name: string;
|
|
8
|
+
topics: StickyOn & MqttService.StandardTopics;
|
|
9
|
+
};
|
|
10
|
+
const create: MqttService.Factory;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=StatefulScene.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatefulScene.d.ts","sourceRoot":"","sources":["../../src/service/StatefulScene.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,yBAAiB,aAAa,CAAC;IAEpB,MAAM,IAAI,kBAA4B,CAAC;IAE9C,KAAY,MAAM,GAAG,WAAW,CAAC,MAAM,GAAG;QACtC,IAAI,EAAE,OAAO,IAAI,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,QAAQ,GAAG,WAAW,CAAC,cAAc,CAAA;KAChD,CAAC;IAEK,MAAM,MAAM,EAAE,WAAW,CAAC,OAmBhC,CAAC;CACL"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StatefulScene = void 0;
|
|
4
|
+
const index_js_1 = require("./characteristic/index.js");
|
|
5
|
+
const until_js_1 = require("./until.js");
|
|
6
|
+
var StatefulScene;
|
|
7
|
+
(function (StatefulScene) {
|
|
8
|
+
StatefulScene.TYPE = 'stateful-scene';
|
|
9
|
+
StatefulScene.create = async (platform, mqtt, accessory, serviceConfig, primary) => {
|
|
10
|
+
if (serviceConfig.type !== StatefulScene.TYPE) {
|
|
11
|
+
throw new Error(`StatelessScene factory expects a '${StatefulScene.TYPE}' config`);
|
|
12
|
+
}
|
|
13
|
+
const config = serviceConfig;
|
|
14
|
+
const { service, cleanup, online, ctx } = await (0, until_js_1.defineService)(platform, mqtt, accessory, platform.Service.Switch, serviceConfig, primary);
|
|
15
|
+
if (!config.topics.stickyOn) {
|
|
16
|
+
throw new Error(`Could not create Button service [${config.name}] for device [${accessory.context.deviceId}]. Missing 'stickyOn' topics`);
|
|
17
|
+
}
|
|
18
|
+
cleanup.push(await (0, index_js_1.stickyOn)(platform, mqtt, accessory, service, config.topics.stickyOn, ctx));
|
|
19
|
+
return {
|
|
20
|
+
config,
|
|
21
|
+
hap: service,
|
|
22
|
+
dispose: () => cleanup.detach(),
|
|
23
|
+
setConnected: value => online.setValue(value)
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
})(StatefulScene = exports.StatefulScene || (exports.StatefulScene = {}));
|
|
27
|
+
//# sourceMappingURL=StatefulScene.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatefulScene.js","sourceRoot":"","sources":["../../src/service/StatefulScene.ts"],"names":[],"mappings":";;;AAAA,wDAAyF;AAEzF,yCAA2C;AAE3C,IAAiB,aAAa,CA8B7B;AA9BD,WAAiB,aAAa;IAEb,kBAAI,GAAG,gBAAyB,CAAC;IAQjC,oBAAM,GAAwB,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,EAAE;QACnG,IAAI,aAAa,CAAC,IAAI,KAAK,cAAA,IAAI,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,qCAAqC,cAAA,IAAI,UAAU,CAAC,CAAC;SACxE;QACD,MAAM,MAAM,GAAG,aAAuB,CAAC;QAEvC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,IAAA,wBAAa,EAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;QAE1I,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,oCAAoC,MAAM,CAAC,IAAI,iBAAiB,SAAS,CAAC,OAAO,CAAC,QAAQ,8BAA8B,CAAC,CAAC;SAC7I;QACD,OAAO,CAAC,IAAI,CAAC,MAAM,IAAA,mBAAQ,EAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;QAE9F,OAAO;YACH,MAAM;YACN,GAAG,EAAE,OAAO;YACZ,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE;YAC/B,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;SAChD,CAAC;IACN,CAAC,CAAC;AACN,CAAC,EA9BgB,aAAa,GAAb,qBAAa,KAAb,qBAAa,QA8B7B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MomentaryOn } from './characteristic/index.js';
|
|
2
|
+
import { MqttService } from './MqttService.js';
|
|
3
|
+
export declare namespace StatelessScene {
|
|
4
|
+
const TYPE: "stateless-scene";
|
|
5
|
+
type Config = MqttService.Config & {
|
|
6
|
+
type: typeof TYPE;
|
|
7
|
+
name: string;
|
|
8
|
+
topics: MomentaryOn & MqttService.StandardTopics;
|
|
9
|
+
};
|
|
10
|
+
const create: MqttService.Factory;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=StatelessScene.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatelessScene.d.ts","sourceRoot":"","sources":["../../src/service/StatelessScene.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,yBAAiB,cAAc,CAAC;IAErB,MAAM,IAAI,mBAA6B,CAAC;IAE/C,KAAY,MAAM,GAAG,WAAW,CAAC,MAAM,GAAG;QACtC,IAAI,EAAE,OAAO,IAAI,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EACF,WAAW,GACX,WAAW,CAAC,cAAc,CAAA;KACjC,CAAC;IAEK,MAAM,MAAM,EAAE,WAAW,CAAC,OAmBhC,CAAC;CACL"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StatelessScene = void 0;
|
|
4
|
+
const index_js_1 = require("./characteristic/index.js");
|
|
5
|
+
const until_js_1 = require("./until.js");
|
|
6
|
+
var StatelessScene;
|
|
7
|
+
(function (StatelessScene) {
|
|
8
|
+
StatelessScene.TYPE = 'stateless-scene';
|
|
9
|
+
StatelessScene.create = async (platform, mqtt, accessory, serviceConfig, primary) => {
|
|
10
|
+
if (serviceConfig.type !== StatelessScene.TYPE) {
|
|
11
|
+
throw new Error(`StatelessScene factory expects a '${StatelessScene.TYPE}' config`);
|
|
12
|
+
}
|
|
13
|
+
const config = serviceConfig;
|
|
14
|
+
const { service, cleanup, online, ctx } = await (0, until_js_1.defineService)(platform, mqtt, accessory, platform.Service.Switch, serviceConfig, primary);
|
|
15
|
+
if (!config.topics.momentaryOn) {
|
|
16
|
+
throw new Error(`Could not create Button service [${config.name}] for device [${accessory.context.deviceId}]. Missing 'momentaryOn' topics`);
|
|
17
|
+
}
|
|
18
|
+
cleanup.push(await (0, index_js_1.momentaryOn)(platform, mqtt, accessory, service, config.topics.momentaryOn, ctx));
|
|
19
|
+
return {
|
|
20
|
+
config,
|
|
21
|
+
hap: service,
|
|
22
|
+
dispose: () => cleanup.detach(),
|
|
23
|
+
setConnected: value => online.setValue(value)
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
})(StatelessScene = exports.StatelessScene || (exports.StatelessScene = {}));
|
|
27
|
+
//# sourceMappingURL=StatelessScene.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatelessScene.js","sourceRoot":"","sources":["../../src/service/StatelessScene.ts"],"names":[],"mappings":";;;AAAA,wDAAqE;AAErE,yCAA2C;AAE3C,IAAiB,cAAc,CAgC9B;AAhCD,WAAiB,cAAc;IAEd,mBAAI,GAAG,iBAA0B,CAAC;IAUlC,qBAAM,GAAwB,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,EAAE;QACnG,IAAI,aAAa,CAAC,IAAI,KAAK,eAAA,IAAI,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,qCAAqC,eAAA,IAAI,UAAU,CAAC,CAAC;SACxE;QACD,MAAM,MAAM,GAAG,aAAuB,CAAC;QAEvC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,IAAA,wBAAa,EAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;QAE1I,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,oCAAoC,MAAM,CAAC,IAAI,iBAAiB,SAAS,CAAC,OAAO,CAAC,QAAQ,iCAAiC,CAAC,CAAC;SAChJ;QACD,OAAO,CAAC,IAAI,CAAC,MAAM,IAAA,sBAAW,EAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC;QAEpG,OAAO;YACH,MAAM;YACN,GAAG,EAAE,OAAO;YACZ,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE;YAC/B,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;SAChD,CAAC;IACN,CAAC,CAAC;AACN,CAAC,EAhCgB,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAgC9B"}
|
|
@@ -2,5 +2,5 @@ import { OneZeroValue } from './archetype/index.js';
|
|
|
2
2
|
export type Active = {
|
|
3
3
|
active: OneZeroValue.ReadWriteConfig;
|
|
4
4
|
};
|
|
5
|
-
export declare const active: import("./index.js").CharacteristicConfigurator<OneZeroValue.ReadWriteConfig<
|
|
5
|
+
export declare const active: import("./index.js").CharacteristicConfigurator<OneZeroValue.ReadOnlyConfig<string, string> | OneZeroValue.WriteOnlyConfig<string, string> | OneZeroValue.ReadWriteConfig<string, string>>;
|
|
6
6
|
//# sourceMappingURL=active.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"active.d.ts","sourceRoot":"","sources":["../../../src/service/characteristic/active.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,MAAM,MAAM,MAAM,GAAG;IACjB,MAAM,EAAE,YAAY,CAAC,eAAe,CAAA;CACvC,CAAA;AAED,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"active.d.ts","sourceRoot":"","sources":["../../../src/service/characteristic/active.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,MAAM,MAAM,MAAM,GAAG;IACjB,MAAM,EAAE,YAAY,CAAC,eAAe,CAAA;CACvC,CAAA;AAED,eAAO,MAAM,MAAM,4LAA+E,CAAC"}
|
|
@@ -2,18 +2,24 @@ import { CharacteristicConfigurator } from '../index.js';
|
|
|
2
2
|
import { Converter } from './Converter.js';
|
|
3
3
|
import { CharTypeFactory } from './common.js';
|
|
4
4
|
export declare namespace BooleanValue {
|
|
5
|
-
type
|
|
6
|
-
get: string;
|
|
5
|
+
type CommonConfig<ON extends string, OFF extends string> = {
|
|
7
6
|
converter?: Converter.Boolean.Type<ON, OFF>;
|
|
8
7
|
};
|
|
9
|
-
type
|
|
8
|
+
export type ReadOnlyConfig<ON extends string = 'on', OFF extends string = 'off'> = {
|
|
9
|
+
get: string;
|
|
10
|
+
} & CommonConfig<ON, OFF>;
|
|
11
|
+
export type WriteOnlyConfig<ON extends string = 'on', OFF extends string = 'off'> = {
|
|
10
12
|
set: string;
|
|
11
|
-
}
|
|
12
|
-
type
|
|
13
|
+
} & CommonConfig<ON, OFF>;
|
|
14
|
+
export type ReadWriteConfig<ON extends string = 'on', OFF extends string = 'off'> = ReadOnlyConfig<ON, OFF> & WriteOnlyConfig<ON, OFF>;
|
|
15
|
+
type Config<ON extends string = 'on', OFF extends string = 'off'> = ReadOnlyConfig<ON, OFF> | WriteOnlyConfig<ON, OFF> | ReadWriteConfig<ON, OFF>;
|
|
16
|
+
export type Options<ON extends string = 'on', OFF extends string = 'off'> = {
|
|
13
17
|
onKey?: ON;
|
|
14
18
|
offKey?: OFF;
|
|
15
19
|
};
|
|
16
|
-
const readOnly: <ON extends string
|
|
17
|
-
const
|
|
20
|
+
export const readOnly: <ON extends string, OFF extends string>(name: string, charTypeFactory: CharTypeFactory, options?: Options<ON, OFF> | undefined) => CharacteristicConfigurator<Config<ON, OFF>>;
|
|
21
|
+
export const writeOnly: <ON extends string, OFF extends string>(name: string, charTypeFactory: CharTypeFactory, options?: Options<ON, OFF> | undefined) => CharacteristicConfigurator<Config<ON, OFF>>;
|
|
22
|
+
export const readWrite: <ON extends string, OFF extends string>(name: string, charTypeFactory: CharTypeFactory, options?: Options<ON, OFF> | undefined) => CharacteristicConfigurator<Config<ON, OFF>>;
|
|
23
|
+
export {};
|
|
18
24
|
}
|
|
19
25
|
//# sourceMappingURL=BooleanValue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanValue.d.ts","sourceRoot":"","sources":["../../../../src/service/characteristic/archetype/BooleanValue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BooleanValue.d.ts","sourceRoot":"","sources":["../../../../src/service/characteristic/archetype/BooleanValue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACH,eAAe,EAKlB,MAAM,aAAa,CAAC;AAErB,yBAAiB,YAAY,CAAC;IAE1B,KAAK,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,MAAM,IAAI;QAAE,SAAS,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;KAAE,CAAC;IAC3G,MAAM,MAAM,cAAc,CAAC,EAAE,SAAS,MAAM,GAAG,IAAI,EAAE,GAAG,SAAS,MAAM,GAAG,KAAK,IAAI;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,YAAY,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;IAC1H,MAAM,MAAM,eAAe,CAAC,EAAE,SAAS,MAAM,GAAG,IAAI,EAAE,GAAG,SAAS,MAAM,GAAG,KAAK,IAC5E;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GACb,YAAY,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC5B,MAAM,MAAM,eAAe,CAAC,EAAE,SAAS,MAAM,GAAG,IAAI,EAAE,GAAG,SAAS,MAAM,GAAG,KAAK,IAC5E,cAAc,CAAC,EAAE,EAAE,GAAG,CAAC,GACrB,eAAe,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC/B,KAAK,MAAM,CAAC,EAAE,SAAS,MAAM,GAAG,IAAI,EAAE,GAAG,SAAS,MAAM,GAAG,KAAK,IAC5D,cAAc,CAAC,EAAE,EAAE,GAAG,CAAC,GACrB,eAAe,CAAC,EAAE,EAAE,GAAG,CAAC,GACxB,eAAe,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAE/B,MAAM,MAAM,OAAO,CAAC,EAAE,SAAS,MAAM,GAAG,IAAI,EAAE,GAAG,SAAS,MAAM,GAAG,KAAK,IAAI;QACxE,KAAK,CAAC,EAAE,EAAE,CAAC;QACX,MAAM,CAAC,EAAE,GAAG,CAAA;KACf,CAAA;IAED,MAAM,CAAC,MAAM,QAAQ,gDAAiD,MAAM,mBAAmB,eAAe,wFACrD,CAAC;IAE1D,MAAM,CAAC,MAAM,SAAS,gDAAiD,MAAM,mBAAmB,eAAe,wFACtD,CAAC;IAE1D,MAAM,CAAC,MAAM,SAAS,gDAAiD,MAAM,mBAAmB,eAAe,wFACtD,CAAC;;CA0D7D"}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BooleanValue = void 0;
|
|
4
|
+
const common_1 = require("../../../common");
|
|
4
5
|
const Converter_js_1 = require("./Converter.js");
|
|
5
6
|
const common_js_1 = require("./common.js");
|
|
6
7
|
var BooleanValue;
|
|
7
8
|
(function (BooleanValue) {
|
|
8
9
|
BooleanValue.readOnly = (name, charTypeFactory, options) => configurator(name, charTypeFactory, options);
|
|
10
|
+
BooleanValue.writeOnly = (name, charTypeFactory, options) => configurator(name, charTypeFactory, options);
|
|
9
11
|
BooleanValue.readWrite = (name, charTypeFactory, options) => configurator(name, charTypeFactory, options);
|
|
10
|
-
const
|
|
12
|
+
const isWrite = (config) => 'set' in config;
|
|
13
|
+
const isRead = (config) => 'get' in config;
|
|
11
14
|
const configurator = (name, charTypeFactory, options) => {
|
|
12
15
|
var _a, _b;
|
|
13
16
|
const onKey = (_a = options === null || options === void 0 ? void 0 : options.onKey) !== null && _a !== void 0 ? _a : 'on';
|
|
14
17
|
const offKey = (_b = options === null || options === void 0 ? void 0 : options.offKey) !== null && _b !== void 0 ? _b : 'off';
|
|
15
|
-
return async (platform, mqtt, accessory, service, config,
|
|
18
|
+
return async (platform, mqtt, accessory, service, config, serviceCtx) => {
|
|
16
19
|
var _a, _b;
|
|
17
|
-
const [setTopic, setJson, fullSetTopic] =
|
|
18
|
-
const [getTopic, getJson, fullGetTopic] = (0, common_js_1.parseTopic)(config.get,
|
|
20
|
+
const [setTopic, setJson, fullSetTopic] = isWrite(config) ? (0, common_js_1.parseTopic)(config.set, serviceCtx) : [undefined, undefined];
|
|
21
|
+
const [getTopic, getJson, fullGetTopic] = isRead(config) ? (0, common_js_1.parseTopic)(config.get, serviceCtx) : [undefined, undefined];
|
|
19
22
|
const converter = Converter_js_1.Converter.Boolean.resolve((_a = config.converter) !== null && _a !== void 0 ? _a : 'boolean', onKey, offKey);
|
|
20
23
|
if (!converter) {
|
|
21
24
|
platform.logger.error(`Unknown converter [${JSON.stringify(config.converter)}] set for [${mqtt.id}][${accessory.displayName}][${service.displayName}][${name}]`);
|
|
@@ -25,6 +28,7 @@ var BooleanValue;
|
|
|
25
28
|
if (setTopic) {
|
|
26
29
|
char.onSet((value, ctx) => {
|
|
27
30
|
var _a;
|
|
31
|
+
serviceCtx.emitter.emit(`${name}.set`, value, ctx);
|
|
28
32
|
if (!(ctx === null || ctx === void 0 ? void 0 : ctx.fromMqtt) && converter) {
|
|
29
33
|
const mqttValue = converter.fromHap(value);
|
|
30
34
|
const publishedValue = (_a = setJson === null || setJson === void 0 ? void 0 : setJson.stringify(mqttValue)) !== null && _a !== void 0 ? _a : mqttValue;
|
|
@@ -33,7 +37,7 @@ var BooleanValue;
|
|
|
33
37
|
}
|
|
34
38
|
});
|
|
35
39
|
}
|
|
36
|
-
const detachable = await mqtt.subscribe(getTopic, value => {
|
|
40
|
+
const detachable = !getTopic ? common_1.Detachable.NOOP : await mqtt.subscribe(getTopic, value => {
|
|
37
41
|
if (converter) {
|
|
38
42
|
const mqttValue = !getJson ? (0, common_js_1.parseMqttValue)(value) : getJson.parse(value);
|
|
39
43
|
const bool = converter.toHap(mqttValue);
|
|
@@ -47,7 +51,12 @@ var BooleanValue;
|
|
|
47
51
|
}
|
|
48
52
|
}
|
|
49
53
|
});
|
|
50
|
-
|
|
54
|
+
const on = (event, handler) => {
|
|
55
|
+
const eventName = `${name}.${event}`;
|
|
56
|
+
serviceCtx.emitter.on(eventName, handler);
|
|
57
|
+
return { detach: () => serviceCtx.emitter.off(eventName, handler) };
|
|
58
|
+
};
|
|
59
|
+
return common_js_1.DetachableCharacteristic.mixin(char, detachable, on);
|
|
51
60
|
};
|
|
52
61
|
};
|
|
53
62
|
})(BooleanValue = exports.BooleanValue || (exports.BooleanValue = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanValue.js","sourceRoot":"","sources":["../../../../src/service/characteristic/archetype/BooleanValue.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"BooleanValue.js","sourceRoot":"","sources":["../../../../src/service/characteristic/archetype/BooleanValue.ts"],"names":[],"mappings":";;;AAAA,4CAA6C;AAE7C,iDAA2C;AAC3C,2CAMqB;AAErB,IAAiB,YAAY,CAqF5B;AArFD,WAAiB,YAAY;IAoBZ,qBAAQ,GAAG,CAAwC,IAAY,EAAE,eAAgC,EAAE,OAA0B,EAAE,EAAE,CAC1I,YAAY,CAAU,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;IAE7C,sBAAS,GAAG,CAAwC,IAAY,EAAE,eAAgC,EAAE,OAA0B,EAAE,EAAE,CAC3I,YAAY,CAAU,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;IAE7C,sBAAS,GAAG,CAAwC,IAAY,EAAE,eAAgC,EAAE,OAA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AAI,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;QAChE,CAAC,CAAC;IAEN,CAAC,CAAC;AAEN,CAAC,EArFgB,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAqF5B"}
|
|
@@ -36,8 +36,9 @@ export declare namespace Converter {
|
|
|
36
36
|
type Type<ON extends string = 'on', OFF extends string = 'off'> = 'one-zero' | 'boolean' | {
|
|
37
37
|
[key in ON]: string;
|
|
38
38
|
} & {
|
|
39
|
-
[key in OFF]
|
|
39
|
+
[key in OFF]?: string;
|
|
40
40
|
};
|
|
41
|
+
const OneZero: Converter<number, boolean>;
|
|
41
42
|
const resolve: <ON extends string, OFF extends string>(type: Type<ON, OFF>, on: ON, off: OFF) => Optional<Converter<any, boolean>>;
|
|
42
43
|
}
|
|
43
44
|
}
|