homebridge-netatmo-security-mk 1.0.2
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/LICENSE +176 -0
- package/README.md +50 -0
- package/config.schema.json +88 -0
- package/dist/accessory/indoorSirenAccessory.d.ts +11 -0
- package/dist/accessory/indoorSirenAccessory.d.ts.map +1 -0
- package/dist/accessory/indoorSirenAccessory.js +66 -0
- package/dist/accessory/indoorSirenAccessory.js.map +1 -0
- package/dist/accessory/tagSensorAccessory.d.ts +12 -0
- package/dist/accessory/tagSensorAccessory.d.ts.map +1 -0
- package/dist/accessory/tagSensorAccessory.js +67 -0
- package/dist/accessory/tagSensorAccessory.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/platform.d.ts +17 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +108 -0
- package/dist/platform.js.map +1 -0
- package/dist/settings.d.ts +3 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +9 -0
- package/dist/settings.js.map +1 -0
- package/dist/util/LegacyAPI.d.ts +2 -0
- package/dist/util/LegacyAPI.d.ts.map +1 -0
- package/dist/util/LegacyAPI.js +28 -0
- package/dist/util/LegacyAPI.js.map +1 -0
- package/dist/util/NetatmoAPI.d.ts +23 -0
- package/dist/util/NetatmoAPI.d.ts.map +1 -0
- package/dist/util/NetatmoAPI.js +185 -0
- package/dist/util/NetatmoAPI.js.map +1 -0
- package/dist/util/Webhook.d.ts +1 -0
- package/dist/util/Webhook.d.ts.map +1 -0
- package/dist/util/Webhook.js +25 -0
- package/dist/util/Webhook.js.map +1 -0
- package/dist/util/axios.d.ts +3 -0
- package/dist/util/axios.d.ts.map +1 -0
- package/dist/util/axios.js +10 -0
- package/dist/util/axios.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://github.com/homebridge/branding/raw/master/logos/homebridge-wordmark-logo-vertical.png" width="150">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# Homebridge Netatmo Security MK
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/homebridge-netatmo-security-mk)
|
|
8
|
+
|
|
9
|
+
## About plugin
|
|
10
|
+
Get extended HomeKit support for Netatmo Security products — exposing **door/window tags as Contact Sensors**, plus the indoor siren.
|
|
11
|
+
|
|
12
|
+
This is a personal fork of [Anzure/homebridge-netatmo-security](https://github.com/Anzure/homebridge-netatmo-security) (Apache-2.0), published under the `-mk` name. The main change versus upstream is **OAuth2 refresh-token authentication** (Netatmo removed the password login), with on-disk token persistence and rotation.
|
|
13
|
+
|
|
14
|
+
Supported or partially supported accessories:
|
|
15
|
+
- Netatmo Door/Window Tag → HomeKit Contact Sensor
|
|
16
|
+
- Netatmo Indoor Siren
|
|
17
|
+
- Netatmo Welcome
|
|
18
|
+
|
|
19
|
+
## Getting started
|
|
20
|
+
|
|
21
|
+
### 1. Create a Netatmo app (Client ID / Secret)
|
|
22
|
+
1. Sign in to https://dev.netatmo.com (or create an account).
|
|
23
|
+
2. Create a new application: https://dev.netatmo.com/apps
|
|
24
|
+
3. Note your **Client ID** and **Client Secret**.
|
|
25
|
+
|
|
26
|
+
### 2. Generate a refresh token
|
|
27
|
+
Netatmo no longer supports password login, so this plugin authenticates with an OAuth2 **refresh token**:
|
|
28
|
+
1. On your app page, use the **Token generator**.
|
|
29
|
+
2. Select at least the **`read_camera`** scope (required for tags and events); add **`write_camera`** if you want siren control.
|
|
30
|
+
3. Copy the generated **refresh token**.
|
|
31
|
+
|
|
32
|
+
The refresh token is only used on first start: the plugin then rotates and persists it automatically in the Homebridge storage directory (`netatmo-security-token.json`).
|
|
33
|
+
|
|
34
|
+
More information: https://dev.netatmo.com/apidocumentation/oauth
|
|
35
|
+
|
|
36
|
+
### 3. Install plugin
|
|
37
|
+
Install from npm:
|
|
38
|
+
```
|
|
39
|
+
npm install -g homebridge-netatmo-security-mk
|
|
40
|
+
```
|
|
41
|
+
or point Homebridge Config UI X to this GitHub repository.
|
|
42
|
+
|
|
43
|
+
### 4. Configure plugin
|
|
44
|
+
Fill in **Client ID**, **Client Secret** and **Refresh Token** in the plugin settings, then save.
|
|
45
|
+
|
|
46
|
+
### 5. Restart Homebridge
|
|
47
|
+
Restart Homebridge after setting up or making changes.
|
|
48
|
+
|
|
49
|
+
## Credits
|
|
50
|
+
Forked from [Anzure/homebridge-netatmo-security](https://github.com/Anzure/homebridge-netatmo-security). Licensed under Apache-2.0.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pluginAlias": "netatmo-security",
|
|
3
|
+
"pluginType": "platform",
|
|
4
|
+
"singular": true,
|
|
5
|
+
"schema": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"name": {
|
|
9
|
+
"title": "Name",
|
|
10
|
+
"type": "string",
|
|
11
|
+
"required": true,
|
|
12
|
+
"default": "Netatmo Security Platform",
|
|
13
|
+
"description": "Plugin display name"
|
|
14
|
+
},
|
|
15
|
+
"client_id": {
|
|
16
|
+
"title": "Client ID",
|
|
17
|
+
"type": "string",
|
|
18
|
+
"required": true,
|
|
19
|
+
"default": "",
|
|
20
|
+
"placeholder": "Generated client id from dev.netatmo.com/apps",
|
|
21
|
+
"description": "OAuth 2.0 client for Netatmo API app"
|
|
22
|
+
},
|
|
23
|
+
"client_secret": {
|
|
24
|
+
"title": "Client Secret",
|
|
25
|
+
"type": "string",
|
|
26
|
+
"required": true,
|
|
27
|
+
"default": "",
|
|
28
|
+
"condition": {
|
|
29
|
+
"functionBody": "return model.hide_client_secret === false || model.hide_client_secret.length <= 0;"
|
|
30
|
+
},
|
|
31
|
+
"placeholder": "Generated client secret from dev.netatmo.com/apps",
|
|
32
|
+
"description": "OAuth 2.0 secret for Netatmo API app"
|
|
33
|
+
},
|
|
34
|
+
"hide_client_secret": {
|
|
35
|
+
"title": "Hide Client Secret?",
|
|
36
|
+
"type": "boolean",
|
|
37
|
+
"default": false,
|
|
38
|
+
"required": true,
|
|
39
|
+
"condition": {
|
|
40
|
+
"functionBody": "return model.client_secret != null && model.client_secret.length > 0;"
|
|
41
|
+
},
|
|
42
|
+
"description": "Secure client secret by hiding it"
|
|
43
|
+
},
|
|
44
|
+
"refresh_token": {
|
|
45
|
+
"title": "Refresh Token",
|
|
46
|
+
"type": "string",
|
|
47
|
+
"required": true,
|
|
48
|
+
"default": "",
|
|
49
|
+
"placeholder": "Generated refresh token from dev.netatmo.com",
|
|
50
|
+
"description": "OAuth2 refresh token. Netatmo no longer supports password login: generate this with the token generator on your app at dev.netatmo.com (scope read_camera, plus write_camera for siren control). Used only on first start — the plugin then rotates and persists it automatically."
|
|
51
|
+
},
|
|
52
|
+
"webhook_scheme": {
|
|
53
|
+
"title": "Webhook Scheme",
|
|
54
|
+
"type": "string",
|
|
55
|
+
"default": "http",
|
|
56
|
+
"oneOf": [
|
|
57
|
+
{ "title": "Use HTTP", "enum": ["http"] },
|
|
58
|
+
{ "title": "Use HTTPS", "enum": ["https"] }
|
|
59
|
+
],
|
|
60
|
+
"description": "Web protocol used in URL",
|
|
61
|
+
"required": true
|
|
62
|
+
},
|
|
63
|
+
"webhook_host": {
|
|
64
|
+
"title": "Webhook Host",
|
|
65
|
+
"type": "string",
|
|
66
|
+
"required": false,
|
|
67
|
+
"default": "",
|
|
68
|
+
"placeholder": "xx.xx.xx.xx",
|
|
69
|
+
"description": "Public IP or Domain"
|
|
70
|
+
},
|
|
71
|
+
"webhook_port": {
|
|
72
|
+
"title": "Webhook Port",
|
|
73
|
+
"type": "string",
|
|
74
|
+
"required": false,
|
|
75
|
+
"default": "",
|
|
76
|
+
"placeholder": "3000",
|
|
77
|
+
"description": "Local listen port"
|
|
78
|
+
},
|
|
79
|
+
"enable_webhook": {
|
|
80
|
+
"title": "Enable Webhook?",
|
|
81
|
+
"type": "boolean",
|
|
82
|
+
"default": false,
|
|
83
|
+
"required": false,
|
|
84
|
+
"description": "Requires port forwarding"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
2
|
+
import { NetatmoSecurityPlatform } from '../platform';
|
|
3
|
+
export declare class IndoorSirenAccessory {
|
|
4
|
+
private readonly platform;
|
|
5
|
+
private readonly accessory;
|
|
6
|
+
private service;
|
|
7
|
+
private state;
|
|
8
|
+
constructor(platform: NetatmoSecurityPlatform, accessory: PlatformAccessory);
|
|
9
|
+
isMuted(): Promise<CharacteristicValue>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=indoorSirenAccessory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indoorSirenAccessory.d.ts","sourceRoot":"","sources":["../../src/accessory/indoorSirenAccessory.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,qBAAa,oBAAoB;IAS7B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAT5B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,KAAK,CAGX;gBAIiB,QAAQ,EAAE,uBAAuB,EACjC,SAAS,EAAE,iBAAiB;IA0DzC,OAAO,IAAI,OAAO,CAAC,mBAAmB,CAAC;CAM9C"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IndoorSirenAccessory = void 0;
|
|
4
|
+
class IndoorSirenAccessory {
|
|
5
|
+
// Load device
|
|
6
|
+
constructor(platform, accessory) {
|
|
7
|
+
this.platform = platform;
|
|
8
|
+
this.accessory = accessory;
|
|
9
|
+
this.state = {
|
|
10
|
+
SoundStatus: 'no_sound',
|
|
11
|
+
TamperStatus: 0,
|
|
12
|
+
};
|
|
13
|
+
this.accessory.getService(this.platform.Service.AccessoryInformation)
|
|
14
|
+
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'Netatmo-Security')
|
|
15
|
+
.setCharacteristic(this.platform.Characteristic.Model, 'Indoor-Siren')
|
|
16
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, this.accessory.context.device.id);
|
|
17
|
+
this.service = this.accessory.getService(this.platform.Service.Speaker)
|
|
18
|
+
|| this.accessory.addService(this.platform.Service.Speaker);
|
|
19
|
+
this.service.setCharacteristic(this.platform.Characteristic.Name, this.accessory.context.device.name);
|
|
20
|
+
this.service.getCharacteristic(this.platform.Characteristic.Mute)
|
|
21
|
+
/*.onSet(this.setMuted.bind(this))*/
|
|
22
|
+
.onGet(this.isMuted.bind(this));
|
|
23
|
+
setInterval(() => {
|
|
24
|
+
try {
|
|
25
|
+
const soundDetected = this.accessory.context.device.status !== 'no_sound';
|
|
26
|
+
if (this.accessory.context.device.status !== this.state.SoundStatus) {
|
|
27
|
+
this.platform.log.info(accessory.displayName + ' Sound Status: ' + soundDetected + ' (' + this.state.SoundStatus + ' -> ' + this.accessory.context.device.status + ')');
|
|
28
|
+
}
|
|
29
|
+
this.state.SoundStatus = this.accessory.context.device.status;
|
|
30
|
+
this.service.updateCharacteristic(this.platform.Characteristic.Mute, !soundDetected);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
this.platform.log.error('Failed to update siren sound status', error);
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const timeTampered = this.accessory.context.device.activity ? this.accessory.context.device.activity : 0;
|
|
37
|
+
const minimumTime = (new Date().getTime() / 1000) - 90;
|
|
38
|
+
const tamperingDetected = timeTampered > this.state.TamperStatus || timeTampered > minimumTime;
|
|
39
|
+
if (this.accessory.context.device.activity !== this.state.TamperStatus) {
|
|
40
|
+
this.platform.log.info(accessory.displayName + ' Tampered Status: ' + tamperingDetected + ' (' + this.state.TamperStatus + ' -> ' + this.accessory.context.device.activity + ')');
|
|
41
|
+
}
|
|
42
|
+
else if (tamperingDetected === true) {
|
|
43
|
+
this.platform.log.debug(accessory.displayName + ' Tampered Status: ' + tamperingDetected + ' (' + this.state.TamperStatus + ' -> ' + this.accessory.context.device.activity + ')');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
this.platform.log.error('Failed to update tampered sensor status', error);
|
|
48
|
+
}
|
|
49
|
+
}, 5000);
|
|
50
|
+
}
|
|
51
|
+
/*async setMuted(value: CharacteristicValue) {
|
|
52
|
+
const sound = value ? 'no_sound' : 'warning';
|
|
53
|
+
this.platform.log.info(this.accessory.displayName + ' Sound Characteristic: ' + sound + ' (' + this.state.SoundStatus + ' / ' + this.accessory.context.device.status + ')');
|
|
54
|
+
this.platform.netatmoAPI.setState(this.accessory.context.device, sound).then(() => {
|
|
55
|
+
this.state.SoundStatus = sound;
|
|
56
|
+
this.service.updateCharacteristic(this.platform.Characteristic.Mute, value);
|
|
57
|
+
});
|
|
58
|
+
}*/
|
|
59
|
+
async isMuted() {
|
|
60
|
+
const playing = this.state.SoundStatus === 'no_sound' && this.accessory.context.device.status === 'no_sound';
|
|
61
|
+
this.platform.log.debug(this.accessory.displayName + ' Sound Characteristic: ' + playing + ' (' + this.state.SoundStatus + ' / ' + this.accessory.context.device.status + ')');
|
|
62
|
+
return playing;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.IndoorSirenAccessory = IndoorSirenAccessory;
|
|
66
|
+
//# sourceMappingURL=indoorSirenAccessory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indoorSirenAccessory.js","sourceRoot":"","sources":["../../src/accessory/indoorSirenAccessory.ts"],"names":[],"mappings":";;;AAIA,MAAa,oBAAoB;IAO/B,cAAc;IACd,YACmB,QAAiC,EACjC,SAA4B;QAD5B,aAAQ,GAAR,QAAQ,CAAyB;QACjC,cAAS,GAAT,SAAS,CAAmB;QARvC,UAAK,GAAG;YACd,WAAW,EAAE,UAAU;YACvB,YAAY,EAAE,CAAC;SAChB,CAAC;QAOA,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,kBAAkB,CAAC;aAChF,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,KA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AAG,iBAAiB,GAAG,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC;iBACpL;aAEF;YAAC,OAAO,KAAK,EAAC;gBACb,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,yCAAyC,EAAE,KAAK,CAAC,CAAC;aAC3E;QAEH,CAAC,EAAE,IAAI,CAAC,CAAC;IACX,CAAC;IAED;;;;;;;OAOG;IAEH,KAAK,CAAC,OAAO;QACX,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,KAAK,UAAU,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,KAAK,UAAU,CAAC;QAC7G,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,GAAG,yBAAyB,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;QAC/K,OAAO,OAAO,CAAC;IACjB,CAAC;CAEF;AA1ED,oDA0EC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
2
|
+
import { NetatmoSecurityPlatform } from '../platform';
|
|
3
|
+
export declare class TagSensorAccessory {
|
|
4
|
+
private readonly platform;
|
|
5
|
+
private readonly accessory;
|
|
6
|
+
private service;
|
|
7
|
+
private state;
|
|
8
|
+
constructor(platform: NetatmoSecurityPlatform, accessory: PlatformAccessory);
|
|
9
|
+
isTampered(): Promise<CharacteristicValue>;
|
|
10
|
+
isOpen(): Promise<CharacteristicValue>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=tagSensorAccessory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tagSensorAccessory.d.ts","sourceRoot":"","sources":["../../src/accessory/tagSensorAccessory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,qBAAa,kBAAkB;IAS3B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAT5B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,KAAK,CAGX;gBAIiB,QAAQ,EAAE,uBAAuB,EACjC,SAAS,EAAE,iBAAiB;IAqDzC,UAAU,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAO1C,MAAM,IAAI,OAAO,CAAC,mBAAmB,CAAC;CAM7C"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TagSensorAccessory = void 0;
|
|
4
|
+
class TagSensorAccessory {
|
|
5
|
+
// Load device
|
|
6
|
+
constructor(platform, accessory) {
|
|
7
|
+
this.platform = platform;
|
|
8
|
+
this.accessory = accessory;
|
|
9
|
+
this.state = {
|
|
10
|
+
SensorStatus: 'unknown',
|
|
11
|
+
TamperStatus: 0,
|
|
12
|
+
};
|
|
13
|
+
this.accessory.getService(this.platform.Service.AccessoryInformation)
|
|
14
|
+
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'Netatmo-Security')
|
|
15
|
+
.setCharacteristic(this.platform.Characteristic.Model, 'Tag-Sensor')
|
|
16
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, this.accessory.context.device.id);
|
|
17
|
+
this.service = this.accessory.getService(this.platform.Service.ContactSensor)
|
|
18
|
+
|| this.accessory.addService(this.platform.Service.ContactSensor);
|
|
19
|
+
this.service.setCharacteristic(this.platform.Characteristic.Name, this.accessory.context.device.name);
|
|
20
|
+
this.service.getCharacteristic(this.platform.Characteristic.ContactSensorState)
|
|
21
|
+
.onGet(this.isOpen.bind(this));
|
|
22
|
+
this.service.getCharacteristic(this.platform.Characteristic.StatusTampered)
|
|
23
|
+
.onGet(this.isTampered.bind(this));
|
|
24
|
+
setInterval(() => {
|
|
25
|
+
try {
|
|
26
|
+
const contactDetected = this.accessory.context.device.status === 'open';
|
|
27
|
+
if (this.accessory.context.device.status !== this.state.SensorStatus) {
|
|
28
|
+
this.platform.log.info(accessory.displayName + ' Sensor Status: ' + contactDetected + ' (' + this.state.SensorStatus + ' -> ' + this.accessory.context.device.status + ')');
|
|
29
|
+
}
|
|
30
|
+
this.state.SensorStatus = this.accessory.context.device.status;
|
|
31
|
+
this.service.updateCharacteristic(this.platform.Characteristic.ContactSensorState, contactDetected);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
this.platform.log.error('Failed to update contact sensor status', error);
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const timeTampered = this.accessory.context.device.activity ? this.accessory.context.device.activity : 0;
|
|
38
|
+
const minimumTime = (new Date().getTime() / 1000) - 90;
|
|
39
|
+
const tamperingDetected = timeTampered > this.state.TamperStatus || timeTampered > minimumTime;
|
|
40
|
+
if (this.accessory.context.device.activity !== this.state.TamperStatus) {
|
|
41
|
+
this.platform.log.info(accessory.displayName + ' Tampered Status: ' + tamperingDetected + ' (' + this.state.TamperStatus + ' -> ' + this.accessory.context.device.activity + ')');
|
|
42
|
+
}
|
|
43
|
+
else if (tamperingDetected === true) {
|
|
44
|
+
this.platform.log.debug(accessory.displayName + ' Tampered Status: ' + tamperingDetected + ' (' + this.state.TamperStatus + ' -> ' + this.accessory.context.device.activity + ')');
|
|
45
|
+
}
|
|
46
|
+
this.state.TamperStatus = this.accessory.context.device.activity;
|
|
47
|
+
this.service.updateCharacteristic(this.platform.Characteristic.StatusTampered, tamperingDetected);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
this.platform.log.error('Failed to update tampered sensor status', error);
|
|
51
|
+
}
|
|
52
|
+
}, 5000);
|
|
53
|
+
}
|
|
54
|
+
async isTampered() {
|
|
55
|
+
const minimumTime = (new Date().getTime() / 1000) - 90;
|
|
56
|
+
const isTampered = this.state.TamperStatus > minimumTime || this.accessory.context.device.activity > minimumTime;
|
|
57
|
+
this.platform.log.debug(this.accessory.displayName + ' Tampered Characteristic: ' + isTampered + ' (' + this.state.TamperStatus + ' / ' + this.accessory.context.device.activity + ')');
|
|
58
|
+
return isTampered;
|
|
59
|
+
}
|
|
60
|
+
async isOpen() {
|
|
61
|
+
const isOpen = this.state.SensorStatus === 'open' || this.accessory.context.device.status === 'open';
|
|
62
|
+
this.platform.log.debug(this.accessory.displayName + ' Sensor Characteristic: ' + isOpen + ' (' + this.state.SensorStatus + ' / ' + this.accessory.context.device.status + ')');
|
|
63
|
+
return isOpen;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.TagSensorAccessory = TagSensorAccessory;
|
|
67
|
+
//# sourceMappingURL=tagSensorAccessory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tagSensorAccessory.js","sourceRoot":"","sources":["../../src/accessory/tagSensorAccessory.ts"],"names":[],"mappings":";;;AAKA,MAAa,kBAAkB;IAO7B,cAAc;IACd,YACmB,QAAiC,EACjC,SAA4B;QAD5B,aAAQ,GAAR,QAAQ,CAAyB;QACjC,cAAS,GAAT,SAAS,CAAmB;QARvC,UAAK,GAAG;YACd,YAAY,EAAE,SAAS;YACvB,YAAY,EAAE,CAAC;SAChB,CAAC;QAOA,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,kBAAkB,CAAC;aAChF,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S,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC;QACxL,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,KAAK,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC;QACrG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,GAAG,0BAA0B,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;QAChL,OAAO,MAAM,CAAC;IAChB,CAAC;CAEF;AA5ED,gDA4EC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;8BAIlB,GAAG;AAAlB,kBAEE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,yCAA2C;AAC3C,yCAAqD;AAErD,iBAAS,CAAC,GAAQ,EAAE,EAAE;IACpB,GAAG,CAAC,gBAAgB,CAAC,wBAAa,EAAE,kCAAuB,CAAC,CAAC;AAC/D,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { API, DynamicPlatformPlugin, PlatformAccessory, Logger, PlatformConfig, Service, Characteristic } from 'homebridge';
|
|
2
|
+
import NetatmoAPI from './util/NetatmoAPI';
|
|
3
|
+
export declare class NetatmoSecurityPlatform implements DynamicPlatformPlugin {
|
|
4
|
+
readonly log: Logger;
|
|
5
|
+
readonly config: PlatformConfig;
|
|
6
|
+
readonly api: API;
|
|
7
|
+
readonly Service: typeof Service;
|
|
8
|
+
readonly Characteristic: typeof Characteristic;
|
|
9
|
+
readonly accessories: PlatformAccessory[];
|
|
10
|
+
netatmoAPI: NetatmoAPI;
|
|
11
|
+
constructor(log: Logger, config: PlatformConfig, api: API);
|
|
12
|
+
configureAccessory(accessory: PlatformAccessory): void;
|
|
13
|
+
discoverDevices(): void;
|
|
14
|
+
startRefreshTask(): void;
|
|
15
|
+
refreshStatus(): void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=platform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5H,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAG3C,qBAAa,uBAAwB,YAAW,qBAAqB;aAQjD,GAAG,EAAE,MAAM;aACX,MAAM,EAAE,cAAc;aACtB,GAAG,EAAE,GAAG;IAT1B,SAAgB,OAAO,EAAE,OAAO,OAAO,CAAwB;IAC/D,SAAgB,cAAc,EAAE,OAAO,cAAc,CAA+B;IACpF,SAAgB,WAAW,EAAE,iBAAiB,EAAE,CAAM;IAC/C,UAAU,EAAE,UAAU,CAAC;gBAIZ,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,GAAG;IAoB1B,kBAAkB,CAAC,SAAS,EAAE,iBAAiB;IAe/C,eAAe;IA+Bf,gBAAgB;IAWhB,aAAa;CAmBd"}
|
package/dist/platform.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NetatmoSecurityPlatform = void 0;
|
|
7
|
+
const settings_1 = require("./settings");
|
|
8
|
+
const tagSensorAccessory_1 = require("./accessory/tagSensorAccessory");
|
|
9
|
+
const NetatmoAPI_1 = __importDefault(require("./util/NetatmoAPI"));
|
|
10
|
+
const indoorSirenAccessory_1 = require("./accessory/indoorSirenAccessory");
|
|
11
|
+
class NetatmoSecurityPlatform {
|
|
12
|
+
// Load platform
|
|
13
|
+
constructor(log, config, api) {
|
|
14
|
+
this.log = log;
|
|
15
|
+
this.config = config;
|
|
16
|
+
this.api = api;
|
|
17
|
+
this.Service = this.api.hap.Service;
|
|
18
|
+
this.Characteristic = this.api.hap.Characteristic;
|
|
19
|
+
this.accessories = [];
|
|
20
|
+
log.debug('Finished loading platform:', this.config.name);
|
|
21
|
+
this.netatmoAPI = new NetatmoAPI_1.default(log, this.api.user.storagePath());
|
|
22
|
+
log.debug('Finished initializing platform:', this.config.name);
|
|
23
|
+
this.api.on('didFinishLaunching', () => {
|
|
24
|
+
log.debug('Executed didFinishLaunching callback');
|
|
25
|
+
log.debug('Authenticating with provider:', this.config.name);
|
|
26
|
+
this.netatmoAPI.init(config).then(() => {
|
|
27
|
+
log.debug('Authenticated with provider:', this.config.name);
|
|
28
|
+
this.discoverDevices();
|
|
29
|
+
this.startRefreshTask();
|
|
30
|
+
log.debug('Config loaded: ' + JSON.stringify({ ...config, refresh_token: '******', client_secret: '********' }));
|
|
31
|
+
}).catch((error) => {
|
|
32
|
+
var _a;
|
|
33
|
+
log.error('Netatmo authentication failed, plugin disabled until restart: ' + ((_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error));
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
// Configure device
|
|
38
|
+
configureAccessory(accessory) {
|
|
39
|
+
if (accessory.context.device.type === 'NIS') {
|
|
40
|
+
this.log.debug('Loading accessory from cache:', accessory.displayName);
|
|
41
|
+
new indoorSirenAccessory_1.IndoorSirenAccessory(this, accessory);
|
|
42
|
+
this.accessories.push(accessory);
|
|
43
|
+
}
|
|
44
|
+
else if (accessory.context.device.type === 'NACamDoorTag') {
|
|
45
|
+
this.log.debug('Loading accessory from cache:', accessory.displayName);
|
|
46
|
+
new tagSensorAccessory_1.TagSensorAccessory(this, accessory);
|
|
47
|
+
this.accessories.push(accessory);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.log.debug('Device type not supported: ' + accessory.context.device.type);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Load devices
|
|
54
|
+
discoverDevices() {
|
|
55
|
+
this.netatmoAPI.getHomeDevices().then((devices) => {
|
|
56
|
+
for (const device of devices) {
|
|
57
|
+
if (device.type !== 'NACamDoorTag' && device.type !== 'NIS') {
|
|
58
|
+
this.log.debug('Skipped unsupported accessory: ' + device.name);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
device.name = device.name.trimEnd();
|
|
62
|
+
const uuid = this.api.hap.uuid.generate(device.id);
|
|
63
|
+
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
64
|
+
if (existingAccessory) {
|
|
65
|
+
this.log.debug('Existing accessory discovered: ' + existingAccessory.displayName);
|
|
66
|
+
this.configureAccessory(existingAccessory);
|
|
67
|
+
existingAccessory.context.device = device;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
this.log.debug('Adding newly discovered accessory: ' + device.name);
|
|
71
|
+
const accessory = new this.api.platformAccessory(device.name, uuid);
|
|
72
|
+
accessory.context.device = device;
|
|
73
|
+
this.configureAccessory(accessory);
|
|
74
|
+
this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
// Refresh task
|
|
80
|
+
startRefreshTask() {
|
|
81
|
+
setInterval(() => {
|
|
82
|
+
try {
|
|
83
|
+
this.refreshStatus();
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
this.log.error('Failed to refresh status: ' + this.config.name, error);
|
|
87
|
+
}
|
|
88
|
+
}, 20000);
|
|
89
|
+
}
|
|
90
|
+
// Refresh status
|
|
91
|
+
refreshStatus() {
|
|
92
|
+
this.netatmoAPI.getHomeDevices().then((devices) => {
|
|
93
|
+
for (const device of devices) {
|
|
94
|
+
if (device.type !== 'NACamDoorTag' && device.type !== 'NIS') {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const uuid = this.api.hap.uuid.generate(device.id);
|
|
98
|
+
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
99
|
+
if (existingAccessory) {
|
|
100
|
+
existingAccessory.context.device = device;
|
|
101
|
+
this.accessories.push(existingAccessory);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.NetatmoSecurityPlatform = NetatmoSecurityPlatform;
|
|
108
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAwD;AACxD,uEAAoE;AACpE,mEAA2C;AAC3C,2EAAwE;AAExE,MAAa,uBAAuB;IAMlC,gBAAgB;IAChB,YACkB,GAAW,EACX,MAAsB,EACtB,GAAQ;QAFR,QAAG,GAAH,GAAG,CAAQ;QACX,WAAM,GAAN,MAAM,CAAgB;QACtB,QAAG,GAAH,GAAG,CAAK;QATV,YAAO,GAAmB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/C,mBAAc,GAA0B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,c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CAAC,OAAO,EAAE,EAAE;YAChD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;gBAE5B,IAAI,MAAM,CAAC,IAAI,KAAK,cAAc,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,EAAE;oBAC3D,SAAS;iBACV;gBAED,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;gBACnD,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;gBAEtF,IAAI,iBAAiB,EAAE;oBACrB,iBAAiB,CAAC,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;oBAC1C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;iBAC1C;aACF;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CAEF;AA1GD,0DA0GC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,qBAAqB,CAAC;AAIhD,eAAO,MAAM,WAAW,mCAAmC,CAAC"}
|
package/dist/settings.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PLUGIN_NAME = exports.PLATFORM_NAME = void 0;
|
|
4
|
+
exports.PLATFORM_NAME = 'netatmo-security';
|
|
5
|
+
// MUST equal the "name" in package.json. With the 2-arg registerPlatform(),
|
|
6
|
+
// Homebridge stamps registered accessories with this plugin name; a mismatch makes
|
|
7
|
+
// it re-create every accessory on each restart (see homebridge-tahoma bug C6).
|
|
8
|
+
exports.PLUGIN_NAME = 'homebridge-netatmo-security-mk';
|
|
9
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,kBAAkB,CAAC;AAChD,4EAA4E;AAC5E,mFAAmF;AACnF,+EAA+E;AAClE,QAAA,WAAW,GAAG,gCAAgC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LegacyAPI.d.ts","sourceRoot":"","sources":["../../src/util/LegacyAPI.js"],"names":[],"mappings":"AAGA,+EAqBC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const axios_1 = __importDefault(require("axios"));
|
|
7
|
+
const querystring_1 = require("querystring");
|
|
8
|
+
function NetatmoAPI(config) {
|
|
9
|
+
if (axios_1.default.defaults.headers.common['Authorization'] === null || axios_1.default.defaults.headers.common['Authorization'] === undefined) {
|
|
10
|
+
const credentials = {
|
|
11
|
+
client_id: config.client_id,
|
|
12
|
+
client_secret: config.client_secret,
|
|
13
|
+
grant_type: 'password',
|
|
14
|
+
username: config.username,
|
|
15
|
+
password: config.password,
|
|
16
|
+
scope: 'read_camera write_camera',
|
|
17
|
+
};
|
|
18
|
+
const response = axios_1.default.post('https://api.netatmo.com/oauth2/token', (0, querystring_1.stringify)(credentials));
|
|
19
|
+
const token = response.data.access_token;
|
|
20
|
+
axios_1.default.defaults.headers.common['Authorization'] = `Bearer ${token}`;
|
|
21
|
+
}
|
|
22
|
+
return axios_1.default.create({
|
|
23
|
+
baseURL: 'https://api.netatmo.com/api/',
|
|
24
|
+
responseType: 'json',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.default = NetatmoAPI;
|
|
28
|
+
//# sourceMappingURL=LegacyAPI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LegacyAPI.js","sourceRoot":"","sources":["../../src/util/LegacyAPI.js"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAC1B,6CAAwC;AAExC,SAAwB,UAAU,CAAC,MAAM;IAEvC,IAAI,eAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,IAAI,IAAI,eAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,SAAS,EAAE;QAC3H,MAAM,WAAW,GAAG;YAClB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,UAAU,EAAE,UAAU;YACtB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,KAAK,EAAE,0BAA0B;SAClC,CAAC;QACF,MAAM,QAAQ,GAAG,eAAK,CAAC,IAAI,CAAC,sCAAsC,EAAE,IAAA,uBAAS,EAAC,WAAW,CAAC,CAAC,CAAC;QAC5F,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC;QACzC,eAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,UAAU,KAAK,EAAE,CAAC;KACpE;IAED,OAAO,eAAK,CAAC,MAAM,CAAC;QAClB,OAAO,EAAE,8BAA8B;QACvC,YAAY,EAAE,MAAM;KACrB,CAAC,CAAC;AAEL,CAAC;AArBD,6BAqBC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export default class NetatmoAPI {
|
|
2
|
+
constructor(logger: any, storagePath: any);
|
|
3
|
+
log: null;
|
|
4
|
+
config: null;
|
|
5
|
+
storagePath: null;
|
|
6
|
+
accessToken: null;
|
|
7
|
+
refreshToken: null;
|
|
8
|
+
tokenExpire: number;
|
|
9
|
+
_authPromise: null;
|
|
10
|
+
get tokenFile(): string;
|
|
11
|
+
loadPersistedRefreshToken(): any;
|
|
12
|
+
persistRefreshToken(): void;
|
|
13
|
+
init(configuration: any): Promise<void>;
|
|
14
|
+
authenticate(): Promise<void>;
|
|
15
|
+
ensureAuth(): Promise<null | undefined>;
|
|
16
|
+
client(): import("axios").AxiosInstance;
|
|
17
|
+
setState(device: any, status: any): Promise<any>;
|
|
18
|
+
getEvents(homeId: any): Promise<any>;
|
|
19
|
+
getHomeData(): Promise<any>;
|
|
20
|
+
getHomeStatus(homeId: any): Promise<any>;
|
|
21
|
+
getHomeDevices(): Promise<any[]>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=NetatmoAPI.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NetatmoAPI.d.ts","sourceRoot":"","sources":["../../src/util/NetatmoAPI.js"],"names":[],"mappings":"AAWA;IASE,2CAIC;IAZD,UAAW;IACX,aAAc;IACd,kBAAmB;IACnB,kBAAmB;IACnB,mBAAoB;IACpB,oBAAgB;IAChB,mBAAoB;IAQpB,wBAEC;IAED,iCAaC;IAED,4BAQC;IAED,wCAWC;IAED,8BAgCC;IAID,wCAYC;IAED,wCAMC;IAED,iDAiBC;IAED,qCAMC;IAED,4BAMC;IAED,yCAMC;IAED,iCAqBC;CAEF"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const axios_1 = __importDefault(require("axios"));
|
|
7
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
// Netatmo deprecated the password grant (Resource Owner Password Credentials),
|
|
11
|
+
// so we authenticate exclusively with the OAuth2 refresh-token flow:
|
|
12
|
+
// - the user generates a refresh token once on dev.netatmo.com and sets it in
|
|
13
|
+
// the config (first run only);
|
|
14
|
+
// - Netatmo rotates the refresh token on every refresh, so we persist the latest
|
|
15
|
+
// one to disk and always prefer it over the (now possibly stale) config value.
|
|
16
|
+
class NetatmoAPI {
|
|
17
|
+
constructor(logger, storagePath) {
|
|
18
|
+
this.log = null;
|
|
19
|
+
this.config = null;
|
|
20
|
+
this.storagePath = null;
|
|
21
|
+
this.accessToken = null;
|
|
22
|
+
this.refreshToken = null;
|
|
23
|
+
this.tokenExpire = 0;
|
|
24
|
+
this._authPromise = null;
|
|
25
|
+
this.log = logger;
|
|
26
|
+
this.storagePath = storagePath;
|
|
27
|
+
this.log.info('Netatmo API constructed.');
|
|
28
|
+
}
|
|
29
|
+
get tokenFile() {
|
|
30
|
+
return path_1.default.join(this.storagePath || '.', 'netatmo-security-token.json');
|
|
31
|
+
}
|
|
32
|
+
loadPersistedRefreshToken() {
|
|
33
|
+
try {
|
|
34
|
+
if (this.storagePath && fs_1.default.existsSync(this.tokenFile)) {
|
|
35
|
+
const data = JSON.parse(fs_1.default.readFileSync(this.tokenFile, 'utf8'));
|
|
36
|
+
if (data && data.refresh_token) {
|
|
37
|
+
this.log.debug('Loaded persisted refresh token.');
|
|
38
|
+
return data.refresh_token;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
this.log.warn('Could not read persisted token: ' + error.message);
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
persistRefreshToken() {
|
|
48
|
+
try {
|
|
49
|
+
if (this.storagePath && this.refreshToken) {
|
|
50
|
+
fs_1.default.writeFileSync(this.tokenFile, JSON.stringify({ refresh_token: this.refreshToken }), { mode: 0o600 });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
this.log.warn('Could not persist token: ' + error.message);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async init(configuration) {
|
|
58
|
+
this.config = configuration;
|
|
59
|
+
// Prefer the rotated token we persisted; fall back to the config one (first run).
|
|
60
|
+
this.refreshToken = this.loadPersistedRefreshToken() || configuration.refresh_token || null;
|
|
61
|
+
if (!this.refreshToken) {
|
|
62
|
+
throw new Error('No refresh token available. Generate one with the token generator on your app at '
|
|
63
|
+
+ 'dev.netatmo.com (scope read_camera) and set "refresh_token" in the plugin config.');
|
|
64
|
+
}
|
|
65
|
+
await this.authenticate();
|
|
66
|
+
this.log.debug('Netatmo API loaded.');
|
|
67
|
+
}
|
|
68
|
+
async authenticate() {
|
|
69
|
+
if (!this.refreshToken) {
|
|
70
|
+
throw new Error('Missing refresh token; cannot authenticate.');
|
|
71
|
+
}
|
|
72
|
+
const form = new form_data_1.default();
|
|
73
|
+
form.append('grant_type', 'refresh_token');
|
|
74
|
+
form.append('refresh_token', this.refreshToken);
|
|
75
|
+
form.append('client_id', this.config.client_id);
|
|
76
|
+
form.append('client_secret', this.config.client_secret);
|
|
77
|
+
let response;
|
|
78
|
+
try {
|
|
79
|
+
response = await axios_1.default.post('https://api.netatmo.com/oauth2/token', form, {
|
|
80
|
+
headers: { ...form.getHeaders() },
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
const detail = error.response ? JSON.stringify(error.response.data) : error.message;
|
|
85
|
+
this.log.error('Netatmo authentication failed: ' + detail);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
const data = response.data;
|
|
89
|
+
this.accessToken = data.access_token;
|
|
90
|
+
// Netatmo rotates the refresh token on every refresh — keep and persist the new one.
|
|
91
|
+
if (data.refresh_token && data.refresh_token !== this.refreshToken) {
|
|
92
|
+
this.refreshToken = data.refresh_token;
|
|
93
|
+
this.persistRefreshToken();
|
|
94
|
+
}
|
|
95
|
+
// Refresh a few minutes before the real expiry (expires_in is seconds, ~3h).
|
|
96
|
+
const expiresIn = data.expires_in ? Number(data.expires_in) : 10800;
|
|
97
|
+
this.tokenExpire = (Date.now() / 1000) + expiresIn - 300;
|
|
98
|
+
this.log.debug('Authentication complete; token valid ~' + Math.round(expiresIn / 60) + ' min.');
|
|
99
|
+
}
|
|
100
|
+
// Ensure a valid access token before any request. A single in-flight refresh is
|
|
101
|
+
// shared across concurrent callers so we never fire a storm of token requests.
|
|
102
|
+
async ensureAuth() {
|
|
103
|
+
const time = Date.now() / 1000;
|
|
104
|
+
if (this.accessToken && time < this.tokenExpire) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (!this._authPromise) {
|
|
108
|
+
this.log.info('Refreshing Netatmo authentication token...');
|
|
109
|
+
this._authPromise = this.authenticate().finally(() => {
|
|
110
|
+
this._authPromise = null;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return this._authPromise;
|
|
114
|
+
}
|
|
115
|
+
client() {
|
|
116
|
+
return axios_1.default.create({
|
|
117
|
+
baseURL: 'https://api.netatmo.com/api/',
|
|
118
|
+
responseType: 'json',
|
|
119
|
+
headers: { Authorization: `Bearer ${this.accessToken}` },
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
async setState(device, status) {
|
|
123
|
+
await this.ensureAuth();
|
|
124
|
+
const body = { home: {
|
|
125
|
+
id: device.home_id,
|
|
126
|
+
modules: [
|
|
127
|
+
{
|
|
128
|
+
id: device.id,
|
|
129
|
+
status: status,
|
|
130
|
+
bridge: device.bridge,
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
} };
|
|
134
|
+
this.log.debug('Set State request: ' + JSON.stringify(body));
|
|
135
|
+
const response = await this.client().post('/setstate', body);
|
|
136
|
+
const data = response.data;
|
|
137
|
+
this.log.debug('Set State response: ' + JSON.stringify(response.data));
|
|
138
|
+
return data;
|
|
139
|
+
}
|
|
140
|
+
async getEvents(homeId) {
|
|
141
|
+
await this.ensureAuth();
|
|
142
|
+
const response = await this.client().get('/getevents?home_id=' + homeId);
|
|
143
|
+
const data = response.data.body.home;
|
|
144
|
+
const events = data.events;
|
|
145
|
+
return events;
|
|
146
|
+
}
|
|
147
|
+
async getHomeData() {
|
|
148
|
+
await this.ensureAuth();
|
|
149
|
+
const response = await this.client().get('/homesdata');
|
|
150
|
+
const data = response.data.body;
|
|
151
|
+
const home = data.homes[0];
|
|
152
|
+
return home;
|
|
153
|
+
}
|
|
154
|
+
async getHomeStatus(homeId) {
|
|
155
|
+
await this.ensureAuth();
|
|
156
|
+
const response = await this.client().get('/homestatus?home_id=' + homeId);
|
|
157
|
+
const data = response.data.body;
|
|
158
|
+
const status = data.home;
|
|
159
|
+
return status;
|
|
160
|
+
}
|
|
161
|
+
async getHomeDevices() {
|
|
162
|
+
const home = await this.getHomeData();
|
|
163
|
+
const status = await this.getHomeStatus(home.id);
|
|
164
|
+
const events = await this.getEvents(home.id);
|
|
165
|
+
const devices = [];
|
|
166
|
+
home.modules.map((moduleInfo) => {
|
|
167
|
+
const moduleStatus = status.modules.find((module) => moduleInfo.id === module.id);
|
|
168
|
+
const minimumTime = (new Date().getTime() / 1000) - 90;
|
|
169
|
+
const moduleEvents = events.filter((event) => moduleInfo.id === event.module_id && event.time > minimumTime);
|
|
170
|
+
const lastActivity = moduleEvents.length > 0 ? Math.max.apply(Math, moduleEvents.map((event) => event.time)) : 0;
|
|
171
|
+
const device = { ...moduleStatus,
|
|
172
|
+
name: moduleInfo.name,
|
|
173
|
+
category: moduleInfo.category,
|
|
174
|
+
setup_date: moduleInfo.setup_date,
|
|
175
|
+
room_id: moduleInfo.room_id,
|
|
176
|
+
home_id: home.id,
|
|
177
|
+
activity: lastActivity,
|
|
178
|
+
};
|
|
179
|
+
devices.push(device);
|
|
180
|
+
});
|
|
181
|
+
return devices;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
exports.default = NetatmoAPI;
|
|
185
|
+
//# sourceMappingURL=NetatmoAPI.js.map
|
|
@@ -0,0 +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C,QAAQ;gBAC7B,UAAU,EAAE,UAAU,CAAC,UAAU;gBACjC,OAAO,EAAE,UAAU,CAAC,OAAO;gBAC3B,OAAO,EAAE,IAAI,CAAC,EAAE;gBAChB,QAAQ,EAAE,YAAY;aACvB,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACjB,CAAC;CAEF;AArLD,6BAqLC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=Webhook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Webhook.d.ts","sourceRoot":"","sources":["../../src/util/Webhook.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// todo
|
|
3
|
+
/*
|
|
4
|
+
|
|
5
|
+
import express from 'express';
|
|
6
|
+
import bodyParser from 'body-parser';
|
|
7
|
+
|
|
8
|
+
var app = express();
|
|
9
|
+
var port = 3000;
|
|
10
|
+
app.use(bodyParser.json());
|
|
11
|
+
|
|
12
|
+
app.get('/', (req, res) => {
|
|
13
|
+
var body = req.body;
|
|
14
|
+
res.json({
|
|
15
|
+
message: '',
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
var server = app.listen(port, () => {
|
|
20
|
+
var host = server.address().address;
|
|
21
|
+
var port = server.address().port;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
*/
|
|
25
|
+
//# sourceMappingURL=Webhook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Webhook.js","sourceRoot":"","sources":["../../src/util/Webhook.js"],"names":[],"mappings":";AAAA,OAAO;AAEP;;;;;;;;;;;;;;;;;;;;;EAqBE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axios.d.ts","sourceRoot":"","sources":["../../src/util/axios.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const axios_1 = __importDefault(require("axios"));
|
|
7
|
+
exports.default = axios_1.default.create({
|
|
8
|
+
validateStatus: (status) => status < 500,
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=axios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axios.js","sourceRoot":"","sources":["../../src/util/axios.js"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAE1B,kBAAe,eAAK,CAAC,MAAM,CAAC;IAC1B,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,GAAG,GAAG;CACzC,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"displayName": "Homebridge Netatmo Security MK",
|
|
3
|
+
"name": "homebridge-netatmo-security-mk",
|
|
4
|
+
"version": "1.0.2",
|
|
5
|
+
"description": "Extended HomeKit support for Netatmo Security products (door/window tags, siren). Fork of Anzure/homebridge-netatmo-security.",
|
|
6
|
+
"author": "maximekduval",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"homepage": "https://github.com/maximekduval/homebridge-netatmo-security#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/maximekduval/homebridge-netatmo-security.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/maximekduval/homebridge-netatmo-security/issues"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=14.18.1",
|
|
18
|
+
"homebridge": ">=1.3.5"
|
|
19
|
+
},
|
|
20
|
+
"main": "dist/index.js",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"config.schema.json"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"lint": "eslint src/**.ts --max-warnings=0",
|
|
27
|
+
"watch": "npm run build && npm link && nodemon",
|
|
28
|
+
"build": "rimraf ./dist && tsc",
|
|
29
|
+
"clean": "rimraf ./dist",
|
|
30
|
+
"prepare": "npm run build",
|
|
31
|
+
"prepublishOnly": "npm run lint && npm run build && npm version patch -m 'Release %s'",
|
|
32
|
+
"postpublish": "npm run clean"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"homebridge-plugin"
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"axios": "^0.25.0",
|
|
42
|
+
"body-parser": "^1.20.1",
|
|
43
|
+
"express": "^4.18.2",
|
|
44
|
+
"form-data": "^4.0.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/body-parser": "^1.19.2",
|
|
48
|
+
"@types/express": "^4.17.14",
|
|
49
|
+
"@types/node": "^16.10.9",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
51
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
52
|
+
"eslint": "^8.0.1",
|
|
53
|
+
"homebridge": "^1.3.5",
|
|
54
|
+
"nodemon": "^2.0.13",
|
|
55
|
+
"rimraf": "^3.0.2",
|
|
56
|
+
"ts-node": "^10.3.0",
|
|
57
|
+
"typescript": "^4.4.4"
|
|
58
|
+
}
|
|
59
|
+
}
|