@smarthome.exchange/integrations 1.0.0 → 2.0.0
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 +49 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/core/classes.configstore.d.ts +2 -0
- package/dist_ts/core/classes.configstore.js +84 -27
- package/dist_ts/core/classes.nativehomeadmission.d.ts +19 -0
- package/dist_ts/core/classes.nativehomeadmission.js +84 -0
- package/dist_ts/core/classes.nativeintegrationowner.d.ts +79 -0
- package/dist_ts/core/classes.nativeintegrationowner.js +269 -0
- package/dist_ts/core/index.d.ts +2 -0
- package/dist_ts/core/index.js +3 -1
- package/dist_ts/core/types.d.ts +14 -0
- package/dist_ts/integrations/braviatv/braviatv.classes.client.d.ts +23 -72
- package/dist_ts/integrations/braviatv/braviatv.classes.client.js +265 -625
- package/dist_ts/integrations/braviatv/braviatv.classes.configflow.d.ts +7 -7
- package/dist_ts/integrations/braviatv/braviatv.classes.configflow.js +51 -68
- package/dist_ts/integrations/braviatv/braviatv.classes.integration.d.ts +8 -11
- package/dist_ts/integrations/braviatv/braviatv.classes.integration.js +186 -135
- package/dist_ts/integrations/braviatv/braviatv.discovery.js +12 -11
- package/dist_ts/integrations/braviatv/braviatv.mapper.d.ts +6 -14
- package/dist_ts/integrations/braviatv/braviatv.mapper.js +37 -131
- package/dist_ts/integrations/braviatv/braviatv.types.d.ts +55 -133
- package/dist_ts/integrations/braviatv/braviatv.validation.d.ts +7 -0
- package/dist_ts/integrations/braviatv/braviatv.validation.js +72 -0
- package/dist_ts/integrations/broadlink/broadlink.actions.d.ts +2 -0
- package/dist_ts/integrations/broadlink/broadlink.actions.js +36 -0
- package/dist_ts/integrations/broadlink/broadlink.classes.client.d.ts +21 -19
- package/dist_ts/integrations/broadlink/broadlink.classes.client.js +185 -124
- package/dist_ts/integrations/broadlink/broadlink.classes.configflow.d.ts +5 -4
- package/dist_ts/integrations/broadlink/broadlink.classes.configflow.js +64 -83
- package/dist_ts/integrations/broadlink/broadlink.classes.integration.d.ts +16 -19
- package/dist_ts/integrations/broadlink/broadlink.classes.integration.js +114 -59
- package/dist_ts/integrations/broadlink/broadlink.mapper.d.ts +3 -2
- package/dist_ts/integrations/broadlink/broadlink.mapper.js +2 -1
- package/dist_ts/integrations/broadlink/broadlink.selected.mapper.d.ts +10 -0
- package/dist_ts/integrations/broadlink/broadlink.selected.mapper.js +41 -0
- package/dist_ts/integrations/broadlink/broadlink.types.d.ts +43 -7
- package/dist_ts/integrations/broadlink/broadlink.validation.d.ts +7 -0
- package/dist_ts/integrations/broadlink/broadlink.validation.js +63 -0
- package/dist_ts/integrations/daikin/daikin.classes.client.d.ts +10 -52
- package/dist_ts/integrations/daikin/daikin.classes.client.js +55 -614
- package/dist_ts/integrations/daikin/daikin.classes.configflow.d.ts +8 -12
- package/dist_ts/integrations/daikin/daikin.classes.configflow.js +77 -138
- package/dist_ts/integrations/daikin/daikin.classes.integration.d.ts +7 -24
- package/dist_ts/integrations/daikin/daikin.classes.integration.js +175 -67
- package/dist_ts/integrations/daikin/daikin.discovery.d.ts +11 -24
- package/dist_ts/integrations/daikin/daikin.discovery.js +98 -305
- package/dist_ts/integrations/daikin/daikin.mapper.d.ts +6 -7
- package/dist_ts/integrations/daikin/daikin.mapper.js +95 -155
- package/dist_ts/integrations/daikin/daikin.types.d.ts +24 -44
- package/dist_ts/integrations/daikin/daikin.types.js +1 -1
- package/dist_ts/integrations/daikin/daikin.validation.d.ts +5 -0
- package/dist_ts/integrations/daikin/daikin.validation.js +53 -0
- package/dist_ts/integrations/denonavr/denonavr.classes.client.d.ts +31 -40
- package/dist_ts/integrations/denonavr/denonavr.classes.client.js +149 -404
- package/dist_ts/integrations/denonavr/denonavr.classes.configflow.d.ts +7 -2
- package/dist_ts/integrations/denonavr/denonavr.classes.configflow.js +44 -36
- package/dist_ts/integrations/denonavr/denonavr.classes.integration.d.ts +6 -11
- package/dist_ts/integrations/denonavr/denonavr.classes.integration.js +192 -113
- package/dist_ts/integrations/denonavr/denonavr.discovery.d.ts +10 -18
- package/dist_ts/integrations/denonavr/denonavr.discovery.js +71 -193
- package/dist_ts/integrations/denonavr/denonavr.mapper.d.ts +5 -13
- package/dist_ts/integrations/denonavr/denonavr.mapper.js +35 -159
- package/dist_ts/integrations/denonavr/denonavr.types.d.ts +55 -90
- package/dist_ts/integrations/denonavr/denonavr.validation.d.ts +10 -0
- package/dist_ts/integrations/denonavr/denonavr.validation.js +86 -0
- package/dist_ts/integrations/kodi/kodi.classes.client.d.ts +11 -45
- package/dist_ts/integrations/kodi/kodi.classes.client.js +84 -310
- package/dist_ts/integrations/kodi/kodi.classes.configflow.d.ts +9 -8
- package/dist_ts/integrations/kodi/kodi.classes.configflow.js +53 -48
- package/dist_ts/integrations/kodi/kodi.classes.integration.d.ts +11 -11
- package/dist_ts/integrations/kodi/kodi.classes.integration.js +114 -171
- package/dist_ts/integrations/kodi/kodi.discovery.js +53 -29
- package/dist_ts/integrations/kodi/kodi.mapper.d.ts +7 -2
- package/dist_ts/integrations/kodi/kodi.mapper.js +48 -10
- package/dist_ts/integrations/kodi/kodi.types.d.ts +32 -28
- package/dist_ts/integrations/kodi/kodi.validation.d.ts +9 -0
- package/dist_ts/integrations/kodi/kodi.validation.js +62 -0
- package/dist_ts/integrations/modbus/modbus.classes.client.d.ts +15 -61
- package/dist_ts/integrations/modbus/modbus.classes.client.js +117 -776
- package/dist_ts/integrations/modbus/modbus.classes.configflow.d.ts +9 -5
- package/dist_ts/integrations/modbus/modbus.classes.configflow.js +70 -38
- package/dist_ts/integrations/modbus/modbus.classes.integration.d.ts +6 -17
- package/dist_ts/integrations/modbus/modbus.classes.integration.js +133 -57
- package/dist_ts/integrations/modbus/modbus.discovery.d.ts +5 -8
- package/dist_ts/integrations/modbus/modbus.discovery.js +38 -93
- package/dist_ts/integrations/modbus/modbus.mapper.d.ts +8 -32
- package/dist_ts/integrations/modbus/modbus.mapper.js +71 -431
- package/dist_ts/integrations/modbus/modbus.types.d.ts +82 -332
- package/dist_ts/integrations/modbus/modbus.validation.d.ts +10 -0
- package/dist_ts/integrations/modbus/modbus.validation.js +128 -0
- package/dist_ts/integrations/nanoleaf/nanoleaf.classes.client.d.ts +12 -34
- package/dist_ts/integrations/nanoleaf/nanoleaf.classes.client.js +143 -231
- package/dist_ts/integrations/nanoleaf/nanoleaf.classes.configflow.d.ts +6 -1
- package/dist_ts/integrations/nanoleaf/nanoleaf.classes.configflow.js +105 -18
- package/dist_ts/integrations/nanoleaf/nanoleaf.classes.integration.d.ts +8 -8
- package/dist_ts/integrations/nanoleaf/nanoleaf.classes.integration.js +141 -155
- package/dist_ts/integrations/nanoleaf/nanoleaf.credentials.d.ts +9 -0
- package/dist_ts/integrations/nanoleaf/nanoleaf.credentials.js +35 -0
- package/dist_ts/integrations/nanoleaf/nanoleaf.mapper.d.ts +6 -18
- package/dist_ts/integrations/nanoleaf/nanoleaf.mapper.js +45 -220
- package/dist_ts/integrations/nanoleaf/nanoleaf.types.d.ts +33 -147
- package/dist_ts/integrations/nanoleaf/nanoleaf.validation.d.ts +6 -0
- package/dist_ts/integrations/nanoleaf/nanoleaf.validation.js +82 -0
- package/dist_ts/integrations/onkyo/onkyo.classes.client.d.ts +15 -20
- package/dist_ts/integrations/onkyo/onkyo.classes.client.js +161 -404
- package/dist_ts/integrations/onkyo/onkyo.classes.configflow.d.ts +9 -4
- package/dist_ts/integrations/onkyo/onkyo.classes.configflow.js +51 -6
- package/dist_ts/integrations/onkyo/onkyo.classes.integration.d.ts +22 -6
- package/dist_ts/integrations/onkyo/onkyo.classes.integration.js +144 -11
- package/dist_ts/integrations/onkyo/onkyo.discovery.d.ts +6 -1
- package/dist_ts/integrations/onkyo/onkyo.discovery.js +40 -4
- package/dist_ts/integrations/onkyo/onkyo.mapper.d.ts +7 -8
- package/dist_ts/integrations/onkyo/onkyo.mapper.js +45 -12
- package/dist_ts/integrations/onkyo/onkyo.types.d.ts +58 -8
- package/dist_ts/integrations/onkyo/onkyo.types.js +13 -102
- package/dist_ts/integrations/onkyo/onkyo.validation.d.ts +16 -0
- package/dist_ts/integrations/onkyo/onkyo.validation.js +77 -0
- package/dist_ts/integrations/panasonic_viera/panasonic_viera.classes.client.d.ts +25 -25
- package/dist_ts/integrations/panasonic_viera/panasonic_viera.classes.client.js +116 -360
- package/dist_ts/integrations/panasonic_viera/panasonic_viera.classes.configflow.d.ts +11 -3
- package/dist_ts/integrations/panasonic_viera/panasonic_viera.classes.configflow.js +76 -6
- package/dist_ts/integrations/panasonic_viera/panasonic_viera.classes.integration.d.ts +26 -4
- package/dist_ts/integrations/panasonic_viera/panasonic_viera.classes.integration.js +142 -9
- package/dist_ts/integrations/panasonic_viera/panasonic_viera.discovery.d.ts +2 -1
- package/dist_ts/integrations/panasonic_viera/panasonic_viera.discovery.js +31 -4
- package/dist_ts/integrations/panasonic_viera/panasonic_viera.mapper.d.ts +9 -9
- package/dist_ts/integrations/panasonic_viera/panasonic_viera.mapper.js +31 -149
- package/dist_ts/integrations/panasonic_viera/panasonic_viera.types.d.ts +51 -11
- package/dist_ts/integrations/panasonic_viera/panasonic_viera.types.js +22 -87
- package/dist_ts/integrations/panasonic_viera/panasonic_viera.validation.d.ts +6 -0
- package/dist_ts/integrations/panasonic_viera/panasonic_viera.validation.js +56 -0
- package/dist_ts/integrations/pioneer/pioneer.classes.client.d.ts +31 -16
- package/dist_ts/integrations/pioneer/pioneer.classes.client.js +167 -409
- package/dist_ts/integrations/pioneer/pioneer.classes.configflow.d.ts +10 -3
- package/dist_ts/integrations/pioneer/pioneer.classes.configflow.js +66 -6
- package/dist_ts/integrations/pioneer/pioneer.classes.integration.d.ts +13 -5
- package/dist_ts/integrations/pioneer/pioneer.classes.integration.js +239 -11
- package/dist_ts/integrations/pioneer/pioneer.discovery.d.ts +14 -1
- package/dist_ts/integrations/pioneer/pioneer.discovery.js +51 -4
- package/dist_ts/integrations/pioneer/pioneer.mapper.d.ts +14 -8
- package/dist_ts/integrations/pioneer/pioneer.mapper.js +54 -12
- package/dist_ts/integrations/pioneer/pioneer.types.d.ts +79 -12
- package/dist_ts/integrations/pioneer/pioneer.types.js +12 -76
- package/dist_ts/integrations/pioneer/pioneer.validation.d.ts +10 -0
- package/dist_ts/integrations/pioneer/pioneer.validation.js +85 -0
- package/dist_ts/integrations/soundtouch/soundtouch.classes.client.d.ts +13 -36
- package/dist_ts/integrations/soundtouch/soundtouch.classes.client.js +179 -502
- package/dist_ts/integrations/soundtouch/soundtouch.classes.configflow.d.ts +6 -1
- package/dist_ts/integrations/soundtouch/soundtouch.classes.configflow.js +50 -40
- package/dist_ts/integrations/soundtouch/soundtouch.classes.integration.d.ts +14 -15
- package/dist_ts/integrations/soundtouch/soundtouch.classes.integration.js +108 -128
- package/dist_ts/integrations/soundtouch/soundtouch.discovery.d.ts +2 -20
- package/dist_ts/integrations/soundtouch/soundtouch.discovery.js +23 -113
- package/dist_ts/integrations/soundtouch/soundtouch.mapper.d.ts +3 -12
- package/dist_ts/integrations/soundtouch/soundtouch.mapper.js +35 -189
- package/dist_ts/integrations/soundtouch/soundtouch.types.d.ts +57 -142
- package/dist_ts/integrations/soundtouch/soundtouch.types.js +18 -3
- package/dist_ts/integrations/soundtouch/soundtouch.validation.d.ts +22 -0
- package/dist_ts/integrations/soundtouch/soundtouch.validation.js +65 -0
- package/dist_ts/integrations/wiz/index.d.ts +1 -0
- package/dist_ts/integrations/wiz/index.js +2 -1
- package/dist_ts/integrations/wiz/wiz.classes.client.d.ts +14 -28
- package/dist_ts/integrations/wiz/wiz.classes.client.js +93 -229
- package/dist_ts/integrations/wiz/wiz.classes.configflow.d.ts +6 -4
- package/dist_ts/integrations/wiz/wiz.classes.configflow.js +38 -67
- package/dist_ts/integrations/wiz/wiz.classes.integration.d.ts +10 -21
- package/dist_ts/integrations/wiz/wiz.classes.integration.js +204 -44
- package/dist_ts/integrations/wiz/wiz.discovery.d.ts +10 -31
- package/dist_ts/integrations/wiz/wiz.discovery.js +48 -249
- package/dist_ts/integrations/wiz/wiz.mapper.d.ts +7 -51
- package/dist_ts/integrations/wiz/wiz.mapper.js +82 -668
- package/dist_ts/integrations/wiz/wiz.types.d.ts +34 -208
- package/dist_ts/integrations/wiz/wiz.validation.d.ts +8 -0
- package/dist_ts/integrations/wiz/wiz.validation.js +72 -0
- package/dist_ts/integrations/yamaha/index.d.ts +1 -0
- package/dist_ts/integrations/yamaha/index.js +2 -1
- package/dist_ts/integrations/yamaha/yamaha.classes.client.d.ts +30 -4
- package/dist_ts/integrations/yamaha/yamaha.classes.client.js +162 -6
- package/dist_ts/integrations/yamaha/yamaha.classes.configflow.d.ts +10 -3
- package/dist_ts/integrations/yamaha/yamaha.classes.configflow.js +106 -6
- package/dist_ts/integrations/yamaha/yamaha.classes.integration.d.ts +22 -4
- package/dist_ts/integrations/yamaha/yamaha.classes.integration.js +243 -8
- package/dist_ts/integrations/yamaha/yamaha.discovery.d.ts +13 -1
- package/dist_ts/integrations/yamaha/yamaha.discovery.js +57 -4
- package/dist_ts/integrations/yamaha/yamaha.mapper.d.ts +16 -8
- package/dist_ts/integrations/yamaha/yamaha.mapper.js +58 -12
- package/dist_ts/integrations/yamaha/yamaha.types.d.ts +73 -6
- package/dist_ts/integrations/yamaha/yamaha.types.js +8 -94
- package/dist_ts/integrations/yamaha/yamaha.validation.d.ts +12 -0
- package/dist_ts/integrations/yamaha/yamaha.validation.js +89 -0
- package/package.json +3 -3
- package/readme.md +514 -2
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/core/classes.configstore.ts +84 -27
- package/ts/core/classes.nativehomeadmission.ts +96 -0
- package/ts/core/classes.nativeintegrationowner.ts +297 -0
- package/ts/core/index.ts +2 -0
- package/ts/core/types.ts +16 -0
- package/ts/integrations/braviatv/braviatv.classes.client.ts +245 -709
- package/ts/integrations/braviatv/braviatv.classes.configflow.ts +47 -76
- package/ts/integrations/braviatv/braviatv.classes.integration.ts +167 -147
- package/ts/integrations/braviatv/braviatv.discovery.ts +11 -10
- package/ts/integrations/braviatv/braviatv.mapper.ts +39 -142
- package/ts/integrations/braviatv/braviatv.types.ts +53 -173
- package/ts/integrations/braviatv/braviatv.validation.ts +68 -0
- package/ts/integrations/broadlink/broadlink.actions.ts +31 -0
- package/ts/integrations/broadlink/broadlink.classes.client.ts +170 -144
- package/ts/integrations/broadlink/broadlink.classes.configflow.ts +59 -89
- package/ts/integrations/broadlink/broadlink.classes.integration.ts +110 -64
- package/ts/integrations/broadlink/broadlink.mapper.ts +5 -4
- package/ts/integrations/broadlink/broadlink.selected.mapper.ts +46 -0
- package/ts/integrations/broadlink/broadlink.types.ts +48 -8
- package/ts/integrations/broadlink/broadlink.validation.ts +66 -0
- package/ts/integrations/daikin/daikin.classes.client.ts +52 -661
- package/ts/integrations/daikin/daikin.classes.configflow.ts +72 -152
- package/ts/integrations/daikin/daikin.classes.integration.ts +166 -71
- package/ts/integrations/daikin/daikin.discovery.ts +94 -346
- package/ts/integrations/daikin/daikin.mapper.ts +83 -166
- package/ts/integrations/daikin/daikin.types.ts +27 -48
- package/ts/integrations/daikin/daikin.validation.ts +51 -0
- package/ts/integrations/daikin/readme.md +83 -0
- package/ts/integrations/denonavr/denonavr.classes.client.ts +132 -421
- package/ts/integrations/denonavr/denonavr.classes.configflow.ts +44 -37
- package/ts/integrations/denonavr/denonavr.classes.integration.ts +171 -117
- package/ts/integrations/denonavr/denonavr.discovery.ts +67 -220
- package/ts/integrations/denonavr/denonavr.mapper.ts +36 -182
- package/ts/integrations/denonavr/denonavr.types.ts +48 -111
- package/ts/integrations/denonavr/denonavr.validation.ts +87 -0
- package/ts/integrations/kodi/kodi.classes.client.ts +72 -352
- package/ts/integrations/kodi/kodi.classes.configflow.ts +52 -55
- package/ts/integrations/kodi/kodi.classes.integration.ts +97 -178
- package/ts/integrations/kodi/kodi.discovery.ts +49 -28
- package/ts/integrations/kodi/kodi.mapper.ts +52 -10
- package/ts/integrations/kodi/kodi.types.ts +33 -58
- package/ts/integrations/kodi/kodi.validation.ts +60 -0
- package/ts/integrations/modbus/modbus.classes.client.ts +100 -842
- package/ts/integrations/modbus/modbus.classes.configflow.ts +70 -41
- package/ts/integrations/modbus/modbus.classes.integration.ts +115 -60
- package/ts/integrations/modbus/modbus.discovery.ts +38 -106
- package/ts/integrations/modbus/modbus.mapper.ts +64 -467
- package/ts/integrations/modbus/modbus.types.ts +64 -381
- package/ts/integrations/modbus/modbus.validation.ts +119 -0
- package/ts/integrations/nanoleaf/nanoleaf.classes.client.ts +115 -249
- package/ts/integrations/nanoleaf/nanoleaf.classes.configflow.ts +90 -19
- package/ts/integrations/nanoleaf/nanoleaf.classes.integration.ts +130 -181
- package/ts/integrations/nanoleaf/nanoleaf.credentials.ts +39 -0
- package/ts/integrations/nanoleaf/nanoleaf.mapper.ts +47 -260
- package/ts/integrations/nanoleaf/nanoleaf.types.ts +29 -147
- package/ts/integrations/nanoleaf/nanoleaf.validation.ts +77 -0
- package/ts/integrations/onkyo/onkyo.classes.client.ts +148 -457
- package/ts/integrations/onkyo/onkyo.classes.configflow.ts +52 -6
- package/ts/integrations/onkyo/onkyo.classes.integration.ts +121 -12
- package/ts/integrations/onkyo/onkyo.discovery.ts +41 -3
- package/ts/integrations/onkyo/onkyo.mapper.ts +46 -19
- package/ts/integrations/onkyo/onkyo.types.ts +55 -110
- package/ts/integrations/onkyo/onkyo.validation.ts +85 -0
- package/ts/integrations/onkyo/readme.md +126 -0
- package/ts/integrations/panasonic_viera/panasonic_viera.classes.client.ts +101 -398
- package/ts/integrations/panasonic_viera/panasonic_viera.classes.configflow.ts +69 -5
- package/ts/integrations/panasonic_viera/panasonic_viera.classes.integration.ts +141 -9
- package/ts/integrations/panasonic_viera/panasonic_viera.discovery.ts +32 -3
- package/ts/integrations/panasonic_viera/panasonic_viera.mapper.ts +34 -161
- package/ts/integrations/panasonic_viera/panasonic_viera.types.ts +52 -96
- package/ts/integrations/panasonic_viera/panasonic_viera.validation.ts +56 -0
- package/ts/integrations/pioneer/pioneer.classes.client.ts +132 -428
- package/ts/integrations/pioneer/pioneer.classes.configflow.ts +67 -5
- package/ts/integrations/pioneer/pioneer.classes.integration.ts +225 -11
- package/ts/integrations/pioneer/pioneer.discovery.ts +45 -3
- package/ts/integrations/pioneer/pioneer.mapper.ts +57 -13
- package/ts/integrations/pioneer/pioneer.types.ts +87 -85
- package/ts/integrations/pioneer/pioneer.validation.ts +84 -0
- package/ts/integrations/soundtouch/soundtouch.classes.client.ts +152 -571
- package/ts/integrations/soundtouch/soundtouch.classes.configflow.ts +47 -42
- package/ts/integrations/soundtouch/soundtouch.classes.integration.ts +95 -150
- package/ts/integrations/soundtouch/soundtouch.discovery.ts +21 -133
- package/ts/integrations/soundtouch/soundtouch.mapper.ts +36 -207
- package/ts/integrations/soundtouch/soundtouch.types.ts +50 -195
- package/ts/integrations/soundtouch/soundtouch.validation.ts +60 -0
- package/ts/integrations/wiz/index.ts +1 -0
- package/ts/integrations/wiz/wiz.classes.client.ts +84 -254
- package/ts/integrations/wiz/wiz.classes.configflow.ts +39 -70
- package/ts/integrations/wiz/wiz.classes.integration.ts +189 -45
- package/ts/integrations/wiz/wiz.discovery.ts +48 -291
- package/ts/integrations/wiz/wiz.mapper.ts +81 -754
- package/ts/integrations/wiz/wiz.types.ts +24 -224
- package/ts/integrations/wiz/wiz.validation.ts +73 -0
- package/ts/integrations/yamaha/index.ts +1 -0
- package/ts/integrations/yamaha/yamaha.classes.client.ts +150 -6
- package/ts/integrations/yamaha/yamaha.classes.configflow.ts +100 -5
- package/ts/integrations/yamaha/yamaha.classes.integration.ts +236 -8
- package/ts/integrations/yamaha/yamaha.discovery.ts +52 -3
- package/ts/integrations/yamaha/yamaha.mapper.ts +65 -13
- package/ts/integrations/yamaha/yamaha.types.ts +77 -97
- package/ts/integrations/yamaha/yamaha.validation.ts +86 -0
|
@@ -1,167 +1,193 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
broadlinkPacketFromBase64,
|
|
13
|
-
broadlinkPacketFromHex,
|
|
14
|
-
broadlinkRfPacketFromTimings,
|
|
15
|
-
} from './broadlink.packet.js';
|
|
16
|
-
|
|
17
|
-
type TBroadlinkEventHandler = (eventArg: IBroadlinkEvent) => void;
|
|
1
|
+
import * as plugins from '../../plugins.js';
|
|
2
|
+
import type { NoSqlConfigStore } from '../../core/classes.configstore.js';
|
|
3
|
+
import { NativeHomeAdmission } from '../../core/classes.nativehomeadmission.js';
|
|
4
|
+
import type { INativeIntegrationSetupContext } from '../../core/types.js';
|
|
5
|
+
import { readBroadlinkActions } from './broadlink.actions.js';
|
|
6
|
+
import { broadlinkConfigKey, broadlinkRecord, readBroadlinkSelection,
|
|
7
|
+
sameBroadlinkSelection } from './broadlink.validation.js';
|
|
8
|
+
import { broadlinkIrPacketFromTimings, broadlinkPacketFromBase64, broadlinkPacketFromHex,
|
|
9
|
+
broadlinkRfPacketFromTimings } from './broadlink.packet.js';
|
|
10
|
+
import type { IBroadlinkConfig, IBroadlinkIrAction, IBroadlinkPacket, IBroadlinkSelectedSnapshot,
|
|
11
|
+
IBroadlinkSelection } from './broadlink.types.js';
|
|
18
12
|
|
|
19
13
|
export class BroadlinkClient {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
this
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
public async sendCommand(commandArg: IBroadlinkCommand): Promise<IBroadlinkCommandResult> {
|
|
43
|
-
this.emit({ type: 'command_mapped', command: commandArg, deviceId: commandArg.deviceId, entityId: commandArg.entityId, timestamp: Date.now() });
|
|
44
|
-
|
|
45
|
-
if (commandArg.type === 'delete_command') {
|
|
46
|
-
const result = this.deleteCommand(commandArg);
|
|
47
|
-
this.emit({ type: result.success ? 'command_deleted' : 'command_failed', command: commandArg, deviceId: commandArg.deviceId, entityId: commandArg.entityId, data: result, timestamp: Date.now() });
|
|
48
|
-
return result;
|
|
14
|
+
readonly #selection: IBroadlinkSelection;
|
|
15
|
+
readonly #store?: NoSqlConfigStore;
|
|
16
|
+
readonly #protocol: plugins.ecobridgeDeviceManager.BroadlinkProtocol;
|
|
17
|
+
readonly #lifetime = new AbortController();
|
|
18
|
+
readonly #pending = new Set<Promise<unknown>>();
|
|
19
|
+
readonly #packets = new Map<string, Buffer>();
|
|
20
|
+
readonly #setupSignal?: AbortSignal;
|
|
21
|
+
#actions?: ReadonlyArray<Readonly<IBroadlinkIrAction>>;
|
|
22
|
+
#snapshot?: IBroadlinkSelectedSnapshot;
|
|
23
|
+
#initialization?: Promise<void>;
|
|
24
|
+
#closePromise?: Promise<void>;
|
|
25
|
+
#retryPromise?: Promise<void>;
|
|
26
|
+
|
|
27
|
+
constructor(configArg: IBroadlinkConfig, contextArg: INativeIntegrationSetupContext) {
|
|
28
|
+
const config = broadlinkRecord(configArg, ['homeId', 'host', 'macAddress', 'deviceType', 'port',
|
|
29
|
+
'localAddress', 'timeoutMs', 'maxPendingOperations', 'name', 'actions']);
|
|
30
|
+
this.#selection = readBroadlinkSelection(config);
|
|
31
|
+
this.#actions = config.actions === undefined ? undefined : readBroadlinkActions(config.actions);
|
|
32
|
+
const context = new NativeHomeAdmission('broadlink').admit(contextArg, this.#selection.homeId);
|
|
33
|
+
this.#store = context.configStore;
|
|
34
|
+
if (!this.#actions && !this.#store) {
|
|
35
|
+
throw new TypeError('Broadlink action restoration requires an initialized encrypted NoSqlConfigStore.');
|
|
49
36
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
37
|
+
this.#setupSignal = context.abortSignal;
|
|
38
|
+
this.#setupSignal?.throwIfAborted();
|
|
39
|
+
this.#protocol = new plugins.ecobridgeDeviceManager.BroadlinkProtocol({
|
|
40
|
+
host: this.#selection.host, port: this.#selection.port, macAddress: this.#selection.macAddress,
|
|
41
|
+
deviceType: this.#selection.deviceType, localAddress: this.#selection.localAddress,
|
|
42
|
+
timeoutMs: this.#selection.timeoutMs, maxPendingOperations: this.#selection.maxPendingOperations,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public get selection(): IBroadlinkSelection { return this.#selection; }
|
|
47
|
+
public get currentSnapshot(): IBroadlinkSelectedSnapshot {
|
|
48
|
+
if (!this.#snapshot) throw new Error('Broadlink has no verified bridge observation.');
|
|
49
|
+
return this.#snapshot;
|
|
50
|
+
}
|
|
51
|
+
public isHealthy(): boolean { return !this.#lifetime.signal.aborted && this.#protocol.isReady && this.#snapshot?.available === true; }
|
|
52
|
+
|
|
53
|
+
public initialize(): Promise<void> {
|
|
54
|
+
if (!this.#initialization) this.#initialization = this.initializeSelected();
|
|
55
|
+
return this.#initialization;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private async initializeSelected(): Promise<void> {
|
|
59
|
+
try { await this.track(() => this.loadAndStart()); }
|
|
60
|
+
catch (error) {
|
|
61
|
+
this.#lifetime.abort(new Error('Broadlink setup failed.'));
|
|
62
|
+
if (this.#snapshot) this.#snapshot = Object.freeze({ ...this.#snapshot, available: false });
|
|
63
|
+
try { await this.closeAndDrain(); }
|
|
64
|
+
catch (cleanupError) {
|
|
65
|
+
throw new AggregateError([error, cleanupError], 'Broadlink setup and cleanup failed.', { cause: error });
|
|
73
66
|
}
|
|
74
|
-
|
|
75
|
-
return result;
|
|
76
|
-
} catch (errorArg) {
|
|
77
|
-
const result: IBroadlinkCommandResult = {
|
|
78
|
-
success: false,
|
|
79
|
-
transmitted: false,
|
|
80
|
-
error: errorArg instanceof Error ? errorArg.message : String(errorArg),
|
|
81
|
-
data: { command: commandArg },
|
|
82
|
-
};
|
|
83
|
-
this.emit({ type: 'command_failed', command: commandArg, deviceId: commandArg.deviceId, entityId: commandArg.entityId, data: result, timestamp: Date.now() });
|
|
84
|
-
return result;
|
|
67
|
+
throw error;
|
|
85
68
|
}
|
|
86
69
|
}
|
|
87
70
|
|
|
88
|
-
|
|
89
|
-
this.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return broadlinkIrPacketFromTimings(timingsArg);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
public static rfPacketFromTimings(optionsArg: { frequency: number; timings: number[]; repeatCount?: number }): IBroadlinkPacket {
|
|
105
|
-
return broadlinkRfPacketFromTimings(optionsArg);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
private emit(eventArg: IBroadlinkEvent): void {
|
|
109
|
-
this.events.push(eventArg);
|
|
110
|
-
for (const handler of this.eventHandlers) {
|
|
111
|
-
handler(eventArg);
|
|
71
|
+
private async loadAndStart(): Promise<void> {
|
|
72
|
+
const signal = this.operationSignal(this.#setupSignal);
|
|
73
|
+
signal.throwIfAborted();
|
|
74
|
+
const supplied = this.#actions !== undefined;
|
|
75
|
+
if (!supplied) {
|
|
76
|
+
if (!this.#store) throw new TypeError('Broadlink action restoration requires an initialized encrypted NoSqlConfigStore.');
|
|
77
|
+
const value = await this.#store.get<unknown>(broadlinkConfigKey(this.#selection));
|
|
78
|
+
if (value === undefined) throw new Error('Broadlink has no encrypted owner action configuration for this bridge.');
|
|
79
|
+
const stored = broadlinkRecord(value, ['version', 'selection', 'actions']);
|
|
80
|
+
if (stored.version !== 1 || !sameBroadlinkSelection(this.#selection, readBroadlinkSelection(stored.selection))) {
|
|
81
|
+
throw new Error('Stored Broadlink configuration does not match the selected home and bridge.');
|
|
82
|
+
}
|
|
83
|
+
this.#actions = readBroadlinkActions(stored.actions);
|
|
112
84
|
}
|
|
85
|
+
signal.throwIfAborted();
|
|
86
|
+
for (const action of this.#actions!) this.#packets.set(action.id, Buffer.from(action.packetBase64, 'base64'));
|
|
87
|
+
await this.#protocol.start({ signal });
|
|
88
|
+
const firmware = await this.#protocol.readFirmware({ signal });
|
|
89
|
+
signal.throwIfAborted();
|
|
90
|
+
this.#snapshot = Object.freeze({ selection: this.#selection, available: true, firmwareVersion: firmware.version,
|
|
91
|
+
observedAt: new Date().toISOString(), actions: Object.freeze(this.#actions!.map((actionArg) =>
|
|
92
|
+
Object.freeze({ id: actionArg.id, name: actionArg.name }))) });
|
|
93
|
+
if (supplied && this.#store) await this.#store.set(broadlinkConfigKey(this.#selection), {
|
|
94
|
+
version: 1, selection: this.#selection, actions: this.#actions,
|
|
95
|
+
});
|
|
96
|
+
signal.throwIfAborted();
|
|
97
|
+
this.#actions = undefined;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public getSnapshot(signalArg?: AbortSignal): Promise<IBroadlinkSelectedSnapshot> {
|
|
101
|
+
return this.track(async () => {
|
|
102
|
+
const signal = this.operationSignal(signalArg);
|
|
103
|
+
signal.throwIfAborted();
|
|
104
|
+
try {
|
|
105
|
+
const firmware = await this.#protocol.readFirmware({ signal });
|
|
106
|
+
signal.throwIfAborted();
|
|
107
|
+
this.#snapshot = Object.freeze({ ...this.currentSnapshot, firmwareVersion: firmware.version,
|
|
108
|
+
available: true, observedAt: new Date().toISOString() });
|
|
109
|
+
return this.#snapshot;
|
|
110
|
+
} catch (error) {
|
|
111
|
+
if (this.#snapshot) this.#snapshot = Object.freeze({ ...this.#snapshot, available: false });
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public sendAction(actionIdArg: string, signalArg?: AbortSignal): Promise<plugins.ecobridgeDeviceManager.IBroadlinkIrReceipt> {
|
|
118
|
+
return this.track(async () => {
|
|
119
|
+
const signal = this.operationSignal(signalArg);
|
|
120
|
+
if (signal.aborted) throw new plugins.ecobridgeDeviceManager.BroadlinkProtocolError('ABORTED', 'Broadlink action was aborted.');
|
|
121
|
+
const packet = this.#packets.get(actionIdArg);
|
|
122
|
+
if (!packet || !this.isHealthy()) throw new plugins.ecobridgeDeviceManager.BroadlinkProtocolError('NOT_STARTED',
|
|
123
|
+
'Broadlink action is unknown or the selected bridge is unavailable.');
|
|
124
|
+
try { return await this.#protocol.sendIr(packet, { signal }); }
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (this.#protocol.isClosed && this.#snapshot) this.#snapshot = Object.freeze({ ...this.#snapshot, available: false });
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Terminal and memoized. The caller owns its store/database. */
|
|
133
|
+
public destroy(): Promise<void> {
|
|
134
|
+
if (!this.#closePromise) {
|
|
135
|
+
const closing = Promise.withResolvers<void>();
|
|
136
|
+
this.#closePromise = closing.promise;
|
|
137
|
+
this.#lifetime.abort(new Error('Broadlink client is closed.'));
|
|
138
|
+
if (this.#snapshot) this.#snapshot = Object.freeze({ ...this.#snapshot, available: false });
|
|
139
|
+
void (async () => {
|
|
140
|
+
const [closed] = await Promise.allSettled([this.closeAndDrain(), this.#initialization]);
|
|
141
|
+
if (closed.status === 'rejected') throw closed.reason;
|
|
142
|
+
})().then(closing.resolve, closing.reject);
|
|
143
|
+
}
|
|
144
|
+
return this.#closePromise;
|
|
113
145
|
}
|
|
114
146
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
147
|
+
/** Explicitly retries retained cleanup without reopening or replaying bridge operations. */
|
|
148
|
+
public retryCleanup(): Promise<void> {
|
|
149
|
+
if (!this.#closePromise) return this.destroy();
|
|
150
|
+
if (!this.#retryPromise) {
|
|
151
|
+
const retry = this.#closePromise.then(() => undefined, () => this.closeAndDrain());
|
|
152
|
+
this.#retryPromise = retry;
|
|
153
|
+
void retry.then(() => {}, () => { if (this.#retryPromise === retry) this.#retryPromise = undefined; });
|
|
118
154
|
}
|
|
119
|
-
return
|
|
155
|
+
return this.#retryPromise;
|
|
120
156
|
}
|
|
121
157
|
|
|
122
|
-
private
|
|
123
|
-
|
|
158
|
+
private async closeAndDrain(): Promise<void> {
|
|
159
|
+
// Startup tracks only its admitted work, so its cleanup cannot join itself.
|
|
160
|
+
const [closed] = await Promise.allSettled([
|
|
161
|
+
Promise.resolve().then(() => this.#protocol.close()),
|
|
162
|
+
...this.#pending,
|
|
163
|
+
]);
|
|
164
|
+
this.releasePackets();
|
|
165
|
+
this.#actions = undefined;
|
|
166
|
+
if (closed.status === 'rejected') throw closed.reason;
|
|
124
167
|
}
|
|
125
168
|
|
|
126
|
-
private
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return { success: false, transmitted: false, error: 'Broadlink delete_command requires data.device and data.command.' };
|
|
130
|
-
}
|
|
131
|
-
const devices = this.config.snapshot?.devices || this.config.devices || [];
|
|
132
|
-
const targetDevice = devices.find((deviceArg) => BroadlinkMapper.deviceId(deviceArg) === commandArg.deviceId || deviceArg.id === commandArg.deviceId) || devices[0];
|
|
133
|
-
const codes = targetDevice?.codes || this.config.codes;
|
|
134
|
-
if (!codes?.[remoteDevice]) {
|
|
135
|
-
return { success: false, transmitted: false, error: `Broadlink learned-code device not found: ${remoteDevice}.` };
|
|
136
|
-
}
|
|
137
|
-
for (const command of commandArg.commandNames) {
|
|
138
|
-
delete codes[remoteDevice][command];
|
|
139
|
-
}
|
|
140
|
-
if (!Object.keys(codes[remoteDevice]).length) {
|
|
141
|
-
delete codes[remoteDevice];
|
|
142
|
-
}
|
|
143
|
-
return { success: true, transmitted: false, data: { command: commandArg } };
|
|
169
|
+
private operationSignal(signalArg?: AbortSignal): AbortSignal {
|
|
170
|
+
if (signalArg !== undefined && !(signalArg instanceof AbortSignal)) throw new TypeError('Broadlink cancellation requires an AbortSignal.');
|
|
171
|
+
return signalArg ? AbortSignal.any([signalArg, this.#lifetime.signal]) : this.#lifetime.signal;
|
|
144
172
|
}
|
|
145
173
|
|
|
146
|
-
private
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
const device = snapshot.devices.find((deviceArg) => BroadlinkMapper.deviceId(deviceArg) === commandArg.deviceId || deviceArg.id === commandArg.deviceId);
|
|
152
|
-
if (!device) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
device.state = { ...(device.state || {}), ...commandArg.payload };
|
|
156
|
-
device.available = true;
|
|
157
|
-
device.updatedAt = new Date().toISOString();
|
|
174
|
+
private releasePackets(): void {
|
|
175
|
+
for (const packet of this.#packets.values()) packet.fill(0);
|
|
176
|
+
this.#packets.clear();
|
|
158
177
|
}
|
|
159
178
|
|
|
160
|
-
private
|
|
161
|
-
|
|
179
|
+
private track<TValue>(operationArg: () => Promise<TValue>): Promise<TValue> {
|
|
180
|
+
const operation = Promise.resolve().then(operationArg);
|
|
181
|
+
this.#pending.add(operation);
|
|
182
|
+
void operation.then(() => this.#pending.delete(operation), () => this.#pending.delete(operation));
|
|
183
|
+
return operation;
|
|
162
184
|
}
|
|
163
185
|
|
|
164
|
-
|
|
165
|
-
|
|
186
|
+
/** These pure helpers do not validate a packet for native runtime admission. */
|
|
187
|
+
public static packetFromBase64(valueArg: string): IBroadlinkPacket { return broadlinkPacketFromBase64(valueArg); }
|
|
188
|
+
public static packetFromHex(valueArg: string): IBroadlinkPacket { return broadlinkPacketFromHex(valueArg); }
|
|
189
|
+
public static irPacketFromTimings(timingsArg: number[]): IBroadlinkPacket { return broadlinkIrPacketFromTimings(timingsArg); }
|
|
190
|
+
public static rfPacketFromTimings(optionsArg: { frequency: number; timings: number[]; repeatCount?: number }): IBroadlinkPacket {
|
|
191
|
+
return broadlinkRfPacketFromTimings(optionsArg);
|
|
166
192
|
}
|
|
167
193
|
}
|
|
@@ -1,99 +1,69 @@
|
|
|
1
|
+
import { NativeIntegrationOwner, type NativeIntegrationScope } from '../../core/classes.nativeintegrationowner.js';
|
|
1
2
|
import type { IConfigFlow, IConfigFlowContext, IConfigFlowStep, IDiscoveryCandidate } from '../../core/types.js';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
3
|
+
import { readBroadlinkActions } from './broadlink.actions.js';
|
|
4
|
+
import { broadlinkConfigKey, broadlinkRecord, readBroadlinkSelection } from './broadlink.validation.js';
|
|
5
|
+
import type { IBroadlinkConfig } from './broadlink.types.js';
|
|
4
6
|
|
|
5
7
|
export class BroadlinkConfigFlow implements IConfigFlow<IBroadlinkConfig> {
|
|
6
|
-
|
|
7
|
-
void contextArg;
|
|
8
|
-
const metadata = candidateArg.metadata || {};
|
|
9
|
-
const host = candidateArg.host || this.stringValue(metadata.host) || '';
|
|
10
|
-
const deviceType = candidateArg.model || this.stringValue(metadata.deviceType) || '';
|
|
11
|
-
const name = candidateArg.name || this.stringValue(metadata.name) || '';
|
|
12
|
-
|
|
13
|
-
return {
|
|
14
|
-
kind: 'form',
|
|
15
|
-
title: 'Connect Broadlink device',
|
|
16
|
-
description: 'Provide the local host and device identity. This TypeScript port maps snapshots and commands, and requires an injected executor for live Broadlink UDP/auth traffic.',
|
|
17
|
-
fields: [
|
|
18
|
-
{ name: 'host', label: host ? `Host (${host})` : 'Host', type: 'text', required: true },
|
|
19
|
-
{ name: 'port', label: `Port (${candidateArg.port || broadlinkDefaultPort})`, type: 'number' },
|
|
20
|
-
{ name: 'timeout', label: `Timeout seconds (${broadlinkDefaultTimeoutSeconds})`, type: 'number' },
|
|
21
|
-
{ name: 'name', label: name ? `Name (${name})` : 'Name', type: 'text' },
|
|
22
|
-
{ name: 'type', label: deviceType ? `Device type (${deviceType})` : 'Device type', type: 'text' },
|
|
23
|
-
{ name: 'macAddress', label: candidateArg.macAddress ? `MAC (${candidateArg.macAddress})` : 'MAC address', type: 'text' },
|
|
24
|
-
{ name: 'snapshotJson', label: 'Snapshot JSON', type: 'text' },
|
|
25
|
-
],
|
|
26
|
-
submit: async (valuesArg) => this.submit(candidateArg, valuesArg),
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
private async submit(candidateArg: IDiscoveryCandidate, valuesArg: Record<string, unknown>): Promise<IConfigFlowStep<IBroadlinkConfig>> {
|
|
31
|
-
const snapshot = this.snapshotFromInput(valuesArg.snapshotJson);
|
|
32
|
-
if (snapshot instanceof Error) {
|
|
33
|
-
return { kind: 'error', title: 'Invalid snapshot', error: snapshot.message };
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const host = this.stringValue(valuesArg.host) || candidateArg.host || snapshot?.host;
|
|
37
|
-
if (!host && !snapshot) {
|
|
38
|
-
return { kind: 'error', title: 'Host required', error: 'Broadlink setup requires a host unless a config is created directly from a snapshot.' };
|
|
39
|
-
}
|
|
8
|
+
readonly #scope: NativeIntegrationScope;
|
|
40
9
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
host,
|
|
44
|
-
port: this.numberValue(valuesArg.port) || candidateArg.port || snapshot?.port || broadlinkDefaultPort,
|
|
45
|
-
timeout: this.numberValue(valuesArg.timeout) || this.numberValue(metadata.timeout) || broadlinkDefaultTimeoutSeconds,
|
|
46
|
-
name: this.stringValue(valuesArg.name) || candidateArg.name,
|
|
47
|
-
macAddress: this.stringValue(valuesArg.macAddress) || candidateArg.macAddress,
|
|
48
|
-
deviceId: candidateArg.id,
|
|
49
|
-
type: (this.stringValue(valuesArg.type) || this.stringValue(metadata.deviceType) || candidateArg.model) as TBroadlinkDeviceType | undefined,
|
|
50
|
-
devtype: this.numberValue(metadata.devtype),
|
|
51
|
-
model: candidateArg.model,
|
|
52
|
-
manufacturer: candidateArg.manufacturer || 'Broadlink',
|
|
53
|
-
isLocked: metadata.isLocked === true,
|
|
54
|
-
snapshot,
|
|
55
|
-
metadata: {
|
|
56
|
-
discoverySource: candidateArg.source,
|
|
57
|
-
discoveryMetadata: metadata,
|
|
58
|
-
liveUdpAuthImplemented: false,
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
kind: 'done',
|
|
64
|
-
title: 'Broadlink device configured',
|
|
65
|
-
config,
|
|
66
|
-
};
|
|
10
|
+
constructor(scopeArg?: NativeIntegrationScope) {
|
|
11
|
+
this.#scope = scopeArg ?? new NativeIntegrationOwner('broadlink').createFlowScope();
|
|
67
12
|
}
|
|
68
13
|
|
|
69
|
-
|
|
70
|
-
const text = this.stringValue(valueArg);
|
|
71
|
-
if (!text) {
|
|
72
|
-
return undefined;
|
|
73
|
-
}
|
|
14
|
+
public async start(candidateArg: IDiscoveryCandidate, contextArg: IConfigFlowContext): Promise<IConfigFlowStep<IBroadlinkConfig>> {
|
|
74
15
|
try {
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
16
|
+
const context = this.#scope.admit(contextArg);
|
|
17
|
+
return await this.#scope.run<IConfigFlowStep<IBroadlinkConfig>>(context, undefined, async (leaseArg) => {
|
|
18
|
+
leaseArg.assertOpen();
|
|
19
|
+
const host = candidateArg.host;
|
|
20
|
+
const macAddress = candidateArg.macAddress;
|
|
21
|
+
const candidateType = candidateArg.metadata?.devtype;
|
|
22
|
+
const name = candidateArg.name;
|
|
23
|
+
return {
|
|
24
|
+
kind: 'form', title: 'Select Broadlink IR bridge',
|
|
25
|
+
description: 'Select one RM mini 3 or RM4 mini on a trusted local network and provide owner-approved native IR action packets. Bridge acceptance cannot confirm appliance effects.',
|
|
26
|
+
fields: [
|
|
27
|
+
{ name: 'host', label: host ? `Private IPv4 (${host})` : 'Private IPv4', type: 'text', required: true },
|
|
28
|
+
{ name: 'macAddress', label: macAddress ? `MAC (${macAddress})` : 'Exact MAC', type: 'text', required: true },
|
|
29
|
+
{ name: 'deviceType', label: 'Exact bridge type', type: 'select', required: true,
|
|
30
|
+
options: [{ label: 'RM mini 3 (0x2737)', value: '0x2737' }, { label: 'RM4 mini (0x51da)', value: '0x51da' }] },
|
|
31
|
+
{ name: 'name', label: name ? `Name (${name})` : 'Bridge name', type: 'text' },
|
|
32
|
+
{ name: 'port', label: 'UDP port (80)', type: 'number' },
|
|
33
|
+
{ name: 'localAddress', label: 'Local private IPv4 interface (optional)', type: 'text' },
|
|
34
|
+
{ name: 'timeoutMs', label: 'Operation timeout milliseconds (5000)', type: 'number' },
|
|
35
|
+
{ name: 'maxPendingOperations', label: 'Pending operation limit (32)', type: 'number' },
|
|
36
|
+
{ name: 'actionsJson', label: 'Owner IR actions JSON: id, name, packetBase64', type: 'text', required: true },
|
|
37
|
+
],
|
|
38
|
+
submit: async (valuesArg) => {
|
|
39
|
+
try {
|
|
40
|
+
const values = broadlinkRecord(valuesArg, ['host', 'macAddress', 'deviceType', 'name', 'port', 'localAddress',
|
|
41
|
+
'timeoutMs', 'maxPendingOperations', 'actionsJson']);
|
|
42
|
+
const deviceType = values.deviceType === '0x2737' ? 0x2737 : values.deviceType === '0x51da' ? 0x51da
|
|
43
|
+
: values.deviceType ?? candidateType;
|
|
44
|
+
return await this.#scope.run<IConfigFlowStep<IBroadlinkConfig>>(context, context.homeId, async (submissionArg) => {
|
|
45
|
+
const selection = readBroadlinkSelection({ homeId: context.homeId, host: values.host ?? host,
|
|
46
|
+
macAddress: values.macAddress ?? macAddress, deviceType, name: values.name ?? name,
|
|
47
|
+
port: values.port, localAddress: values.localAddress, timeoutMs: values.timeoutMs,
|
|
48
|
+
maxPendingOperations: values.maxPendingOperations });
|
|
49
|
+
if (typeof values.actionsJson !== 'string' || values.actionsJson.length > 60000) throw new TypeError('Owner IR actions require bounded JSON.');
|
|
50
|
+
const actions = readBroadlinkActions(JSON.parse(values.actionsJson) as unknown);
|
|
51
|
+
submissionArg.assertOpen();
|
|
52
|
+
if (submissionArg.context.configStore) {
|
|
53
|
+
await submissionArg.context.configStore.set(broadlinkConfigKey(selection), { version: 1, selection, actions });
|
|
54
|
+
}
|
|
55
|
+
return { kind: 'done', title: 'Broadlink selection configured', config: { ...selection,
|
|
56
|
+
...(submissionArg.context.configStore ? {} : { actions: actions.map((actionArg) => ({ ...actionArg })) }) } };
|
|
57
|
+
});
|
|
58
|
+
} catch (error) { return { kind: 'error', title: 'Invalid Broadlink selection',
|
|
59
|
+
error: error instanceof Error ? error.message : 'Broadlink configuration failed.' }; }
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
} catch (error) { return { kind: 'error', title: 'Broadlink home admission failed',
|
|
64
|
+
error: error instanceof Error ? error.message : 'Provide an explicit authorized host home.' }; }
|
|
83
65
|
}
|
|
84
66
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
private numberValue(valueArg: unknown): number | undefined {
|
|
90
|
-
if (typeof valueArg === 'number' && Number.isFinite(valueArg)) {
|
|
91
|
-
return valueArg;
|
|
92
|
-
}
|
|
93
|
-
if (typeof valueArg === 'string' && valueArg.trim()) {
|
|
94
|
-
const value = Number(valueArg);
|
|
95
|
-
return Number.isFinite(value) ? value : undefined;
|
|
96
|
-
}
|
|
97
|
-
return undefined;
|
|
98
|
-
}
|
|
67
|
+
public destroy(): Promise<void> { return this.#scope.close(); }
|
|
68
|
+
public retryCleanup(): Promise<void> { return this.#scope.retryCleanup(); }
|
|
99
69
|
}
|