@marcel2215/homebridge-supla-plugin 2.1.31 → 2.1.33
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/README.md +1 -67
- package/config.json +3 -0
- package/config.schema.json +75 -92
- package/dist/Accesories/ActionTriggerAccessory.d.ts +1 -0
- package/dist/Accesories/ActionTriggerAccessory.d.ts.map +1 -1
- package/dist/Accesories/ActionTriggerAccessory.js +9 -15
- package/dist/Accesories/ActionTriggerAccessory.js.map +1 -1
- package/dist/Accesories/AirQualityAccessory.d.ts +1 -3
- package/dist/Accesories/AirQualityAccessory.d.ts.map +1 -1
- package/dist/Accesories/AirQualityAccessory.js +5 -47
- package/dist/Accesories/AirQualityAccessory.js.map +1 -1
- package/dist/Accesories/ContactSensorAccessory.d.ts +1 -3
- package/dist/Accesories/ContactSensorAccessory.d.ts.map +1 -1
- package/dist/Accesories/ContactSensorAccessory.js +4 -32
- package/dist/Accesories/ContactSensorAccessory.js.map +1 -1
- package/dist/Accesories/DimmerAccessory.d.ts +3 -5
- package/dist/Accesories/DimmerAccessory.d.ts.map +1 -1
- package/dist/Accesories/DimmerAccessory.js +14 -50
- package/dist/Accesories/DimmerAccessory.js.map +1 -1
- package/dist/Accesories/DimmerRgbLightAccessory.d.ts +3 -11
- package/dist/Accesories/DimmerRgbLightAccessory.d.ts.map +1 -1
- package/dist/Accesories/DimmerRgbLightAccessory.js +26 -148
- package/dist/Accesories/DimmerRgbLightAccessory.js.map +1 -1
- package/dist/Accesories/DoorAccessory.d.ts +1 -14
- package/dist/Accesories/DoorAccessory.d.ts.map +1 -1
- package/dist/Accesories/DoorAccessory.js +20 -146
- package/dist/Accesories/DoorAccessory.js.map +1 -1
- package/dist/Accesories/ElectricityMeterAccessory.d.ts +1 -13
- package/dist/Accesories/ElectricityMeterAccessory.d.ts.map +1 -1
- package/dist/Accesories/ElectricityMeterAccessory.js +12 -127
- package/dist/Accesories/ElectricityMeterAccessory.js.map +1 -1
- package/dist/Accesories/FacadeBlindAccessory.d.ts +0 -6
- package/dist/Accesories/FacadeBlindAccessory.d.ts.map +1 -1
- package/dist/Accesories/FacadeBlindAccessory.js +64 -205
- package/dist/Accesories/FacadeBlindAccessory.js.map +1 -1
- package/dist/Accesories/FrontGateFsm.d.ts +68 -74
- package/dist/Accesories/FrontGateFsm.d.ts.map +1 -1
- package/dist/Accesories/FrontGateFsm.js +403 -563
- package/dist/Accesories/FrontGateFsm.js.map +1 -1
- package/dist/Accesories/GarageDoorOpenerAccesory.d.ts +3 -12
- package/dist/Accesories/GarageDoorOpenerAccesory.d.ts.map +1 -1
- package/dist/Accesories/GarageDoorOpenerAccesory.js +21 -168
- package/dist/Accesories/GarageDoorOpenerAccesory.js.map +1 -1
- package/dist/Accesories/GateAccessory.d.ts +2 -12
- package/dist/Accesories/GateAccessory.d.ts.map +1 -1
- package/dist/Accesories/GateAccessory.js +89 -258
- package/dist/Accesories/GateAccessory.js.map +1 -1
- package/dist/Accesories/GateLockAccessory.d.ts +1 -17
- package/dist/Accesories/GateLockAccessory.d.ts.map +1 -1
- package/dist/Accesories/GateLockAccessory.js +50 -375
- package/dist/Accesories/GateLockAccessory.js.map +1 -1
- package/dist/Accesories/LeakSensorAccessory.d.ts +1 -3
- package/dist/Accesories/LeakSensorAccessory.d.ts.map +1 -1
- package/dist/Accesories/LeakSensorAccessory.js +4 -32
- package/dist/Accesories/LeakSensorAccessory.js.map +1 -1
- package/dist/Accesories/LightBulbAccesory.d.ts +3 -4
- package/dist/Accesories/LightBulbAccesory.d.ts.map +1 -1
- package/dist/Accesories/LightBulbAccesory.js +12 -40
- package/dist/Accesories/LightBulbAccesory.js.map +1 -1
- package/dist/Accesories/PressureAccessory.d.ts +1 -3
- package/dist/Accesories/PressureAccessory.d.ts.map +1 -1
- package/dist/Accesories/PressureAccessory.js +5 -28
- package/dist/Accesories/PressureAccessory.js.map +1 -1
- package/dist/Accesories/RGBLightBulbAccesory.d.ts +1 -10
- package/dist/Accesories/RGBLightBulbAccesory.d.ts.map +1 -1
- package/dist/Accesories/RGBLightBulbAccesory.js +17 -136
- package/dist/Accesories/RGBLightBulbAccesory.js.map +1 -1
- package/dist/Accesories/RollerShutterAccessory.d.ts +0 -6
- package/dist/Accesories/RollerShutterAccessory.d.ts.map +1 -1
- package/dist/Accesories/RollerShutterAccessory.js +75 -221
- package/dist/Accesories/RollerShutterAccessory.js.map +1 -1
- package/dist/Accesories/SwitchAccessory.d.ts +3 -4
- package/dist/Accesories/SwitchAccessory.d.ts.map +1 -1
- package/dist/Accesories/SwitchAccessory.js +12 -40
- package/dist/Accesories/SwitchAccessory.js.map +1 -1
- package/dist/Accesories/TemperatureAccessory.d.ts +1 -3
- package/dist/Accesories/TemperatureAccessory.d.ts.map +1 -1
- package/dist/Accesories/TemperatureAccessory.js +5 -28
- package/dist/Accesories/TemperatureAccessory.js.map +1 -1
- package/dist/Accesories/TemperatureHumidityAccessory.d.ts +1 -5
- package/dist/Accesories/TemperatureHumidityAccessory.d.ts.map +1 -1
- package/dist/Accesories/TemperatureHumidityAccessory.js +9 -40
- package/dist/Accesories/TemperatureHumidityAccessory.js.map +1 -1
- package/dist/Accesories/ThermostatAccessory.d.ts +1 -18
- package/dist/Accesories/ThermostatAccessory.d.ts.map +1 -1
- package/dist/Accesories/ThermostatAccessory.js +34 -193
- package/dist/Accesories/ThermostatAccessory.js.map +1 -1
- package/dist/Accesories/ValveAccessory.d.ts +2 -5
- package/dist/Accesories/ValveAccessory.d.ts.map +1 -1
- package/dist/Accesories/ValveAccessory.js +8 -47
- package/dist/Accesories/ValveAccessory.js.map +1 -1
- package/dist/Accesories/WicketAccesory.d.ts +3 -18
- package/dist/Accesories/WicketAccesory.d.ts.map +1 -1
- package/dist/Accesories/WicketAccesory.js +14 -154
- package/dist/Accesories/WicketAccesory.js.map +1 -1
- package/dist/Heplers/ColorConverters.d.ts +2 -2
- package/dist/Heplers/ColorConverters.d.ts.map +1 -1
- package/dist/Heplers/ColorConverters.js +3 -7
- package/dist/Heplers/ColorConverters.js.map +1 -1
- package/dist/Heplers/SuplaChannelContext.d.ts +1 -3
- package/dist/Heplers/SuplaChannelContext.d.ts.map +1 -1
- package/dist/Heplers/SuplaChannelContext.js +1 -3
- package/dist/Heplers/SuplaChannelContext.js.map +1 -1
- package/dist/Heplers/SuplaMqttClient.d.ts +3 -11
- package/dist/Heplers/SuplaMqttClient.d.ts.map +1 -1
- package/dist/Heplers/SuplaMqttClient.js +112 -215
- package/dist/Heplers/SuplaMqttClient.js.map +1 -1
- package/dist/Heplers/SuplaMqttClientContext.d.ts +1 -2
- package/dist/Heplers/SuplaMqttClientContext.d.ts.map +1 -1
- package/dist/Heplers/SuplaMqttClientContext.js +1 -2
- package/dist/Heplers/SuplaMqttClientContext.js.map +1 -1
- package/dist/platform.d.ts +36 -93
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +236 -1285
- package/dist/platform.js.map +1 -1
- package/package.json +5 -10
- package/dist/Heplers/DisplayName.d.ts +0 -15
- package/dist/Heplers/DisplayName.d.ts.map +0 -1
- package/dist/Heplers/DisplayName.js +0 -174
- package/dist/Heplers/DisplayName.js.map +0 -1
package/README.md
CHANGED
|
@@ -14,36 +14,12 @@
|
|
|
14
14
|
|
|
15
15
|
This is an accessory plugin for Supla devices. It allows you to control your Supla devices with HomeKit and Siri.
|
|
16
16
|
|
|
17
|
-
Supports Homebridge 1.6 or later, including Homebridge 2.1.1
|
|
17
|
+
Supports Homebridge 1.6 or later, including Homebridge 2.1.1. Homebridge 2 requires Node.js 22.12 or 24.
|
|
18
18
|
|
|
19
19
|
### How it works
|
|
20
20
|
|
|
21
21
|
This plugin uses the mqtt protocol to communicate with the Supla server. It subscribes to the topics of the devices you want to control and publishes the commands you send to the devices.
|
|
22
22
|
|
|
23
|
-
Discovered channel metadata is cached in a versioned, per-platform-instance file under Homebridge's storage directory. A legacy
|
|
24
|
-
`channels` value is migrated once for compatibility; the plugin does not rewrite Homebridge's `config.json` at runtime.
|
|
25
|
-
Cached cloud-topic accessories can be safely migrated in place because their topic contains the Supla account name. Older
|
|
26
|
-
roller-shutter topics contain no account identity, so they receive a new account-scoped HomeKit identity by default. Set
|
|
27
|
-
`migrateUnscopedLegacyAccessories` to `true` only for a one-time migration when you know the cached accessories belong to the
|
|
28
|
-
currently configured account; do not enable it when changing accounts.
|
|
29
|
-
|
|
30
|
-
Supla captions are retained in Unicode NFC form, so Polish diacritics and other scripts are not passed through an ASCII-only
|
|
31
|
-
sanitizer. HomeKit-facing names preserve Unicode letters and numbers while mapping only typography unsupported by HAP and respecting
|
|
32
|
-
the Name characteristic's 64 UTF-16-code-unit limit. Generated, blank, malformed, or partial-discovery captions never replace a
|
|
33
|
-
meaningful cached name; an existing name changes only with durable retained-caption evidence or a complete authoritative snapshot.
|
|
34
|
-
The plugin does not write HomeKit's user-controlled `ConfiguredName` characteristic.
|
|
35
|
-
Accessory UUIDs and service identities are based only on the account plus channel IDs (or a stable legacy topic), never on captions;
|
|
36
|
-
renaming a channel therefore does not create a new HomeKit accessory.
|
|
37
|
-
|
|
38
|
-
MQTT publish completion confirms delivery to the MQTT client/broker, not physical-device application. HomeKit setters surface
|
|
39
|
-
transport failures, and state is reconciled from subsequent Supla state topics.
|
|
40
|
-
|
|
41
|
-
Electricity meters retain the existing HomeKit `LightSensor` service for automation and accessory-identity compatibility.
|
|
42
|
-
`CurrentAmbientLightLevel` is therefore a compatibility carrier, not a lux reading: its numeric value uses the one Supla metric and
|
|
43
|
-
unit shown explicitly in the service name (for example, `Voltage; V` or `Active power; W`). On first setup the plugin selects one
|
|
44
|
-
metric deterministically from the retained snapshot and persists that choice. It will not silently switch units on later starts; if
|
|
45
|
-
the selected metric is absent, the service remains unavailable. The generic `value` metric is labeled `unknown unit`.
|
|
46
|
-
|
|
47
23
|
|
|
48
24
|
### How to use
|
|
49
25
|
|
|
@@ -54,45 +30,3 @@ $ npm i homebridge-supla-plugin
|
|
|
54
30
|
2. Configure the plugin. You can find your MQTT credentials in the [Supla Cloud](https://cloud.supla.org/).
|
|
55
31
|
3. Restart Homebridge
|
|
56
32
|
4. Plugin will automatically discover your devices and add them to HomeKit
|
|
57
|
-
|
|
58
|
-
### Front-gate safety model
|
|
59
|
-
|
|
60
|
-
Supla front gates controlled through the non-idempotent `open_close` action need a closed end-stop sensor. If the sensor is on a
|
|
61
|
-
separate channel, the plugin pairs it only when there is one unambiguous candidate. Configure one of these overrides if automatic
|
|
62
|
-
pairing is not possible:
|
|
63
|
-
|
|
64
|
-
```json
|
|
65
|
-
{
|
|
66
|
-
"frontGateSensorTopic": "supla/USER/devices/123/channels/456"
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Alternatively, use `frontGateSensorDeviceId` and `frontGateSensorChannelId`. A missing or ambiguous sensor keeps the gate unavailable.
|
|
71
|
-
The legacy control-channel sensor fallback is disabled unless `frontGateSensorFallbackToControlChannel` is explicitly enabled.
|
|
72
|
-
|
|
73
|
-
With only a closed sensor, `false` means “not fully closed”; it does not prove that the gate is fully open or reveal its direction.
|
|
74
|
-
The plugin therefore reports an unproven non-closed position as HomeKit `STOPPED` and rejects ambiguous open and close requests by
|
|
75
|
-
default:
|
|
76
|
-
|
|
77
|
-
```json
|
|
78
|
-
{
|
|
79
|
-
"frontGateUnknownOpenPolicy": "reject",
|
|
80
|
-
"frontGateUnknownClosePolicy": "reject",
|
|
81
|
-
"frontGateAssumeOpenAfterTravel": false
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
Optional compatibility policies are:
|
|
86
|
-
|
|
87
|
-
- `accept_non_closed` for open requests: accepts any non-closed position without sending a pulse.
|
|
88
|
-
- `single_pulse_best_effort` for close requests: sends one pulse but continues reporting `STOPPED` until hard evidence arrives.
|
|
89
|
-
- `seek_closed` for close requests: sends up to `frontGateSeekClosedMaxPulses` pulses, one full travel interval apart, until the closed
|
|
90
|
-
sensor activates. The search can initially move the gate in the opposite direction and must only be enabled with that behavior
|
|
91
|
-
understood.
|
|
92
|
-
|
|
93
|
-
`frontGateAssumeOpenAfterTravel` is also an approximation and is disabled by default. An IR remote cannot be observed by the plugin,
|
|
94
|
-
so external IR use can always invalidate a direction estimate until new sensor evidence arrives.
|
|
95
|
-
|
|
96
|
-
Front-gate action publications always use MQTT QoS 0 and `retain: false`, independently of the global command settings. Retained
|
|
97
|
-
`execute_action` messages are ignored by the state estimator; any old retained action already stored on the broker should be removed.
|
|
98
|
-
MQTT 5 enables a No Local subscription for safer self-echo handling by setting `mqttProtocolVersion` to `5`, if the broker supports it.
|
package/config.json
ADDED
package/config.schema.json
CHANGED
|
@@ -2,18 +2,7 @@
|
|
|
2
2
|
"pluginAlias": "SuplaPlatform",
|
|
3
3
|
"pluginType": "platform",
|
|
4
4
|
"singular": true,
|
|
5
|
-
"strictValidation": false,
|
|
6
5
|
"schema": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"required": [
|
|
9
|
-
"name",
|
|
10
|
-
"host",
|
|
11
|
-
"port",
|
|
12
|
-
"username",
|
|
13
|
-
"password"
|
|
14
|
-
],
|
|
15
|
-
"additionalProperties": true,
|
|
16
|
-
"properties": {
|
|
17
6
|
"name": {
|
|
18
7
|
"title": "Name",
|
|
19
8
|
"type": "string",
|
|
@@ -69,89 +58,96 @@
|
|
|
69
58
|
"auto"
|
|
70
59
|
]
|
|
71
60
|
},
|
|
72
|
-
"
|
|
73
|
-
"title": "
|
|
74
|
-
"type": "
|
|
75
|
-
"default":
|
|
76
|
-
"
|
|
61
|
+
"gateControlMode": {
|
|
62
|
+
"title": "Gate Control Mode",
|
|
63
|
+
"type": "string",
|
|
64
|
+
"default": "execute_action",
|
|
65
|
+
"enum": [
|
|
66
|
+
"execute_action",
|
|
67
|
+
"toggle"
|
|
68
|
+
]
|
|
77
69
|
},
|
|
78
|
-
"
|
|
79
|
-
"title": "
|
|
70
|
+
"gateExecuteActionOpen": {
|
|
71
|
+
"title": "Gate Execute Action Open",
|
|
80
72
|
"type": "string",
|
|
81
73
|
"default": "open_close"
|
|
82
74
|
},
|
|
83
|
-
"
|
|
84
|
-
"title": "
|
|
85
|
-
"type": "
|
|
86
|
-
"default":
|
|
87
|
-
"minimum": 5000,
|
|
88
|
-
"maximum": 120000
|
|
89
|
-
},
|
|
90
|
-
"frontGateReversePauseMs": {
|
|
91
|
-
"title": "Front Gate Reverse Pause (ms)",
|
|
92
|
-
"type": "number",
|
|
93
|
-
"default": 3000,
|
|
94
|
-
"minimum": 3000,
|
|
95
|
-
"maximum": 15000
|
|
96
|
-
},
|
|
97
|
-
"frontGateMinimumPulseGapMs": {
|
|
98
|
-
"title": "Front Gate Minimum Pulse Gap (ms)",
|
|
99
|
-
"type": "number",
|
|
100
|
-
"default": 3000,
|
|
101
|
-
"minimum": 0,
|
|
102
|
-
"maximum": 15000
|
|
75
|
+
"gateExecuteActionClose": {
|
|
76
|
+
"title": "Gate Execute Action Close",
|
|
77
|
+
"type": "string",
|
|
78
|
+
"default": "open_close"
|
|
103
79
|
},
|
|
104
|
-
"
|
|
105
|
-
"title": "
|
|
80
|
+
"gateExecuteActionToggle": {
|
|
81
|
+
"title": "Gate Execute Action Toggle",
|
|
106
82
|
"type": "string",
|
|
107
|
-
"default": "
|
|
108
|
-
"enum": [
|
|
109
|
-
"reject",
|
|
110
|
-
"accept_non_closed"
|
|
111
|
-
]
|
|
83
|
+
"default": "open_close"
|
|
112
84
|
},
|
|
113
|
-
"
|
|
114
|
-
"title": "
|
|
85
|
+
"gatePartialHiMode": {
|
|
86
|
+
"title": "Gate Partial Hi Mode",
|
|
115
87
|
"type": "string",
|
|
116
|
-
"default": "
|
|
88
|
+
"default": "moving",
|
|
117
89
|
"enum": [
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
"
|
|
90
|
+
"moving",
|
|
91
|
+
"open_endstop",
|
|
92
|
+
"pedestrian_endstop",
|
|
93
|
+
"ignore"
|
|
121
94
|
]
|
|
122
95
|
},
|
|
123
|
-
"
|
|
124
|
-
"title": "
|
|
96
|
+
"gateReverseFollowUpDelayMs": {
|
|
97
|
+
"title": "Gate Reverse Follow-up Delay (ms)",
|
|
125
98
|
"type": "number",
|
|
126
|
-
"default":
|
|
127
|
-
"minimum": 1,
|
|
128
|
-
"maximum": 3
|
|
99
|
+
"default": 3000
|
|
129
100
|
},
|
|
130
|
-
"
|
|
131
|
-
"title": "
|
|
132
|
-
"type": "
|
|
133
|
-
"default":
|
|
101
|
+
"gateOpenAssumeDelayMs": {
|
|
102
|
+
"title": "Gate Open Assume Delay (ms)",
|
|
103
|
+
"type": "number",
|
|
104
|
+
"default": 22000
|
|
134
105
|
},
|
|
135
|
-
"
|
|
136
|
-
"title": "
|
|
137
|
-
"type": "
|
|
138
|
-
"default":
|
|
106
|
+
"gateCommandCooldownMs": {
|
|
107
|
+
"title": "Gate Command Cooldown (ms)",
|
|
108
|
+
"type": "number",
|
|
109
|
+
"default": 700
|
|
139
110
|
},
|
|
140
|
-
"
|
|
141
|
-
"title": "
|
|
142
|
-
"type": "
|
|
143
|
-
"default":
|
|
111
|
+
"gatePublishRetryDelayMs": {
|
|
112
|
+
"title": "Gate Publish Retry Delay (ms)",
|
|
113
|
+
"type": "number",
|
|
114
|
+
"default": 300
|
|
144
115
|
},
|
|
145
|
-
"
|
|
146
|
-
"title": "
|
|
147
|
-
"type": "
|
|
148
|
-
"default":
|
|
116
|
+
"gateStrictReverseDoublePulse": {
|
|
117
|
+
"title": "Gate Strict Reverse Double Pulse",
|
|
118
|
+
"type": "boolean",
|
|
119
|
+
"default": true
|
|
149
120
|
},
|
|
150
|
-
"
|
|
151
|
-
"title": "
|
|
121
|
+
"gateDebugTimeline": {
|
|
122
|
+
"title": "Gate Debug Timeline",
|
|
152
123
|
"type": "boolean",
|
|
153
124
|
"default": false
|
|
154
125
|
},
|
|
126
|
+
"frontGateFullTravelMs": {
|
|
127
|
+
"title": "Front Gate Full Travel (ms)",
|
|
128
|
+
"type": "number",
|
|
129
|
+
"default": 25000
|
|
130
|
+
},
|
|
131
|
+
"frontGateReversePauseMs": {
|
|
132
|
+
"title": "Front Gate Reverse Pause (ms)",
|
|
133
|
+
"type": "number",
|
|
134
|
+
"default": 900
|
|
135
|
+
},
|
|
136
|
+
"frontGateWrongDirectionRunMs": {
|
|
137
|
+
"title": "Front Gate Wrong Direction Run (ms)",
|
|
138
|
+
"type": "number",
|
|
139
|
+
"default": 700
|
|
140
|
+
},
|
|
141
|
+
"frontGateMinimumPulseGapMs": {
|
|
142
|
+
"title": "Front Gate Minimum Pulse Gap (ms)",
|
|
143
|
+
"type": "number",
|
|
144
|
+
"default": 400
|
|
145
|
+
},
|
|
146
|
+
"frontGateCloseRetryLimit": {
|
|
147
|
+
"title": "Front Gate Close Retry Limit",
|
|
148
|
+
"type": "number",
|
|
149
|
+
"default": 1
|
|
150
|
+
},
|
|
155
151
|
"gateLockControlMode": {
|
|
156
152
|
"title": "Gate Lock Control Mode",
|
|
157
153
|
"type": "string",
|
|
@@ -174,9 +170,7 @@
|
|
|
174
170
|
"gateLockPulseSeconds": {
|
|
175
171
|
"title": "Gate Lock Pulse Seconds",
|
|
176
172
|
"type": "number",
|
|
177
|
-
"default":
|
|
178
|
-
"minimum": 0.1,
|
|
179
|
-
"maximum": 60
|
|
173
|
+
"default": 0
|
|
180
174
|
},
|
|
181
175
|
"gateLockSetOnPayload": {
|
|
182
176
|
"title": "Gate Lock Set On Payload",
|
|
@@ -228,15 +222,6 @@
|
|
|
228
222
|
"type": "number",
|
|
229
223
|
"default": 0
|
|
230
224
|
},
|
|
231
|
-
"mqttProtocolVersion": {
|
|
232
|
-
"title": "MQTT Protocol Version",
|
|
233
|
-
"type": "number",
|
|
234
|
-
"default": 4,
|
|
235
|
-
"enum": [
|
|
236
|
-
4,
|
|
237
|
-
5
|
|
238
|
-
]
|
|
239
|
-
},
|
|
240
225
|
"commandQos": {
|
|
241
226
|
"title": "Command QoS",
|
|
242
227
|
"type": "number",
|
|
@@ -254,20 +239,18 @@
|
|
|
254
239
|
},
|
|
255
240
|
"username": {
|
|
256
241
|
"title": "Username",
|
|
257
|
-
"type": "string"
|
|
242
|
+
"type": "string",
|
|
243
|
+
"default": "admin"
|
|
258
244
|
},
|
|
259
245
|
"password": {
|
|
260
246
|
"title": "Password",
|
|
261
247
|
"type": "string",
|
|
262
|
-
"
|
|
248
|
+
"default": "admin"
|
|
263
249
|
},
|
|
264
250
|
"channels": {
|
|
265
251
|
"title": "Cached Channels",
|
|
266
252
|
"type": "string",
|
|
267
|
-
"
|
|
268
|
-
"deprecated": true,
|
|
269
|
-
"hidden": true
|
|
270
|
-
}
|
|
253
|
+
"default": "[]"
|
|
271
254
|
}
|
|
272
255
|
}
|
|
273
256
|
}
|
|
@@ -6,6 +6,7 @@ export declare class ActionTriggerAccessory {
|
|
|
6
6
|
private readonly accessory;
|
|
7
7
|
private readonly context;
|
|
8
8
|
private service;
|
|
9
|
+
private connected;
|
|
9
10
|
constructor(platform: SuplaPlatform, accessory: PlatformAccessory, context: SuplaChannelContext);
|
|
10
11
|
private parseEvent;
|
|
11
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionTriggerAccessory.d.ts","sourceRoot":"","sources":["../../src/Accesories/ActionTriggerAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE,qBAAa,sBAAsB;
|
|
1
|
+
{"version":3,"file":"ActionTriggerAccessory.d.ts","sourceRoot":"","sources":["../../src/Accesories/ActionTriggerAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE,qBAAa,sBAAsB;IAK/B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAN1B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,SAAS,CAAQ;gBAGN,QAAQ,EAAE,aAAa,EACvB,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,mBAAmB;IAmC/C,OAAO,CAAC,UAAU;CAUnB"}
|
|
@@ -6,38 +6,32 @@ class ActionTriggerAccessory {
|
|
|
6
6
|
this.platform = platform;
|
|
7
7
|
this.accessory = accessory;
|
|
8
8
|
this.context = context;
|
|
9
|
+
this.connected = true;
|
|
9
10
|
this.accessory.getService(this.platform.Service.AccessoryInformation)
|
|
10
11
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'Supla')
|
|
11
12
|
.setCharacteristic(this.platform.Characteristic.Model, 'ActionTrigger');
|
|
12
13
|
this.service = this.accessory.getService(this.platform.Service.StatelessProgrammableSwitch)
|
|
13
14
|
|| this.accessory.addService(this.platform.Service.StatelessProgrammableSwitch);
|
|
14
15
|
this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
15
|
-
this.platform.registerMqttHandler(`${this.context.topic}/state/action`, (message
|
|
16
|
-
if (packet.retain) {
|
|
17
|
-
this.platform.log.debug(`Ignoring retained action trigger event for ${this.context.channelCaption}`);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
16
|
+
this.platform.registerMqttHandler(`${this.context.topic}/state/action`, (message) => {
|
|
20
17
|
const event = this.parseEvent(message.toString());
|
|
21
|
-
if (event === undefined) {
|
|
22
|
-
this.platform.log.debug(`Ignoring unknown action trigger payload for ${this.context.channelCaption}`);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
18
|
this.platform.log.debug(`Action trigger ${this.context.channelCaption} event=${event}`);
|
|
26
19
|
this.service.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent, event);
|
|
27
20
|
}, this.accessory.UUID);
|
|
21
|
+
this.platform.registerMqttHandler(`${this.context.topic}/state/connected`, (message) => {
|
|
22
|
+
this.connected = this.platform.parseBoolean(message.toString());
|
|
23
|
+
this.service.updateCharacteristic(this.platform.Characteristic.StatusFault, this.connected ? 0 : 1);
|
|
24
|
+
}, this.accessory.UUID);
|
|
28
25
|
}
|
|
29
26
|
parseEvent(payload) {
|
|
30
27
|
const value = payload.trim().toLowerCase();
|
|
31
|
-
if (
|
|
28
|
+
if (value === '1' || value.includes('double')) {
|
|
32
29
|
return this.platform.Characteristic.ProgrammableSwitchEvent.DOUBLE_PRESS;
|
|
33
30
|
}
|
|
34
|
-
if (
|
|
31
|
+
if (value === '2' || value.includes('long') || value.includes('hold')) {
|
|
35
32
|
return this.platform.Characteristic.ProgrammableSwitchEvent.LONG_PRESS;
|
|
36
33
|
}
|
|
37
|
-
|
|
38
|
-
return this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS;
|
|
39
|
-
}
|
|
40
|
-
return undefined;
|
|
34
|
+
return this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS;
|
|
41
35
|
}
|
|
42
36
|
}
|
|
43
37
|
exports.ActionTriggerAccessory = ActionTriggerAccessory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionTriggerAccessory.js","sourceRoot":"","sources":["../../src/Accesories/ActionTriggerAccessory.ts"],"names":[],"mappings":";;;AAIA,MAAa,sBAAsB;
|
|
1
|
+
{"version":3,"file":"ActionTriggerAccessory.js","sourceRoot":"","sources":["../../src/Accesories/ActionTriggerAccessory.ts"],"names":[],"mappings":";;;AAIA,MAAa,sBAAsB;IAIjC,YACmB,QAAuB,EACvB,SAA4B,EAC5B,OAA4B;QAF5B,aAAQ,GAAR,QAAQ,CAAe;QACvB,cAAS,GAAT,SAAS,CAAmB;QAC5B,YAAO,GAAP,OAAO,CAAqB;QALvC,cAAS,GAAG,IAAI,CAAC;QAOvB,IAAI,CAAC,SAAS,CAAC,UA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AAC,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;YAChE,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAC/B,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,WAAW,EACxC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACvB,CAAC;QACJ,CAAC,EACD,IAAI,CAAC,SAAS,CAAC,IAAI,CACpB,CAAC;IACJ,CAAC;IAEO,UAAU,CAAC,OAAe;QAChC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC3C,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9C,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,uBAAuB,CAAC,YAAY,CAAC;QAC3E,CAAC;QACD,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACtE,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,uBAAuB,CAAC,UAAU,CAAC;QACzE,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,uBAAuB,CAAC,YAAY,CAAC;IAC3E,CAAC;CACF;AApDD,wDAoDC"}
|
|
@@ -7,12 +7,10 @@ export declare class AirQualityAccessory {
|
|
|
7
7
|
private readonly context;
|
|
8
8
|
private service;
|
|
9
9
|
private value;
|
|
10
|
-
private connected
|
|
11
|
-
private hasValue;
|
|
10
|
+
private connected;
|
|
12
11
|
private kind;
|
|
13
12
|
constructor(platform: SuplaPlatform, accessory: PlatformAccessory, context: SuplaChannelContext);
|
|
14
13
|
handleAirQualityGet(): Promise<CharacteristicValue>;
|
|
15
|
-
private updateFault;
|
|
16
14
|
private updateMeasurements;
|
|
17
15
|
private resolveKind;
|
|
18
16
|
private toAirQuality;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AirQualityAccessory.d.ts","sourceRoot":"","sources":["../../src/Accesories/AirQualityAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAIrE,qBAAa,mBAAmB;
|
|
1
|
+
{"version":3,"file":"AirQualityAccessory.d.ts","sourceRoot":"","sources":["../../src/Accesories/AirQualityAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAIrE,qBAAa,mBAAmB;IAO5B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAR1B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,IAAI,CAAiB;gBAGV,QAAQ,EAAE,aAAa,EACvB,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,mBAAmB;IAuCzC,mBAAmB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAIzD,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,YAAY;CA8BrB"}
|
|
@@ -7,12 +7,8 @@ class AirQualityAccessory {
|
|
|
7
7
|
this.accessory = accessory;
|
|
8
8
|
this.context = context;
|
|
9
9
|
this.value = 0;
|
|
10
|
-
this.
|
|
10
|
+
this.connected = true;
|
|
11
11
|
this.kind = this.resolveKind();
|
|
12
|
-
// Caption heuristics are only a legacy bootstrap. Persist the selected
|
|
13
|
-
// measurement semantics so a later channel rename cannot silently switch
|
|
14
|
-
// PM10 thresholds/characteristics to PM2.5 (or vice versa) after restart.
|
|
15
|
-
this.accessory.context.suplaAirQualityKind = this.kind;
|
|
16
12
|
this.accessory.getService(this.platform.Service.AccessoryInformation)
|
|
17
13
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'Supla')
|
|
18
14
|
.setCharacteristic(this.platform.Characteristic.Model, 'AirQualitySensor');
|
|
@@ -22,43 +18,20 @@ class AirQualityAccessory {
|
|
|
22
18
|
this.service.getCharacteristic(this.platform.Characteristic.AirQuality)
|
|
23
19
|
.onGet(this.handleAirQualityGet.bind(this));
|
|
24
20
|
this.platform.registerMqttHandler(`${this.context.topic}/state/value`, (message) => {
|
|
25
|
-
const value =
|
|
26
|
-
if (value
|
|
21
|
+
const value = parseFloat(message.toString());
|
|
22
|
+
if (!Number.isNaN(value)) {
|
|
27
23
|
this.value = value;
|
|
28
|
-
this.hasValue = true;
|
|
29
24
|
this.updateMeasurements();
|
|
30
|
-
this.updateFault();
|
|
31
25
|
}
|
|
32
26
|
}, this.accessory.UUID);
|
|
33
27
|
this.platform.registerMqttHandler(`${this.context.topic}/state/connected`, (message) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
this.connected = connected;
|
|
39
|
-
if (!connected) {
|
|
40
|
-
this.hasValue = false;
|
|
41
|
-
}
|
|
42
|
-
this.updateFault();
|
|
43
|
-
}, this.accessory.UUID);
|
|
44
|
-
this.platform.registerMqttTransportHandler?.((transportConnected) => {
|
|
45
|
-
if (!transportConnected) {
|
|
46
|
-
this.connected = undefined;
|
|
47
|
-
this.hasValue = false;
|
|
48
|
-
this.updateFault();
|
|
49
|
-
}
|
|
28
|
+
this.connected = this.platform.parseBoolean(message.toString());
|
|
29
|
+
this.service.updateCharacteristic(this.platform.Characteristic.StatusFault, this.connected ? 0 : 1);
|
|
50
30
|
}, this.accessory.UUID);
|
|
51
|
-
this.updateFault();
|
|
52
31
|
}
|
|
53
32
|
async handleAirQualityGet() {
|
|
54
|
-
if (this.connected !== true || !this.hasValue) {
|
|
55
|
-
throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
56
|
-
}
|
|
57
33
|
return this.toAirQuality(this.value);
|
|
58
34
|
}
|
|
59
|
-
updateFault() {
|
|
60
|
-
this.service.updateCharacteristic(this.platform.Characteristic.StatusFault, this.connected === true && this.hasValue ? 0 : 1);
|
|
61
|
-
}
|
|
62
35
|
updateMeasurements() {
|
|
63
36
|
if (this.kind === 'pm25') {
|
|
64
37
|
this.service.updateCharacteristic(this.platform.Characteristic.PM2_5Density, this.value);
|
|
@@ -69,21 +42,6 @@ class AirQualityAccessory {
|
|
|
69
42
|
this.service.updateCharacteristic(this.platform.Characteristic.AirQuality, this.toAirQuality(this.value));
|
|
70
43
|
}
|
|
71
44
|
resolveKind() {
|
|
72
|
-
const persisted = this.accessory.context.suplaAirQualityKind;
|
|
73
|
-
if (persisted === 'pm10' || persisted === 'pm25') {
|
|
74
|
-
return persisted;
|
|
75
|
-
}
|
|
76
|
-
const functionName = (this.context.channelFunction ?? '')
|
|
77
|
-
.toUpperCase()
|
|
78
|
-
.replace(/[^A-Z0-9]+/g, '');
|
|
79
|
-
if (functionName.includes('PM10')) {
|
|
80
|
-
return 'pm10';
|
|
81
|
-
}
|
|
82
|
-
if (functionName.includes('PM25') || functionName.includes('PM2')) {
|
|
83
|
-
return 'pm25';
|
|
84
|
-
}
|
|
85
|
-
// Old Supla metadata can expose only GENERAL_PURPOSE_MEASUREMENT. Retain
|
|
86
|
-
// the former caption inference once, then use the persisted value above.
|
|
87
45
|
const caption = (this.context.channelCaption ?? '').toLowerCase();
|
|
88
46
|
if (caption.includes('pm10')) {
|
|
89
47
|
return 'pm10';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AirQualityAccessory.js","sourceRoot":"","sources":["../../src/Accesories/AirQualityAccessory.ts"],"names":[],"mappings":";;;AAMA,MAAa,mBAAmB;
|
|
1
|
+
{"version":3,"file":"AirQualityAccessory.js","sourceRoot":"","sources":["../../src/Accesories/AirQualityAccessory.ts"],"names":[],"mappings":";;;AAMA,MAAa,mBAAmB;IAM9B,YACmB,QAAuB,EACvB,SAA4B,EAC5B,OAA4B;QAF5B,aAAQ,GAAR,QAAQ,CAAe;QACvB,cAAS,GAAT,SAAS,CAAmB;QAC5B,YAAO,GAAP,OAAO,CAAqB;QAPvC,UAAK,GAAG,CAAC,CAAC;QACV,cAAS,GAAG,IAAI,CAAC;QAQvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAC/B,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,oBAAoB,CAAE;aACnE,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,EAAE,OAAO,CAAC;aACrE,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;QAE7E,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC;eAC3E,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAEvE,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;QAEzF,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC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ACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC;YACtD,CAAC;YACD,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;gBACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,QAAQ,CAAC;YAC1D,CAAC;YACD,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC;QACtD,CAAC;QACD,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,SAAS,CAAC;QAC3D,CAAC;QACD,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC;QACtD,CAAC;QACD,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC;QACtD,CAAC;QACD,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,QAAQ,CAAC;QAC1D,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC;IACtD,CAAC;CACF;AAtGD,kDAsGC"}
|
|
@@ -7,10 +7,8 @@ export declare class ContactSensorAccessory {
|
|
|
7
7
|
private readonly context;
|
|
8
8
|
private service;
|
|
9
9
|
private state;
|
|
10
|
-
private connected
|
|
11
|
-
private hasState;
|
|
10
|
+
private connected;
|
|
12
11
|
constructor(platform: SuplaPlatform, accessory: PlatformAccessory, context: SuplaChannelContext);
|
|
13
12
|
handleStateGet(): Promise<CharacteristicValue>;
|
|
14
|
-
private updateFault;
|
|
15
13
|
}
|
|
16
14
|
//# sourceMappingURL=ContactSensorAccessory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContactSensorAccessory.d.ts","sourceRoot":"","sources":["../../src/Accesories/ContactSensorAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE,qBAAa,sBAAsB;
|
|
1
|
+
{"version":3,"file":"ContactSensorAccessory.d.ts","sourceRoot":"","sources":["../../src/Accesories/ContactSensorAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE,qBAAa,sBAAsB;IAM/B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAP1B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,KAAK,CAAoE;IACjF,OAAO,CAAC,SAAS,CAAQ;gBAGN,QAAQ,EAAE,aAAa,EACvB,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,mBAAmB;IAsCzC,cAAc,IAAI,OAAO,CAAC,mBAAmB,CAAC;CAGrD"}
|
|
@@ -7,7 +7,7 @@ class ContactSensorAccessory {
|
|
|
7
7
|
this.accessory = accessory;
|
|
8
8
|
this.context = context;
|
|
9
9
|
this.state = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
|
|
10
|
-
this.
|
|
10
|
+
this.connected = true;
|
|
11
11
|
this.accessory.getService(this.platform.Service.AccessoryInformation)
|
|
12
12
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'Supla')
|
|
13
13
|
.setCharacteristic(this.platform.Characteristic.Model, 'ContactSensor');
|
|
@@ -17,48 +17,20 @@ class ContactSensorAccessory {
|
|
|
17
17
|
this.service.getCharacteristic(this.platform.Characteristic.ContactSensorState)
|
|
18
18
|
.onGet(this.handleStateGet.bind(this));
|
|
19
19
|
this.platform.registerMqttHandler(`${this.context.topic}/state/hi`, (message) => {
|
|
20
|
-
const closed = this.platform.
|
|
21
|
-
if (closed === undefined) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
this.hasState = true;
|
|
20
|
+
const closed = this.platform.parseBoolean(message.toString());
|
|
25
21
|
this.state = closed
|
|
26
22
|
? this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED
|
|
27
23
|
: this.platform.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED;
|
|
28
24
|
this.service.updateCharacteristic(this.platform.Characteristic.ContactSensorState, this.state);
|
|
29
|
-
this.updateFault();
|
|
30
25
|
}, this.accessory.UUID);
|
|
31
26
|
this.platform.registerMqttHandler(`${this.context.topic}/state/connected`, (message) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
this.connected = connected;
|
|
37
|
-
if (!connected) {
|
|
38
|
-
this.hasState = false;
|
|
39
|
-
}
|
|
40
|
-
this.updateFault();
|
|
27
|
+
this.connected = this.platform.parseBoolean(message.toString());
|
|
28
|
+
this.service.updateCharacteristic(this.platform.Characteristic.StatusFault, this.connected ? 0 : 1);
|
|
41
29
|
}, this.accessory.UUID);
|
|
42
|
-
this.platform.registerMqttTransportHandler?.((transportConnected) => {
|
|
43
|
-
if (!transportConnected) {
|
|
44
|
-
this.connected = undefined;
|
|
45
|
-
this.hasState = false;
|
|
46
|
-
this.updateFault();
|
|
47
|
-
}
|
|
48
|
-
}, this.accessory.UUID);
|
|
49
|
-
this.updateFault();
|
|
50
30
|
}
|
|
51
31
|
async handleStateGet() {
|
|
52
|
-
if (this.connected !== true || !this.hasState) {
|
|
53
|
-
throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
54
|
-
}
|
|
55
32
|
return this.state;
|
|
56
33
|
}
|
|
57
|
-
updateFault() {
|
|
58
|
-
this.service.updateCharacteristic(this.platform.Characteristic.StatusFault, this.connected === true && this.hasState
|
|
59
|
-
? this.platform.Characteristic.StatusFault.NO_FAULT
|
|
60
|
-
: this.platform.Characteristic.StatusFault.GENERAL_FAULT);
|
|
61
|
-
}
|
|
62
34
|
}
|
|
63
35
|
exports.ContactSensorAccessory = ContactSensorAccessory;
|
|
64
36
|
//# sourceMappingURL=ContactSensorAccessory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContactSensorAccessory.js","sourceRoot":"","sources":["../../src/Accesories/ContactSensorAccessory.ts"],"names":[],"mappings":";;;AAIA,MAAa,sBAAsB;
|
|
1
|
+
{"version":3,"file":"ContactSensorAccessory.js","sourceRoot":"","sources":["../../src/Accesories/ContactSensorAccessory.ts"],"names":[],"mappings":";;;AAIA,MAAa,sBAAsB;IAKjC,YACmB,QAAuB,EACvB,SAA4B,EAC5B,OAA4B;QAF5B,aAAQ,GAAR,QAAQ,CAAe;QACvB,cAAS,GAAT,SAAS,CAAmB;QAC5B,YAAO,GAAP,OAAO,CAAqB;QANvC,UAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,kBAAkB,CAAC,gBAAgB,CAAC;QACzE,cAAS,GAAG,IAAI,CAAC;QAOvB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,oBAAoB,CAAE;aACnE,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,EAAE,OAAO,CAAC;aACrE,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,eAAe,CAAC,C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