@ymyzk/homebridge-echonet-lite 1.0.29
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/.claude/settings.local.json +8 -0
- package/.github/workflows/publish.yml +26 -0
- package/.idea/codeStyles/Project.xml +57 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/homebridge-echonet-lite.iml +9 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.prettierignore +1 -0
- package/.prettierrc +3 -0
- package/LICENSE +438 -0
- package/README.md +38 -0
- package/lib/accessory-aircon.js +116 -0
- package/lib/accessory-light.js +101 -0
- package/lib/accessory.js +10 -0
- package/lib/echonet-lite.js +44 -0
- package/lib/index.js +249 -0
- package/package.json +29 -0
- package/sample.js +90 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: Publish to npm
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*.*.*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
id-token: write # Required for npm provenance attestation
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- uses: actions/setup-node@v4
|
|
18
|
+
with:
|
|
19
|
+
node-version: '20'
|
|
20
|
+
registry-url: 'https://registry.npmjs.org'
|
|
21
|
+
|
|
22
|
+
- run: npm ci
|
|
23
|
+
|
|
24
|
+
- run: npm publish --provenance --access public
|
|
25
|
+
env:
|
|
26
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<component name="ProjectCodeStyleConfiguration">
|
|
2
|
+
<code_scheme name="Project" version="173">
|
|
3
|
+
<HTMLCodeStyleSettings>
|
|
4
|
+
<option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
|
|
5
|
+
</HTMLCodeStyleSettings>
|
|
6
|
+
<JSCodeStyleSettings version="0">
|
|
7
|
+
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
8
|
+
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
|
9
|
+
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
10
|
+
<option name="ENFORCE_TRAILING_COMMA" value="Remove" />
|
|
11
|
+
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
|
12
|
+
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
13
|
+
</JSCodeStyleSettings>
|
|
14
|
+
<TypeScriptCodeStyleSettings version="0">
|
|
15
|
+
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
16
|
+
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
|
17
|
+
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
18
|
+
<option name="ENFORCE_TRAILING_COMMA" value="Remove" />
|
|
19
|
+
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
|
20
|
+
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
21
|
+
</TypeScriptCodeStyleSettings>
|
|
22
|
+
<VueCodeStyleSettings>
|
|
23
|
+
<option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
|
|
24
|
+
<option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
|
|
25
|
+
</VueCodeStyleSettings>
|
|
26
|
+
<codeStyleSettings language="HTML">
|
|
27
|
+
<option name="SOFT_MARGINS" value="120" />
|
|
28
|
+
<indentOptions>
|
|
29
|
+
<option name="INDENT_SIZE" value="2" />
|
|
30
|
+
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
31
|
+
<option name="TAB_SIZE" value="2" />
|
|
32
|
+
</indentOptions>
|
|
33
|
+
</codeStyleSettings>
|
|
34
|
+
<codeStyleSettings language="JavaScript">
|
|
35
|
+
<option name="SOFT_MARGINS" value="120" />
|
|
36
|
+
<indentOptions>
|
|
37
|
+
<option name="INDENT_SIZE" value="2" />
|
|
38
|
+
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
39
|
+
<option name="TAB_SIZE" value="2" />
|
|
40
|
+
</indentOptions>
|
|
41
|
+
</codeStyleSettings>
|
|
42
|
+
<codeStyleSettings language="TypeScript">
|
|
43
|
+
<option name="SOFT_MARGINS" value="120" />
|
|
44
|
+
<indentOptions>
|
|
45
|
+
<option name="INDENT_SIZE" value="2" />
|
|
46
|
+
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
47
|
+
<option name="TAB_SIZE" value="2" />
|
|
48
|
+
</indentOptions>
|
|
49
|
+
</codeStyleSettings>
|
|
50
|
+
<codeStyleSettings language="Vue">
|
|
51
|
+
<option name="SOFT_MARGINS" value="120" />
|
|
52
|
+
<indentOptions>
|
|
53
|
+
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
54
|
+
</indentOptions>
|
|
55
|
+
</codeStyleSettings>
|
|
56
|
+
</code_scheme>
|
|
57
|
+
</component>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="JAVA_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
+
<exclude-output />
|
|
5
|
+
<content url="file://$MODULE_DIR$" />
|
|
6
|
+
<orderEntry type="inheritedJdk" />
|
|
7
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
+
</component>
|
|
9
|
+
</module>
|
package/.idea/misc.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/homebridge-echonet-lite.iml" filepath="$PROJECT_DIR$/.idea/homebridge-echonet-lite.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/vcs.xml
ADDED
package/.prettierignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
node_modules/
|
package/.prettierrc
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
Attribution-NonCommercial-ShareAlike 4.0 International
|
|
2
|
+
|
|
3
|
+
=======================================================================
|
|
4
|
+
|
|
5
|
+
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
|
6
|
+
does not provide legal services or legal advice. Distribution of
|
|
7
|
+
Creative Commons public licenses does not create a lawyer-client or
|
|
8
|
+
other relationship. Creative Commons makes its licenses and related
|
|
9
|
+
information available on an "as-is" basis. Creative Commons gives no
|
|
10
|
+
warranties regarding its licenses, any material licensed under their
|
|
11
|
+
terms and conditions, or any related information. Creative Commons
|
|
12
|
+
disclaims all liability for damages resulting from their use to the
|
|
13
|
+
fullest extent possible.
|
|
14
|
+
|
|
15
|
+
Using Creative Commons Public Licenses
|
|
16
|
+
|
|
17
|
+
Creative Commons public licenses provide a standard set of terms and
|
|
18
|
+
conditions that creators and other rights holders may use to share
|
|
19
|
+
original works of authorship and other material subject to copyright
|
|
20
|
+
and certain other rights specified in the public license below. The
|
|
21
|
+
following considerations are for informational purposes only, are not
|
|
22
|
+
exhaustive, and do not form part of our licenses.
|
|
23
|
+
|
|
24
|
+
Considerations for licensors: Our public licenses are
|
|
25
|
+
intended for use by those authorized to give the public
|
|
26
|
+
permission to use material in ways otherwise restricted by
|
|
27
|
+
copyright and certain other rights. Our licenses are
|
|
28
|
+
irrevocable. Licensors should read and understand the terms
|
|
29
|
+
and conditions of the license they choose before applying it.
|
|
30
|
+
Licensors should also secure all rights necessary before
|
|
31
|
+
applying our licenses so that the public can reuse the
|
|
32
|
+
material as expected. Licensors should clearly mark any
|
|
33
|
+
material not subject to the license. This includes other CC-
|
|
34
|
+
licensed material, or material used under an exception or
|
|
35
|
+
limitation to copyright. More considerations for licensors:
|
|
36
|
+
wiki.creativecommons.org/Considerations_for_licensors
|
|
37
|
+
|
|
38
|
+
Considerations for the public: By using one of our public
|
|
39
|
+
licenses, a licensor grants the public permission to use the
|
|
40
|
+
licensed material under specified terms and conditions. If
|
|
41
|
+
the licensor's permission is not necessary for any reason--for
|
|
42
|
+
example, because of any applicable exception or limitation to
|
|
43
|
+
copyright--then that use is not regulated by the license. Our
|
|
44
|
+
licenses grant only permissions under copyright and certain
|
|
45
|
+
other rights that a licensor has authority to grant. Use of
|
|
46
|
+
the licensed material may still be restricted for other
|
|
47
|
+
reasons, including because others have copyright or other
|
|
48
|
+
rights in the material. A licensor may make special requests,
|
|
49
|
+
such as asking that all changes be marked or described.
|
|
50
|
+
Although not required by our licenses, you are encouraged to
|
|
51
|
+
respect those requests where reasonable. More considerations
|
|
52
|
+
for the public:
|
|
53
|
+
wiki.creativecommons.org/Considerations_for_licensees
|
|
54
|
+
|
|
55
|
+
=======================================================================
|
|
56
|
+
|
|
57
|
+
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
|
|
58
|
+
Public License
|
|
59
|
+
|
|
60
|
+
By exercising the Licensed Rights (defined below), You accept and agree
|
|
61
|
+
to be bound by the terms and conditions of this Creative Commons
|
|
62
|
+
Attribution-NonCommercial-ShareAlike 4.0 International Public License
|
|
63
|
+
("Public License"). To the extent this Public License may be
|
|
64
|
+
interpreted as a contract, You are granted the Licensed Rights in
|
|
65
|
+
consideration of Your acceptance of these terms and conditions, and the
|
|
66
|
+
Licensor grants You such rights in consideration of benefits the
|
|
67
|
+
Licensor receives from making the Licensed Material available under
|
|
68
|
+
these terms and conditions.
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
Section 1 -- Definitions.
|
|
72
|
+
|
|
73
|
+
a. Adapted Material means material subject to Copyright and Similar
|
|
74
|
+
Rights that is derived from or based upon the Licensed Material
|
|
75
|
+
and in which the Licensed Material is translated, altered,
|
|
76
|
+
arranged, transformed, or otherwise modified in a manner requiring
|
|
77
|
+
permission under the Copyright and Similar Rights held by the
|
|
78
|
+
Licensor. For purposes of this Public License, where the Licensed
|
|
79
|
+
Material is a musical work, performance, or sound recording,
|
|
80
|
+
Adapted Material is always produced where the Licensed Material is
|
|
81
|
+
synched in timed relation with a moving image.
|
|
82
|
+
|
|
83
|
+
b. Adapter's License means the license You apply to Your Copyright
|
|
84
|
+
and Similar Rights in Your contributions to Adapted Material in
|
|
85
|
+
accordance with the terms and conditions of this Public License.
|
|
86
|
+
|
|
87
|
+
c. BY-NC-SA Compatible License means a license listed at
|
|
88
|
+
creativecommons.org/compatiblelicenses, approved by Creative
|
|
89
|
+
Commons as essentially the equivalent of this Public License.
|
|
90
|
+
|
|
91
|
+
d. Copyright and Similar Rights means copyright and/or similar rights
|
|
92
|
+
closely related to copyright including, without limitation,
|
|
93
|
+
performance, broadcast, sound recording, and Sui Generis Database
|
|
94
|
+
Rights, without regard to how the rights are labeled or
|
|
95
|
+
categorized. For purposes of this Public License, the rights
|
|
96
|
+
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
|
97
|
+
Rights.
|
|
98
|
+
|
|
99
|
+
e. Effective Technological Measures means those measures that, in the
|
|
100
|
+
absence of proper authority, may not be circumvented under laws
|
|
101
|
+
fulfilling obligations under Article 11 of the WIPO Copyright
|
|
102
|
+
Treaty adopted on December 20, 1996, and/or similar international
|
|
103
|
+
agreements.
|
|
104
|
+
|
|
105
|
+
f. Exceptions and Limitations means fair use, fair dealing, and/or
|
|
106
|
+
any other exception or limitation to Copyright and Similar Rights
|
|
107
|
+
that applies to Your use of the Licensed Material.
|
|
108
|
+
|
|
109
|
+
g. License Elements means the license attributes listed in the name
|
|
110
|
+
of a Creative Commons Public License. The License Elements of this
|
|
111
|
+
Public License are Attribution, NonCommercial, and ShareAlike.
|
|
112
|
+
|
|
113
|
+
h. Licensed Material means the artistic or literary work, database,
|
|
114
|
+
or other material to which the Licensor applied this Public
|
|
115
|
+
License.
|
|
116
|
+
|
|
117
|
+
i. Licensed Rights means the rights granted to You subject to the
|
|
118
|
+
terms and conditions of this Public License, which are limited to
|
|
119
|
+
all Copyright and Similar Rights that apply to Your use of the
|
|
120
|
+
Licensed Material and that the Licensor has authority to license.
|
|
121
|
+
|
|
122
|
+
j. Licensor means the individual(s) or entity(ies) granting rights
|
|
123
|
+
under this Public License.
|
|
124
|
+
|
|
125
|
+
k. NonCommercial means not primarily intended for or directed towards
|
|
126
|
+
commercial advantage or monetary compensation. For purposes of
|
|
127
|
+
this Public License, the exchange of the Licensed Material for
|
|
128
|
+
other material subject to Copyright and Similar Rights by digital
|
|
129
|
+
file-sharing or similar means is NonCommercial provided there is
|
|
130
|
+
no payment of monetary compensation in connection with the
|
|
131
|
+
exchange.
|
|
132
|
+
|
|
133
|
+
l. Share means to provide material to the public by any means or
|
|
134
|
+
process that requires permission under the Licensed Rights, such
|
|
135
|
+
as reproduction, public display, public performance, distribution,
|
|
136
|
+
dissemination, communication, or importation, and to make material
|
|
137
|
+
available to the public including in ways that members of the
|
|
138
|
+
public may access the material from a place and at a time
|
|
139
|
+
individually chosen by them.
|
|
140
|
+
|
|
141
|
+
m. Sui Generis Database Rights means rights other than copyright
|
|
142
|
+
resulting from Directive 96/9/EC of the European Parliament and of
|
|
143
|
+
the Council of 11 March 1996 on the legal protection of databases,
|
|
144
|
+
as amended and/or succeeded, as well as other essentially
|
|
145
|
+
equivalent rights anywhere in the world.
|
|
146
|
+
|
|
147
|
+
n. You means the individual or entity exercising the Licensed Rights
|
|
148
|
+
under this Public License. Your has a corresponding meaning.
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
Section 2 -- Scope.
|
|
152
|
+
|
|
153
|
+
a. License grant.
|
|
154
|
+
|
|
155
|
+
1. Subject to the terms and conditions of this Public License,
|
|
156
|
+
the Licensor hereby grants You a worldwide, royalty-free,
|
|
157
|
+
non-sublicensable, non-exclusive, irrevocable license to
|
|
158
|
+
exercise the Licensed Rights in the Licensed Material to:
|
|
159
|
+
|
|
160
|
+
a. reproduce and Share the Licensed Material, in whole or
|
|
161
|
+
in part, for NonCommercial purposes only; and
|
|
162
|
+
|
|
163
|
+
b. produce, reproduce, and Share Adapted Material for
|
|
164
|
+
NonCommercial purposes only.
|
|
165
|
+
|
|
166
|
+
2. Exceptions and Limitations. For the avoidance of doubt, where
|
|
167
|
+
Exceptions and Limitations apply to Your use, this Public
|
|
168
|
+
License does not apply, and You do not need to comply with
|
|
169
|
+
its terms and conditions.
|
|
170
|
+
|
|
171
|
+
3. Term. The term of this Public License is specified in Section
|
|
172
|
+
6(a).
|
|
173
|
+
|
|
174
|
+
4. Media and formats; technical modifications allowed. The
|
|
175
|
+
Licensor authorizes You to exercise the Licensed Rights in
|
|
176
|
+
all media and formats whether now known or hereafter created,
|
|
177
|
+
and to make technical modifications necessary to do so. The
|
|
178
|
+
Licensor waives and/or agrees not to assert any right or
|
|
179
|
+
authority to forbid You from making technical modifications
|
|
180
|
+
necessary to exercise the Licensed Rights, including
|
|
181
|
+
technical modifications necessary to circumvent Effective
|
|
182
|
+
Technological Measures. For purposes of this Public License,
|
|
183
|
+
simply making modifications authorized by this Section 2(a)
|
|
184
|
+
(4) never produces Adapted Material.
|
|
185
|
+
|
|
186
|
+
5. Downstream recipients.
|
|
187
|
+
|
|
188
|
+
a. Offer from the Licensor -- Licensed Material. Every
|
|
189
|
+
recipient of the Licensed Material automatically
|
|
190
|
+
receives an offer from the Licensor to exercise the
|
|
191
|
+
Licensed Rights under the terms and conditions of this
|
|
192
|
+
Public License.
|
|
193
|
+
|
|
194
|
+
b. Additional offer from the Licensor -- Adapted Material.
|
|
195
|
+
Every recipient of Adapted Material from You
|
|
196
|
+
automatically receives an offer from the Licensor to
|
|
197
|
+
exercise the Licensed Rights in the Adapted Material
|
|
198
|
+
under the conditions of the Adapter's License You apply.
|
|
199
|
+
|
|
200
|
+
c. No downstream restrictions. You may not offer or impose
|
|
201
|
+
any additional or different terms or conditions on, or
|
|
202
|
+
apply any Effective Technological Measures to, the
|
|
203
|
+
Licensed Material if doing so restricts exercise of the
|
|
204
|
+
Licensed Rights by any recipient of the Licensed
|
|
205
|
+
Material.
|
|
206
|
+
|
|
207
|
+
6. No endorsement. Nothing in this Public License constitutes or
|
|
208
|
+
may be construed as permission to assert or imply that You
|
|
209
|
+
are, or that Your use of the Licensed Material is, connected
|
|
210
|
+
with, or sponsored, endorsed, or granted official status by,
|
|
211
|
+
the Licensor or others designated to receive attribution as
|
|
212
|
+
provided in Section 3(a)(1)(A)(i).
|
|
213
|
+
|
|
214
|
+
b. Other rights.
|
|
215
|
+
|
|
216
|
+
1. Moral rights, such as the right of integrity, are not
|
|
217
|
+
licensed under this Public License, nor are publicity,
|
|
218
|
+
privacy, and/or other similar personality rights; however, to
|
|
219
|
+
the extent possible, the Licensor waives and/or agrees not to
|
|
220
|
+
assert any such rights held by the Licensor to the limited
|
|
221
|
+
extent necessary to allow You to exercise the Licensed
|
|
222
|
+
Rights, but not otherwise.
|
|
223
|
+
|
|
224
|
+
2. Patent and trademark rights are not licensed under this
|
|
225
|
+
Public License.
|
|
226
|
+
|
|
227
|
+
3. To the extent possible, the Licensor waives any right to
|
|
228
|
+
collect royalties from You for the exercise of the Licensed
|
|
229
|
+
Rights, whether directly or through a collecting society
|
|
230
|
+
under any voluntary or waivable statutory or compulsory
|
|
231
|
+
licensing scheme. In all other cases the Licensor expressly
|
|
232
|
+
reserves any right to collect such royalties, including when
|
|
233
|
+
the Licensed Material is used other than for NonCommercial
|
|
234
|
+
purposes.
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
Section 3 -- License Conditions.
|
|
238
|
+
|
|
239
|
+
Your exercise of the Licensed Rights is expressly made subject to the
|
|
240
|
+
following conditions.
|
|
241
|
+
|
|
242
|
+
a. Attribution.
|
|
243
|
+
|
|
244
|
+
1. If You Share the Licensed Material (including in modified
|
|
245
|
+
form), You must:
|
|
246
|
+
|
|
247
|
+
a. retain the following if it is supplied by the Licensor
|
|
248
|
+
with the Licensed Material:
|
|
249
|
+
|
|
250
|
+
i. identification of the creator(s) of the Licensed
|
|
251
|
+
Material and any others designated to receive
|
|
252
|
+
attribution, in any reasonable manner requested by
|
|
253
|
+
the Licensor (including by pseudonym if
|
|
254
|
+
designated);
|
|
255
|
+
|
|
256
|
+
ii. a copyright notice;
|
|
257
|
+
|
|
258
|
+
iii. a notice that refers to this Public License;
|
|
259
|
+
|
|
260
|
+
iv. a notice that refers to the disclaimer of
|
|
261
|
+
warranties;
|
|
262
|
+
|
|
263
|
+
v. a URI or hyperlink to the Licensed Material to the
|
|
264
|
+
extent reasonably practicable;
|
|
265
|
+
|
|
266
|
+
b. indicate if You modified the Licensed Material and
|
|
267
|
+
retain an indication of any previous modifications; and
|
|
268
|
+
|
|
269
|
+
c. indicate the Licensed Material is licensed under this
|
|
270
|
+
Public License, and include the text of, or the URI or
|
|
271
|
+
hyperlink to, this Public License.
|
|
272
|
+
|
|
273
|
+
2. You may satisfy the conditions in Section 3(a)(1) in any
|
|
274
|
+
reasonable manner based on the medium, means, and context in
|
|
275
|
+
which You Share the Licensed Material. For example, it may be
|
|
276
|
+
reasonable to satisfy the conditions by providing a URI or
|
|
277
|
+
hyperlink to a resource that includes the required
|
|
278
|
+
information.
|
|
279
|
+
3. If requested by the Licensor, You must remove any of the
|
|
280
|
+
information required by Section 3(a)(1)(A) to the extent
|
|
281
|
+
reasonably practicable.
|
|
282
|
+
|
|
283
|
+
b. ShareAlike.
|
|
284
|
+
|
|
285
|
+
In addition to the conditions in Section 3(a), if You Share
|
|
286
|
+
Adapted Material You produce, the following conditions also apply.
|
|
287
|
+
|
|
288
|
+
1. The Adapter's License You apply must be a Creative Commons
|
|
289
|
+
license with the same License Elements, this version or
|
|
290
|
+
later, or a BY-NC-SA Compatible License.
|
|
291
|
+
|
|
292
|
+
2. You must include the text of, or the URI or hyperlink to, the
|
|
293
|
+
Adapter's License You apply. You may satisfy this condition
|
|
294
|
+
in any reasonable manner based on the medium, means, and
|
|
295
|
+
context in which You Share Adapted Material.
|
|
296
|
+
|
|
297
|
+
3. You may not offer or impose any additional or different terms
|
|
298
|
+
or conditions on, or apply any Effective Technological
|
|
299
|
+
Measures to, Adapted Material that restrict exercise of the
|
|
300
|
+
rights granted under the Adapter's License You apply.
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
Section 4 -- Sui Generis Database Rights.
|
|
304
|
+
|
|
305
|
+
Where the Licensed Rights include Sui Generis Database Rights that
|
|
306
|
+
apply to Your use of the Licensed Material:
|
|
307
|
+
|
|
308
|
+
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
|
309
|
+
to extract, reuse, reproduce, and Share all or a substantial
|
|
310
|
+
portion of the contents of the database for NonCommercial purposes
|
|
311
|
+
only;
|
|
312
|
+
|
|
313
|
+
b. if You include all or a substantial portion of the database
|
|
314
|
+
contents in a database in which You have Sui Generis Database
|
|
315
|
+
Rights, then the database in which You have Sui Generis Database
|
|
316
|
+
Rights (but not its individual contents) is Adapted Material,
|
|
317
|
+
including for purposes of Section 3(b); and
|
|
318
|
+
|
|
319
|
+
c. You must comply with the conditions in Section 3(a) if You Share
|
|
320
|
+
all or a substantial portion of the contents of the database.
|
|
321
|
+
|
|
322
|
+
For the avoidance of doubt, this Section 4 supplements and does not
|
|
323
|
+
replace Your obligations under this Public License where the Licensed
|
|
324
|
+
Rights include other Copyright and Similar Rights.
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
|
328
|
+
|
|
329
|
+
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
|
330
|
+
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
|
331
|
+
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
|
332
|
+
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
|
333
|
+
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
|
334
|
+
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
335
|
+
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
|
336
|
+
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
|
337
|
+
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
|
338
|
+
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
|
339
|
+
|
|
340
|
+
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
|
341
|
+
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
|
342
|
+
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
|
343
|
+
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
|
344
|
+
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
|
345
|
+
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
|
346
|
+
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
|
347
|
+
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
|
348
|
+
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
|
349
|
+
|
|
350
|
+
c. The disclaimer of warranties and limitation of liability provided
|
|
351
|
+
above shall be interpreted in a manner that, to the extent
|
|
352
|
+
possible, most closely approximates an absolute disclaimer and
|
|
353
|
+
waiver of all liability.
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
Section 6 -- Term and Termination.
|
|
357
|
+
|
|
358
|
+
a. This Public License applies for the term of the Copyright and
|
|
359
|
+
Similar Rights licensed here. However, if You fail to comply with
|
|
360
|
+
this Public License, then Your rights under this Public License
|
|
361
|
+
terminate automatically.
|
|
362
|
+
|
|
363
|
+
b. Where Your right to use the Licensed Material has terminated under
|
|
364
|
+
Section 6(a), it reinstates:
|
|
365
|
+
|
|
366
|
+
1. automatically as of the date the violation is cured, provided
|
|
367
|
+
it is cured within 30 days of Your discovery of the
|
|
368
|
+
violation; or
|
|
369
|
+
|
|
370
|
+
2. upon express reinstatement by the Licensor.
|
|
371
|
+
|
|
372
|
+
For the avoidance of doubt, this Section 6(b) does not affect any
|
|
373
|
+
right the Licensor may have to seek remedies for Your violations
|
|
374
|
+
of this Public License.
|
|
375
|
+
|
|
376
|
+
c. For the avoidance of doubt, the Licensor may also offer the
|
|
377
|
+
Licensed Material under separate terms or conditions or stop
|
|
378
|
+
distributing the Licensed Material at any time; however, doing so
|
|
379
|
+
will not terminate this Public License.
|
|
380
|
+
|
|
381
|
+
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
|
382
|
+
License.
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
Section 7 -- Other Terms and Conditions.
|
|
386
|
+
|
|
387
|
+
a. The Licensor shall not be bound by any additional or different
|
|
388
|
+
terms or conditions communicated by You unless expressly agreed.
|
|
389
|
+
|
|
390
|
+
b. Any arrangements, understandings, or agreements regarding the
|
|
391
|
+
Licensed Material not stated herein are separate from and
|
|
392
|
+
independent of the terms and conditions of this Public License.
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
Section 8 -- Interpretation.
|
|
396
|
+
|
|
397
|
+
a. For the avoidance of doubt, this Public License does not, and
|
|
398
|
+
shall not be interpreted to, reduce, limit, restrict, or impose
|
|
399
|
+
conditions on any use of the Licensed Material that could lawfully
|
|
400
|
+
be made without permission under this Public License.
|
|
401
|
+
|
|
402
|
+
b. To the extent possible, if any provision of this Public License is
|
|
403
|
+
deemed unenforceable, it shall be automatically reformed to the
|
|
404
|
+
minimum extent necessary to make it enforceable. If the provision
|
|
405
|
+
cannot be reformed, it shall be severed from this Public License
|
|
406
|
+
without affecting the enforceability of the remaining terms and
|
|
407
|
+
conditions.
|
|
408
|
+
|
|
409
|
+
c. No term or condition of this Public License will be waived and no
|
|
410
|
+
failure to comply consented to unless expressly agreed to by the
|
|
411
|
+
Licensor.
|
|
412
|
+
|
|
413
|
+
d. Nothing in this Public License constitutes or may be interpreted
|
|
414
|
+
as a limitation upon, or waiver of, any privileges and immunities
|
|
415
|
+
that apply to the Licensor or You, including from the legal
|
|
416
|
+
processes of any jurisdiction or authority.
|
|
417
|
+
|
|
418
|
+
=======================================================================
|
|
419
|
+
|
|
420
|
+
Creative Commons is not a party to its public
|
|
421
|
+
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
|
422
|
+
its public licenses to material it publishes and in those instances
|
|
423
|
+
will be considered the “Licensor.” The text of the Creative Commons
|
|
424
|
+
public licenses is dedicated to the public domain under the CC0 Public
|
|
425
|
+
Domain Dedication. Except for the limited purpose of indicating that
|
|
426
|
+
material is shared under a Creative Commons public license or as
|
|
427
|
+
otherwise permitted by the Creative Commons policies published at
|
|
428
|
+
creativecommons.org/policies, Creative Commons does not authorize the
|
|
429
|
+
use of the trademark "Creative Commons" or any other trademark or logo
|
|
430
|
+
of Creative Commons without its prior written consent including,
|
|
431
|
+
without limitation, in connection with any unauthorized modifications
|
|
432
|
+
to any of its public licenses or any other arrangements,
|
|
433
|
+
understandings, or agreements concerning use of licensed material. For
|
|
434
|
+
the avoidance of doubt, this paragraph does not form part of the
|
|
435
|
+
public licenses.
|
|
436
|
+
|
|
437
|
+
Creative Commons may be contacted at creativecommons.org.
|
|
438
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# homebridge-echonet-lite
|
|
2
|
+
|
|
3
|
+
Homebridge plugin for ECHONET Lite devices.
|
|
4
|
+
|
|
5
|
+
## Status
|
|
6
|
+
|
|
7
|
+
Implemented:
|
|
8
|
+
|
|
9
|
+
- Light bulb
|
|
10
|
+
- Air conditioner
|
|
11
|
+
|
|
12
|
+
Tested on:
|
|
13
|
+
|
|
14
|
+
- MoekadenRoom (I don't yet have an EchonetLite device)
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
"platforms": [
|
|
20
|
+
{
|
|
21
|
+
"platform": "ELPlatform",
|
|
22
|
+
"enableRefreshSwitch": true
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Credits
|
|
28
|
+
|
|
29
|
+
This project is a fork of [neerajbaid/homebridge-echonet-lite](https://github.com/neerajbaid/homebridge-echonet-lite)
|
|
30
|
+
by Neeraj Baid, which is itself a fork of the original
|
|
31
|
+
[japaniot/homebridge-echonet-lite](https://github.com/japaniot/homebridge-echonet-lite)
|
|
32
|
+
by Cheng Zhao. This fork contains further modifications by Yusuke Miyazaki.
|
|
33
|
+
|
|
34
|
+
## License
|
|
35
|
+
|
|
36
|
+
Licensed under [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/),
|
|
37
|
+
the same license as the upstream projects. See the [LICENSE](LICENSE) file for the
|
|
38
|
+
full text.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
module.exports = async (platform, accessory, el, address, eoj) => {
|
|
2
|
+
const hap = platform.api.hap;
|
|
3
|
+
const service = accessory.getService(hap.Service.HeaterCooler) || accessory.addService(hap.Service.HeaterCooler);
|
|
4
|
+
|
|
5
|
+
service
|
|
6
|
+
.getCharacteristic(hap.Characteristic.Active)
|
|
7
|
+
.on("set", async (value, callback) => {
|
|
8
|
+
try {
|
|
9
|
+
await el.setPropertyValue(address, eoj, 0x80, { status: value != 0 });
|
|
10
|
+
callback();
|
|
11
|
+
} catch (err) {
|
|
12
|
+
callback(err);
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
.on("get", async (callback) => {
|
|
16
|
+
try {
|
|
17
|
+
const { status } = (await el.getPropertyValue(address, eoj, 0x80)).message.data;
|
|
18
|
+
callback(null, status);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
callback(err);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
service.getCharacteristic(hap.Characteristic.CurrentHeaterCoolerState).on("get", async (callback) => {
|
|
25
|
+
try {
|
|
26
|
+
const { status } = (await el.getPropertyValue(address, eoj, 0x80)).message.data;
|
|
27
|
+
if (!status) {
|
|
28
|
+
callback(null, hap.Characteristic.CurrentHeaterCoolerState.INACTIVE);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const { compressor } = (await el.getPropertyValue(address, eoj, 0xcd)).message.data;
|
|
32
|
+
if (!compressor) {
|
|
33
|
+
callback(null, hap.Characteristic.CurrentHeaterCoolerState.IDLE);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const { mode } = (await el.getPropertyValue(address, eoj, 0xb0)).message.data;
|
|
37
|
+
callback(
|
|
38
|
+
null,
|
|
39
|
+
mode === 2
|
|
40
|
+
? hap.Characteristic.CurrentHeaterCoolerState.COOLING
|
|
41
|
+
: hap.Characteristic.CurrentHeaterCoolerState.HEATING,
|
|
42
|
+
);
|
|
43
|
+
} catch (err) {
|
|
44
|
+
callback(null, hap.Characteristic.CurrentHeaterCoolerState.IDLE);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
service
|
|
49
|
+
.getCharacteristic(hap.Characteristic.TargetHeaterCoolerState)
|
|
50
|
+
.on("set", async (value, callback) => {
|
|
51
|
+
try {
|
|
52
|
+
if (value !== hap.Characteristic.TargetHeaterCoolerState.OFF) {
|
|
53
|
+
let mode = 1;
|
|
54
|
+
if (value === hap.Characteristic.TargetHeaterCoolerState.COOL) mode = 2;
|
|
55
|
+
else if (value === hap.Characteristic.TargetHeaterCoolerState.HEAT) mode = 3;
|
|
56
|
+
await el.setPropertyValue(address, eoj, 0xb0, { mode });
|
|
57
|
+
} else {
|
|
58
|
+
await el.setPropertyValue(address, eoj, 0x80, { status: false });
|
|
59
|
+
}
|
|
60
|
+
callback();
|
|
61
|
+
} catch (err) {
|
|
62
|
+
callback(err);
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
.on("get", async (callback) => {
|
|
66
|
+
try {
|
|
67
|
+
let state = hap.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
68
|
+
const { status } = (await el.getPropertyValue(address, eoj, 0x80)).message.data;
|
|
69
|
+
if (status) {
|
|
70
|
+
const { mode } = (await el.getPropertyValue(address, eoj, 0xb0)).message.data;
|
|
71
|
+
if (mode === 2) state = hap.Characteristic.TargetHeaterCoolerState.COOL;
|
|
72
|
+
else if (mode === 3) state = hap.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
73
|
+
} else {
|
|
74
|
+
state = hap.Characteristic.TargetHeaterCoolerState.OFF;
|
|
75
|
+
}
|
|
76
|
+
callback(null, state);
|
|
77
|
+
} catch (err) {
|
|
78
|
+
callback(err);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const temperatureSetter = async (edt, value, callback) => {
|
|
83
|
+
try {
|
|
84
|
+
await el.setPropertyValue(address, eoj, edt, {
|
|
85
|
+
temperature: parseInt(value),
|
|
86
|
+
});
|
|
87
|
+
callback();
|
|
88
|
+
} catch (err) {
|
|
89
|
+
callback(err);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const temperatureGetter = async (edt, callback) => {
|
|
93
|
+
try {
|
|
94
|
+
const { temperature } = (await el.getPropertyValue(address, eoj, edt)).message.data;
|
|
95
|
+
callback(null, temperature);
|
|
96
|
+
} catch (err) {
|
|
97
|
+
// Some air conditioners do not have temperature sensor, reporting error
|
|
98
|
+
// would make the accessory stop working.
|
|
99
|
+
callback(null, 0);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
service
|
|
103
|
+
.getCharacteristic(hap.Characteristic.CurrentTemperature)
|
|
104
|
+
.setProps({ minValue: -127, maxValue: 125, minStep: 1 })
|
|
105
|
+
.on("get", temperatureGetter.bind(null, 0xbb));
|
|
106
|
+
service
|
|
107
|
+
.getCharacteristic(hap.Characteristic.CoolingThresholdTemperature)
|
|
108
|
+
.setProps({ minValue: 16, maxValue: 30, minStep: 1 })
|
|
109
|
+
.on("set", temperatureSetter.bind(null, 0xb5))
|
|
110
|
+
.on("get", temperatureGetter.bind(null, 0xb5));
|
|
111
|
+
service
|
|
112
|
+
.getCharacteristic(hap.Characteristic.HeatingThresholdTemperature)
|
|
113
|
+
.setProps({ minValue: 16, maxValue: 30, minStep: 1 })
|
|
114
|
+
.on("set", temperatureSetter.bind(null, 0xb6))
|
|
115
|
+
.on("get", temperatureGetter.bind(null, 0xb6));
|
|
116
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
module.exports = async (platform, accessory, el, address, eoj) => {
|
|
2
|
+
const hap = platform.api.hap;
|
|
3
|
+
const service = accessory.getService(hap.Service.Lightbulb) || accessory.addService(hap.Service.Lightbulb);
|
|
4
|
+
const properties = (await el.getPropertyMaps(address, eoj)).message.data.set;
|
|
5
|
+
const statusPropertyValue = await el.getPropertyValue(address, eoj, 0x80);
|
|
6
|
+
platform.log.info(`Initializing a light accessory: ${accessory.UUID} ${address} ${eoj}`);
|
|
7
|
+
if (statusPropertyValue == null || statusPropertyValue.message.data == null) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
service.updateCharacteristic(hap.Characteristic.On, statusPropertyValue.message.data.status);
|
|
11
|
+
|
|
12
|
+
let brightness = 0;
|
|
13
|
+
|
|
14
|
+
const updateBrightness = (b) => {
|
|
15
|
+
brightness = b;
|
|
16
|
+
service.updateCharacteristic(hap.Characteristic.Brightness, brightness);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
if (properties.includes(0xb0)) {
|
|
20
|
+
const brightnessPropertyValue = await el.getPropertyValue(address, eoj, 0xb0);
|
|
21
|
+
if (
|
|
22
|
+
brightnessPropertyValue != null &&
|
|
23
|
+
brightnessPropertyValue.message != null &&
|
|
24
|
+
brightnessPropertyValue.message.data != null &&
|
|
25
|
+
brightnessPropertyValue.message.data.level != null
|
|
26
|
+
) {
|
|
27
|
+
brightness = brightnessPropertyValue.message.data.level;
|
|
28
|
+
updateBrightness(brightness);
|
|
29
|
+
console.log("Initialized brightness", accessory.UUID, brightness);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
service
|
|
34
|
+
.getCharacteristic(hap.Characteristic.On)
|
|
35
|
+
.on("set", async (value, callback) => {
|
|
36
|
+
await el.setPropertyValue(address, eoj, 0x80, { status: value });
|
|
37
|
+
platform.log.info(`Set status ${value} for ${accessory.UUID} ${address} ${eoj}`);
|
|
38
|
+
callback();
|
|
39
|
+
})
|
|
40
|
+
.on("get", (callback) => {
|
|
41
|
+
platform.log.info(`Getting status from ${accessory.UUID} ${address} ${eoj}`);
|
|
42
|
+
el.getPropertyValue(address, eoj, 0x80).then((res) => {
|
|
43
|
+
if (res != null && res.message.data != null) {
|
|
44
|
+
const { status } = res.message.data;
|
|
45
|
+
platform.log.info(`Got status: ${status}`);
|
|
46
|
+
callback(null, status);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (properties.includes(0xb0)) {
|
|
52
|
+
service
|
|
53
|
+
.getCharacteristic(hap.Characteristic.Brightness)
|
|
54
|
+
.on("set", async (value, callback) => {
|
|
55
|
+
if (value !== brightness) {
|
|
56
|
+
console.log("Setting brightness", accessory.UUID, value, address, eoj);
|
|
57
|
+
updateBrightness(value);
|
|
58
|
+
await el.setPropertyValue(address, eoj, 0xb0, { level: value });
|
|
59
|
+
} else {
|
|
60
|
+
console.log("Setting brightness no-op", accessory.UUID, value, address, eoj);
|
|
61
|
+
}
|
|
62
|
+
callback();
|
|
63
|
+
})
|
|
64
|
+
.on("get", async (callback) => {
|
|
65
|
+
callback(null, brightness);
|
|
66
|
+
// if (!status) {
|
|
67
|
+
// return;
|
|
68
|
+
// }
|
|
69
|
+
|
|
70
|
+
console.log("Getting brightness", accessory.UUID, address, eoj);
|
|
71
|
+
el.getPropertyValue(address, eoj, 0xb0).then((res) => {
|
|
72
|
+
console.log("Got brightness", accessory.UUID, address, eoj);
|
|
73
|
+
if (res != null && res.message.data != null && res.message.data.level != null) {
|
|
74
|
+
updateBrightness(res.message.data.level);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Subscribe to status changes.
|
|
81
|
+
el.on("notify", (res) => {
|
|
82
|
+
const { seoj, prop } = res.message;
|
|
83
|
+
if (res.device.address !== address || eoj[0] !== seoj[0] || eoj[1] !== seoj[1] || eoj[2] !== seoj[2]) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
platform.log.info("Received a notification from the device");
|
|
87
|
+
|
|
88
|
+
for (const p of prop) {
|
|
89
|
+
if (!p.edt) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (p.epc === 0x80) {
|
|
93
|
+
const status = p.edt.status;
|
|
94
|
+
service.updateCharacteristic(hap.Characteristic.On, status);
|
|
95
|
+
platform.log.info(`Received and updated status: ${status}`);
|
|
96
|
+
} else if (p.epc === 0xb0) {
|
|
97
|
+
updateBrightness(p.edt.level);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
};
|
package/lib/accessory.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
module.exports = async (platform, accessory, el, address, eoj) => {
|
|
2
|
+
if ((eoj[0] === 0x02 && eoj[1] === 0x90) || (eoj[0] === 0x02 && eoj[1] === 0x91)) {
|
|
3
|
+
await require("./accessory-light")(platform, accessory, el, address, eoj);
|
|
4
|
+
return true;
|
|
5
|
+
} else if (eoj[0] === 0x01 && eoj[1] === 0x30) {
|
|
6
|
+
await require("./accessory-aircon")(platform, accessory, el, address, eoj);
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
return false;
|
|
10
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const util = require("util");
|
|
2
|
+
const Bobolink = require("bobolink");
|
|
3
|
+
const EchonetLite = require("node-echonet-lite");
|
|
4
|
+
|
|
5
|
+
// Wrapper that provide promisified methods.
|
|
6
|
+
class PromisifiedEchonetLite {
|
|
7
|
+
constructor(arg) {
|
|
8
|
+
this.el = new EchonetLite(arg);
|
|
9
|
+
this.setQueue = new Bobolink({ concurrency: 1 });
|
|
10
|
+
this.getQueue = new Bobolink({ concurrency: 50 });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Populate methods.
|
|
15
|
+
const callbackMethods = ["getPropertyMaps", "getPropertyValue", "setPropertyValue", "send", "close"];
|
|
16
|
+
for (const method in EchonetLite.prototype) {
|
|
17
|
+
if (method.startsWith("_"))
|
|
18
|
+
// private method
|
|
19
|
+
continue;
|
|
20
|
+
const old = EchonetLite.prototype[method];
|
|
21
|
+
if (typeof old === "function") {
|
|
22
|
+
PromisifiedEchonetLite.prototype[method] = function (...args) {
|
|
23
|
+
if (callbackMethods.includes(method)) {
|
|
24
|
+
if (method === "getPropertyValue")
|
|
25
|
+
return this.getQueue
|
|
26
|
+
.put(() => {
|
|
27
|
+
return util.promisify(old).apply(this.el, args);
|
|
28
|
+
})
|
|
29
|
+
.then((ts) => ts.res);
|
|
30
|
+
else if (method === "setPropertyValue")
|
|
31
|
+
return this.setQueue
|
|
32
|
+
.put(() => {
|
|
33
|
+
return util.promisify(old).apply(this.el, args);
|
|
34
|
+
})
|
|
35
|
+
.then((ts) => ts.res);
|
|
36
|
+
else return util.promisify(old).apply(this.el, args);
|
|
37
|
+
} else {
|
|
38
|
+
return old.apply(this.el, args);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = new PromisifiedEchonetLite({ lang: "ja", type: "lan" });
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
const packageJson = require("../package.json");
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const el = require("./echonet-lite");
|
|
6
|
+
const buildAccessory = require("./accessory");
|
|
7
|
+
|
|
8
|
+
const REJOIN_INTERVAL_MS = 4 * 60 * 1000;
|
|
9
|
+
let rejoinIntervalId = null;
|
|
10
|
+
|
|
11
|
+
// Storage.
|
|
12
|
+
let storagePath = null;
|
|
13
|
+
let storage = { accessories: {} };
|
|
14
|
+
|
|
15
|
+
// Called by homebridge.
|
|
16
|
+
module.exports = (api) => {
|
|
17
|
+
// Read settings.
|
|
18
|
+
try {
|
|
19
|
+
storagePath = path.join(api.user.storagePath(), "persist", "ELPlatform.json");
|
|
20
|
+
storage = JSON.parse(fs.readFileSync(storagePath));
|
|
21
|
+
} catch {}
|
|
22
|
+
|
|
23
|
+
// Register the platform.
|
|
24
|
+
api.registerPlatform(packageJson.name, "ELPlatform", ELPlatform, true);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// UUID for the refresh button.
|
|
28
|
+
const kRefreshUUID = "076cc8c6-7f72-441b-81cb-d85e27386dc1";
|
|
29
|
+
|
|
30
|
+
class ELPlatform {
|
|
31
|
+
constructor(log, config, api) {
|
|
32
|
+
this.log = log;
|
|
33
|
+
this.config = config;
|
|
34
|
+
this.api = api;
|
|
35
|
+
|
|
36
|
+
if (!this.config) return;
|
|
37
|
+
|
|
38
|
+
this.isDiscovering = false;
|
|
39
|
+
this.refreshSwitch = null;
|
|
40
|
+
|
|
41
|
+
this.accessories = new Map();
|
|
42
|
+
|
|
43
|
+
this.log.info(`Finished initializing platform: ${this.config.name}`);
|
|
44
|
+
this.api.once("didFinishLaunching", async () => this._init());
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
configureAccessory(accessory) {
|
|
48
|
+
if (!this.accessories) return;
|
|
49
|
+
|
|
50
|
+
// Prepare or remove the refresh switch.
|
|
51
|
+
if (accessory.UUID === kRefreshUUID) {
|
|
52
|
+
if (this.config.enableRefreshSwitch) this.refreshSwitch = accessory;
|
|
53
|
+
else this.api.unregisterPlatformAccessories(packageJson.name, "ELPlatform", [accessory]);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Save the accessory and build later.
|
|
58
|
+
this.accessories.set(accessory.UUID, accessory);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
configurationRequestHandler(context, request, callback) {}
|
|
62
|
+
|
|
63
|
+
async _init() {
|
|
64
|
+
this.log.info("Executing didFinishLaunching callback");
|
|
65
|
+
|
|
66
|
+
el.init(async (err) => {
|
|
67
|
+
if (err !== null) {
|
|
68
|
+
this.log.error(`Error in init: ${err}`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
this.log.info("Initializing ECHONET Lite client");
|
|
73
|
+
|
|
74
|
+
const udp = el.el.mELNet.udp;
|
|
75
|
+
this.log.info(`mELNet ${el.el.mELNet}`);
|
|
76
|
+
this.log.info(`UDP ${udp}`);
|
|
77
|
+
udp.on("close", () => this.log.info(`UDP close`));
|
|
78
|
+
udp.on("connect", () => this.log.info(`UDP connect`));
|
|
79
|
+
udp.on("error", (err) => this.log.error(`UDP error: ${err}`));
|
|
80
|
+
// udp.on("message", (msg, rinfo) => this.log.info(`UDP message: ${rinfo.address} ${rinfo.family} ${rinfo.port} ${rinfo.size}`));
|
|
81
|
+
|
|
82
|
+
if (this.config.enableRefreshSwitch) await this._buildRefreshAccessory();
|
|
83
|
+
|
|
84
|
+
if (this.accessories.size === 0) {
|
|
85
|
+
// If there is no stored information (i.e. first time run) then do
|
|
86
|
+
// discovery.
|
|
87
|
+
this.log.info("No existing accessories found");
|
|
88
|
+
await this._startDiscovery();
|
|
89
|
+
} else {
|
|
90
|
+
// Otherwise try to recover old accessories.
|
|
91
|
+
this.log.info("Restoring existing accessories");
|
|
92
|
+
for (const [uuid, accessory] of this.accessories) {
|
|
93
|
+
const info = storage.accessories[accessory.UUID];
|
|
94
|
+
this.log.info(`Adding ${info.address} ${info.eoj} ${accessory.UUID}`);
|
|
95
|
+
if (info) {
|
|
96
|
+
await this._addAccessory(info.address, info.eoj, accessory.UUID);
|
|
97
|
+
} else {
|
|
98
|
+
this.accessories.delete(uuid);
|
|
99
|
+
this.api.unregisterPlatformAccessories(packageJson.name, "ELPlatform", [accessory]);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
this._startRenewalTimer();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
_startRenewalTimer() {
|
|
108
|
+
rejoinIntervalId = setInterval(() => {
|
|
109
|
+
try {
|
|
110
|
+
el.el.mELNet._dropMembership();
|
|
111
|
+
el.el.mELNet._addMembership();
|
|
112
|
+
this.log.debug("Renewed multicast group membership");
|
|
113
|
+
} catch (error) {
|
|
114
|
+
this.log.error(`Failed to renew multicast group membership: ${error}`);
|
|
115
|
+
}
|
|
116
|
+
}, REJOIN_INTERVAL_MS);
|
|
117
|
+
this.log.info("Started multicast group renewal timer");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async _startDiscovery() {
|
|
121
|
+
if (!this._setIsDiscovering(true)) return;
|
|
122
|
+
|
|
123
|
+
return new Promise((resolve, reject) => {
|
|
124
|
+
if (rejoinIntervalId !== null) {
|
|
125
|
+
clearInterval(rejoinIntervalId);
|
|
126
|
+
rejoinIntervalId = null;
|
|
127
|
+
this.log.info("Cleared multicast membership renewal timer");
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
el.startDiscovery(async (err, res) => {
|
|
131
|
+
if (err) {
|
|
132
|
+
this.log(err);
|
|
133
|
+
reject(err);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
this._startRenewalTimer();
|
|
138
|
+
|
|
139
|
+
const device = res.device;
|
|
140
|
+
const address = device.address;
|
|
141
|
+
|
|
142
|
+
this.log.debug("3Address", address);
|
|
143
|
+
|
|
144
|
+
for (const eoj of device.eoj) {
|
|
145
|
+
// Invalid device.
|
|
146
|
+
this.log.debug("4EOJ", eoj);
|
|
147
|
+
if (!el.getClassName(eoj[0], eoj[1])) continue;
|
|
148
|
+
|
|
149
|
+
let uid;
|
|
150
|
+
try {
|
|
151
|
+
uid = (await el.getPropertyValue(address, eoj, 0x83)).message.data.uid;
|
|
152
|
+
} catch {
|
|
153
|
+
uid = address + "|" + JSON.stringify(eoj);
|
|
154
|
+
}
|
|
155
|
+
const uuid = this.api.hap.uuid.generate(uid);
|
|
156
|
+
await this._addAccessory(address, eoj, uuid);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
setTimeout(() => {
|
|
161
|
+
this._stopDiscovery();
|
|
162
|
+
resolve();
|
|
163
|
+
}, 10 * 1000);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async _stopDiscovery() {
|
|
168
|
+
if (!this._setIsDiscovering(false)) return;
|
|
169
|
+
|
|
170
|
+
// // Removed unreachable accessories.
|
|
171
|
+
// this.accessories.forEach((accessory, uuid) => {
|
|
172
|
+
// if (!accessory.reachable) {
|
|
173
|
+
// this.log(`Deleteing non-available accessory ${uuid}`)
|
|
174
|
+
// this.accessories.delete(uuid)
|
|
175
|
+
// this.api.unregisterPlatformAccessories(packageJson.name, "ELPlatform", [accessory])
|
|
176
|
+
//
|
|
177
|
+
// delete storage.accessories[uuid]
|
|
178
|
+
// writeSettings(this)
|
|
179
|
+
// }
|
|
180
|
+
// })
|
|
181
|
+
|
|
182
|
+
// After stopping discovery, el would listen to broadcast.
|
|
183
|
+
this.log("Finished discovery");
|
|
184
|
+
el.stopDiscovery();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async _setIsDiscovering(is) {
|
|
188
|
+
if (is == this.isDiscovering) return false;
|
|
189
|
+
this.isDiscovering = is;
|
|
190
|
+
|
|
191
|
+
if (this.refreshService)
|
|
192
|
+
// update the refresh switch
|
|
193
|
+
this.refreshService.updateCharacteristic(this.api.hap.Characteristic.On, is);
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async _buildRefreshAccessory() {
|
|
198
|
+
if (!this.refreshSwitch) {
|
|
199
|
+
this.refreshSwitch = new Accessory("Refresh ECHONET Lite", kRefreshUUID);
|
|
200
|
+
this.api.registerPlatformAccessories(packageJson.name, "ELPlatform", [this.refreshSwitch]);
|
|
201
|
+
}
|
|
202
|
+
this.refreshService =
|
|
203
|
+
this.refreshSwitch.getService(this.api.hap.Service.Switch) ||
|
|
204
|
+
this.refreshSwitch.addService(this.api.hap.Service.Switch);
|
|
205
|
+
this.refreshService
|
|
206
|
+
.getCharacteristic(this.api.hap.Characteristic.On)
|
|
207
|
+
.on("get", (callback) => {
|
|
208
|
+
callback(null, this.isDiscovering);
|
|
209
|
+
})
|
|
210
|
+
.on("set", async (value, callback) => {
|
|
211
|
+
if (value) await this._startDiscovery();
|
|
212
|
+
else await this._stopDiscovery();
|
|
213
|
+
callback();
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async _addAccessory(address, eoj, uuid) {
|
|
218
|
+
const registered = this.accessories.has(uuid);
|
|
219
|
+
let accessory = registered
|
|
220
|
+
? this.accessories.get(uuid)
|
|
221
|
+
: new this.api.platformAccessory(el.getClassName(eoj[0], eoj[1]), uuid);
|
|
222
|
+
|
|
223
|
+
// The _addAccessory may be called twice due to refreshing.
|
|
224
|
+
if (!accessory.alreadyBuilt) {
|
|
225
|
+
if (!(await buildAccessory(this, accessory, el, address, eoj))) return; // unsupported accessory
|
|
226
|
+
accessory.alreadyBuilt = true;
|
|
227
|
+
accessory.once("identify", (paired, callback) => callback());
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
accessory.updateReachability(true);
|
|
231
|
+
|
|
232
|
+
if (!registered) {
|
|
233
|
+
this.log(`Found new accessory: ${uuid}`);
|
|
234
|
+
this.accessories.set(uuid, accessory);
|
|
235
|
+
this.api.registerPlatformAccessories(packageJson.name, "ELPlatform", [accessory]);
|
|
236
|
+
|
|
237
|
+
storage.accessories[uuid] = { address, eoj };
|
|
238
|
+
writeSettings(this);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function writeSettings(platform) {
|
|
244
|
+
try {
|
|
245
|
+
fs.writeFileSync(storagePath, JSON.stringify(storage));
|
|
246
|
+
} catch (e) {
|
|
247
|
+
platform.log(`Failed to write settings: ${e}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"displayName": "Homebridge Echonet Lite",
|
|
3
|
+
"name": "@ymyzk/homebridge-echonet-lite",
|
|
4
|
+
"version": "1.0.29",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/ymyzk/homebridge-echonet-lite.git"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"homebridge-plugin",
|
|
12
|
+
"homekit",
|
|
13
|
+
"echonet-lite"
|
|
14
|
+
],
|
|
15
|
+
"license": "CC-BY-NC-SA-4.0",
|
|
16
|
+
"scripts": {
|
|
17
|
+
"format": "prettier --write ."
|
|
18
|
+
},
|
|
19
|
+
"engines": {
|
|
20
|
+
"homebridge": ">= 0.4.0"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"bobolink": "^3.0.0",
|
|
24
|
+
"node-echonet-lite": "^0.6.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"prettier": "^3.4.2"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/sample.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Load the node-echonet-lite module
|
|
2
|
+
var EchonetLite = require("node-echonet-lite");
|
|
3
|
+
|
|
4
|
+
// Create an EchonetLite object
|
|
5
|
+
// The type of network layer must be passed.
|
|
6
|
+
var el = new EchonetLite({ type: "lan" }); //, 'netif': '172.23.214.108'});
|
|
7
|
+
|
|
8
|
+
// Initialize the EchonetLite object
|
|
9
|
+
el.init((err) => {
|
|
10
|
+
if (err) {
|
|
11
|
+
// An error was occurred
|
|
12
|
+
showErrorExit(err);
|
|
13
|
+
} else {
|
|
14
|
+
// Start to discover devices
|
|
15
|
+
discoverDevices();
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Start to discover devices
|
|
20
|
+
function discoverDevices() {
|
|
21
|
+
// Start to discover Echonet Lite devices
|
|
22
|
+
console.log("discover 1");
|
|
23
|
+
el.startDiscovery((err, res) => {
|
|
24
|
+
console.log("discover 2");
|
|
25
|
+
// Error handling
|
|
26
|
+
if (err) {
|
|
27
|
+
showErrorExit(err);
|
|
28
|
+
}
|
|
29
|
+
// Determine the type of the found device
|
|
30
|
+
var device = res["device"];
|
|
31
|
+
var address = device["address"];
|
|
32
|
+
|
|
33
|
+
for (let eoj of device.eoj) {
|
|
34
|
+
// var eoj = device['eoj'][0];
|
|
35
|
+
var group_code = eoj[0]; // Class group code
|
|
36
|
+
var class_code = eoj[1]; // Class code
|
|
37
|
+
console.log(address, eoj);
|
|
38
|
+
if (group_code === 0x02 && class_code === 0x91) {
|
|
39
|
+
console.log("Stop");
|
|
40
|
+
// Stop to discovery process
|
|
41
|
+
el.stopDiscovery();
|
|
42
|
+
// This means that the found device belongs to the home air conditioner class
|
|
43
|
+
console.log("Found a light (" + address + ").");
|
|
44
|
+
// Get the operation status
|
|
45
|
+
getOperationStatus(address, eoj);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Get the operation status
|
|
52
|
+
function getOperationStatus(address, eoj) {
|
|
53
|
+
var epc = 0x80; // An property code which means the operation status
|
|
54
|
+
// el.getPropertyMaps(address, eoj, (err, res) => {
|
|
55
|
+
// // this value is true if the air conditione is on
|
|
56
|
+
// console.log(JSON.stringify(res.message.data));
|
|
57
|
+
// var status = res['message']['data']['status'];
|
|
58
|
+
// var desc = (status ? 'on' : 'off');
|
|
59
|
+
// console.log('The device is ' + desc + '.');
|
|
60
|
+
// // Toggle the status of the operation status
|
|
61
|
+
// // changePowerStatus(address, eoj, epc, !status);
|
|
62
|
+
// });
|
|
63
|
+
el.getPropertyValue(address, eoj, epc, (err, res) => {
|
|
64
|
+
// this value is true if the air conditione is on
|
|
65
|
+
var status = res["message"]["data"]["status"];
|
|
66
|
+
var desc = status ? "on" : "off";
|
|
67
|
+
console.log("The device is " + desc + ".");
|
|
68
|
+
// Toggle the status of the operation status
|
|
69
|
+
changePowerStatus(address, eoj, epc, !status);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Change the status of the operation status
|
|
74
|
+
function changePowerStatus(address, eoj, epc, status) {
|
|
75
|
+
var edt = { status: status };
|
|
76
|
+
el.setPropertyValue(address, eoj, epc, edt, (err, res) => {
|
|
77
|
+
var desc = status ? "on" : "off";
|
|
78
|
+
console.log("The device was turned " + desc + ".");
|
|
79
|
+
el.close(() => {
|
|
80
|
+
console.log("Closed.");
|
|
81
|
+
// This script terminates here.
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Print an error then terminate the process of this script
|
|
87
|
+
function showErrorExit(err) {
|
|
88
|
+
console.log("[ERROR] " + err.toString());
|
|
89
|
+
process.exit();
|
|
90
|
+
}
|