├── .gitignore
├── LICENSE
├── README.md
├── config.json
├── config.schema.json
├── index.js
├── makefile
├── package-lock.json
├── package.json
├── scripts
└── install-config.js
├── src
├── accessory.js
├── air-purifier.js
├── blind.js
├── device.js
├── gateway.js
├── lightbulb.js
├── outlet.js
├── platform.js
├── remote.js
├── rgb-lightbulb.js
└── warm-white-lightbulb.js
└── test.js
/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode
2 |
3 | # Logs
4 | logs
5 | *.log
6 | npm-debug.log*
7 | yarn-debug.log*
8 | yarn-error.log*
9 |
10 | # Runtime data
11 | pids
12 | *.pid
13 | *.seed
14 | *.pid.lock
15 |
16 | # Directory for instrumented libs generated by jscoverage/JSCover
17 | lib-cov
18 |
19 | # Coverage directory used by tools like istanbul
20 | coverage
21 |
22 | # nyc test coverage
23 | .nyc_output
24 |
25 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
26 | .grunt
27 |
28 | # Bower dependency directory (https://bower.io/)
29 | bower_components
30 |
31 | # node-waf configuration
32 | .lock-wscript
33 |
34 | # Compiled binary addons (http://nodejs.org/api/addons.html)
35 | build/Release
36 |
37 | # Dependency directories
38 | node_modules/
39 | jspm_packages/
40 |
41 | # Typescript v1 declaration files
42 | typings/
43 |
44 | # Optional npm cache directory
45 | .npm
46 |
47 | # Optional eslint cache
48 | .eslintcache
49 |
50 | # Optional REPL history
51 | .node_repl_history
52 |
53 | # Output of 'npm pack'
54 | *.tgz
55 |
56 | # Yarn Integrity file
57 | .yarn-integrity
58 |
59 | # dotenv environment variables file
60 | .env
61 |
62 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # homebridge-ikea-tradfri-gateway
2 |
3 | Yet another HomeBridge plugin for the IKEA Trådfri Gateway.
4 |
5 | **Please note that this module is no longer supported by me.
6 | However, I will continue to merge pull request but I
7 | do not have the ability to test anything.**
8 |
9 | There are several other npm modules that connect to the IKEA Trådfri Gateway.
10 |
11 | - [homebridge-tradfri-plugin](https://www.npmjs.com/package/homebridge-tradfri-plugin)
12 | - [homebridge-tradfri](https://www.npmjs.com/package/homebridge-tradfri)
13 | - [homebridge-ikea](https://www.npmjs.com/package/homebridge-ikea)
14 |
15 | This plugin uses the npm module
16 | [node-tradfri-client](https://www.npmjs.com/package/node-tradfri-client)
17 | from
18 | [alcalzone](https://www.npmjs.com/~alcalzone)
19 | that does not require any other components to be installed and works on multiple
20 | platforms.
21 |
22 | ## Installation
23 |
24 | First, install Homebridge. See https://www.npmjs.com/package/homebridge
25 | for more information.
26 |
27 | Then install this plugin.
28 |
29 | $ sudo npm install homebridge-ikea-tradfri-gateway -g
30 |
31 | If you are having permission problems during install, try this
32 |
33 | $ sudo npm install homebridge-ikea-tradfri-gateway -g --unsafe-perm
34 |
35 | ## Configuration File
36 |
37 | Configure your **~/.homebridge/config.json** with the following platform.
38 |
39 | ```json
40 | {
41 | "bridge": {
42 | "name": "Trådfri",
43 | "username": "AA:22:3D:E3:CE:57",
44 | "port": 51826,
45 | "pin": "031-45-123"
46 | },
47 |
48 | "description": "This is an example configuration file",
49 |
50 | "platforms": [
51 | {
52 | "platform": "Ikea Trådfri Gateway",
53 | "name": "Ikea Trådfri Gateway",
54 | "securityCode" : "this-is-found-on-the-back-of-the-gateway",
55 | "expose": ["lightbulbs", "outlets", "blinds", "remotes", "airPurifiers", "shortcut-buttons"]
56 | }
57 | ]
58 | }
59 |
60 | ```
61 |
62 | > You can also only expose non-IKEA devices (which are not exposed to HomeKit with the native integration) with:
63 | > "expose: ["non-ikea-lightbulbs", "non-ikea-outlets", "non-ikea-blinds", "non-ikea-airPurifiers"]
64 |
65 | This module auto detects the ip address of the IKEA gateway. If by
66 | some reason you would like to access a specific gateway, merge the following into
67 | **~/.homebridge/config.json**.
68 |
69 | ```javascript
70 |
71 | {
72 | ...
73 | "platforms": [
74 | {
75 | ...
76 | "host": "ip-address-of-ikea-gateway"
77 | }
78 | ]
79 | }
80 |
81 | ```
82 |
83 | ## What This Plugin Does
84 |
85 | This plugin simply extracts all lightbulbs, outlets and blinds currently in use by the IKEA Trådfri
86 | Gateway and exposes them to HomeKit and you have the ability to turn the
87 | devices on or off. And, of course, you may change the device names and
88 | group them into rooms on your iPhone or iPad.
89 |
90 | The following IKEA devices are supported
91 |
92 | - Standard white bulbs
93 | - RGB bulbs
94 | - Warm white bulbs with temperature control
95 | - Outlets
96 | - Blinds
97 | - Remotes (including shortcut buttons)
98 | - Air purifier (BETA)
99 |
100 | After this, start **homebridge**, scan the presented code with your iPhone, and hopefully
101 | you will se all you IKEA lightbulbs in your iPhone/iPad Home app.
102 |
103 | ## To Do
104 |
105 | - Support motion sensors and remote controls if possible
106 | - Handle reboot or connection break of gateway
107 | - Refining purifier function
108 |
109 | ## Bugfixes/Updates
110 |
111 | - 2018-01-29 - Can now have accessories with the same name in the IKEA app
112 | - 2018-02-04 - Updated to work with gateway version 1.3.14. The security code must now be present in **~/.homebrige/config.json**.
113 | - 2019-01-19 - Added support for outlets.
114 | - 2019-08-19 - Added support for blinds.
115 | - 2019-08-25 - Added support for auto detecting the IKEA gateway. The **host** property in **~/.homebridge/config.json** is no longer required.
116 | - 2019-11-27 - Added support for non IKEA devices.
117 | - 2021-05-30 - Updated dependencies in package.json
118 | - 2022-11-13 - Added support for remotes and shortcut buttons for low battery notifications.
119 | - 2022-11-24 - Added support for air purifiers.
120 | - 2023-01-29 - Merge of conflicting pull requests.
121 |
122 | ## Useful Links
123 |
124 | - https://www.reddit.com/r/tradfri/
125 |
--------------------------------------------------------------------------------
/config.json:
--------------------------------------------------------------------------------
1 |
2 | {
3 | "bridge": {
4 | "name": "Trådfri",
5 | "username": "AA:22:3D:E3:CE:57",
6 | "port": 51826,
7 | "pin": "031-45-123"
8 | },
9 |
10 | "description": "This is an example configuration file",
11 |
12 | "platforms": [
13 | {
14 | "platform": "Ikea Trådfri Gateway",
15 | "name": "Ikea Trådfri Gateway",
16 | "securityCode" : "security-code-from-the-back-of-gateway",
17 | "lowBatteryLimit": 50,
18 | "expose": ["lightbulbs", "outlets", "blinds", "remotes", "shortcut-buttons"],
19 | "ignore": ["65537", "65540", "65550"]
20 | }
21 | ]
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/config.schema.json:
--------------------------------------------------------------------------------
1 | {
2 | "pluginType": "platform",
3 | "pluginAlias": "Tradfri",
4 | "singular": true,
5 | "schema": {
6 | "type": "object",
7 | "properties": {
8 | "name": {
9 | "title": "Name",
10 | "type": "string",
11 | "default": "Ikea Trådfri Gateway",
12 | "required": true
13 | },
14 | "securityCode": {
15 | "title": "Type in the security code, found on the back of the gateway",
16 | "type": "string",
17 | "required": true,
18 | "minLength": 16,
19 | "maxLength": 16
20 | },
21 | "host": {
22 | "title": "IP Adress of the Gateway, found in the IP Table of your Router",
23 | "type": "string",
24 | "format": "ipv4"
25 | },
26 | "lowBatteryLimit": {
27 | "title": "Low battery limit in percentage for remotes and blinds",
28 | "type": "integer",
29 | "default": 10,
30 | "minimum": 1,
31 | "maximum": 99
32 | },
33 | "expose": {
34 | "title": "Expose device types",
35 | "type": "array",
36 | "uniqueItems": true,
37 | "default": ["lightbulbs", "outlets", "blinds", "remotes", "airPurifiers", "shortcut-buttons"],
38 | "items": {
39 | "type": "string",
40 | "enum": ["lightbulbs", "outlets", "blinds", "remotes", "airPurifiers", "shortcut-buttons", "non-ikea-lightbulbs", "non-ikea-outlets", "non-ikea-blinds", "non-ikea-airPurifiers"]
41 | }
42 | }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var Path = require('path');
4 | var isString = require('yow/isString');
5 |
6 | module.exports = function(homebridge) {
7 |
8 | if (!isString(process.env.HOME))
9 | throw new Error('The HOME environment variable must be defined.');
10 |
11 | // Load .env
12 | require('dotenv').config({path: Path.join(process.env.HOME, '.homebridge/.env')});
13 |
14 | homebridge.registerPlatform('homebridge-ikea-tradfri-gateway', 'Tradfri', require('./src/platform.js'));
15 | };
16 |
--------------------------------------------------------------------------------
/makefile:
--------------------------------------------------------------------------------
1 |
2 | all:
3 | @echo Specify 'pull', 'config', 'install' or 'run'
4 |
5 | pull:
6 | git pull
7 |
8 | config:
9 | node ./scripts/install-config.js
10 |
11 | install:
12 | npm install -g
13 |
14 | run:
15 | homebridge
16 |
17 | test:
18 | node ./test.js
19 |
--------------------------------------------------------------------------------
/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "homebridge-ikea-tradfri-gateway",
3 | "version": "1.2.40",
4 | "lockfileVersion": 2,
5 | "requires": true,
6 | "packages": {
7 | "": {
8 | "name": "homebridge-ikea-tradfri-gateway",
9 | "version": "1.2.40",
10 | "license": "ISC",
11 | "dependencies": {
12 | "color-convert": "^2.0.1",
13 | "dotenv": "^8.2.0",
14 | "node-tradfri-client": "^3.2.0",
15 | "yow": "^1.0.118"
16 | },
17 | "engines": {
18 | "homebridge": ">=0.2.0",
19 | "node": ">=0.12.0"
20 | }
21 | },
22 | "node_modules/@leichtgewicht/ip-codec": {
23 | "version": "2.0.4",
24 | "resolved": "https://registry.npmjs.org/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz",
25 | "integrity": "sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A=="
26 | },
27 | "node_modules/alcalzone-shared": {
28 | "version": "4.0.8",
29 | "resolved": "https://registry.npmjs.org/alcalzone-shared/-/alcalzone-shared-4.0.8.tgz",
30 | "integrity": "sha512-Rr0efCjNL9lw7miDvU8exL87Y42ehsLU2jUGNQUphhnlvxnTMrHeApWgoOSGZvsE2PhxC3KO7Z+VpQ/IbuV3aA==",
31 | "dependencies": {
32 | "debug": "^4.3.4"
33 | },
34 | "engines": {
35 | "node": ">=12"
36 | }
37 | },
38 | "node_modules/color-convert": {
39 | "version": "2.0.1",
40 | "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
41 | "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
42 | "dependencies": {
43 | "color-name": "~1.1.4"
44 | },
45 | "engines": {
46 | "node": ">=7.0.0"
47 | }
48 | },
49 | "node_modules/color-name": {
50 | "version": "1.1.4",
51 | "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
52 | "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
53 | },
54 | "node_modules/debug": {
55 | "version": "4.3.4",
56 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
57 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
58 | "dependencies": {
59 | "ms": "2.1.2"
60 | },
61 | "engines": {
62 | "node": ">=6.0"
63 | },
64 | "peerDependenciesMeta": {
65 | "supports-color": {
66 | "optional": true
67 | }
68 | }
69 | },
70 | "node_modules/dns-packet": {
71 | "version": "5.6.0",
72 | "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-5.6.0.tgz",
73 | "integrity": "sha512-rza3UH1LwdHh9qyPXp8lkwpjSNk/AMD3dPytUoRoqnypDUhY0xvbdmVhWOfxO68frEfV9BU8V12Ez7ZsHGZpCQ==",
74 | "dependencies": {
75 | "@leichtgewicht/ip-codec": "^2.0.1"
76 | },
77 | "engines": {
78 | "node": ">=6"
79 | }
80 | },
81 | "node_modules/dotenv": {
82 | "version": "8.2.0",
83 | "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
84 | "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==",
85 | "engines": {
86 | "node": ">=8"
87 | }
88 | },
89 | "node_modules/lru-cache": {
90 | "version": "6.0.0",
91 | "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
92 | "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
93 | "dependencies": {
94 | "yallist": "^4.0.0"
95 | },
96 | "engines": {
97 | "node": ">=10"
98 | }
99 | },
100 | "node_modules/mdns-server": {
101 | "version": "1.0.11",
102 | "resolved": "https://registry.npmjs.org/mdns-server/-/mdns-server-1.0.11.tgz",
103 | "integrity": "sha512-luzHnhQYmxaqrvYb8akwH2V/lSSyAumDoAK1zmogvpsj7sd4l04AF/LchBYH44NQVm7oo/KBVVFg3AbsJXr12w==",
104 | "dependencies": {
105 | "dns-packet": "^5.2.2"
106 | }
107 | },
108 | "node_modules/ms": {
109 | "version": "2.1.2",
110 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
111 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
112 | },
113 | "node_modules/node-aead-crypto": {
114 | "version": "3.0.1",
115 | "resolved": "https://registry.npmjs.org/node-aead-crypto/-/node-aead-crypto-3.0.1.tgz",
116 | "integrity": "sha512-z1PSiyueg0Demr4iLJ5pqoB1NDP9OsBrsSiGGNx3GaQDBOWY2wyVjS4xRCPiWEN/yu3pgb2PklqaksW1Z4L8aw==",
117 | "optional": true,
118 | "engines": {
119 | "node": ">= 10"
120 | },
121 | "optionalDependencies": {
122 | "node-aead-crypto-android-arm-eabi": "3.0.1",
123 | "node-aead-crypto-android-arm64": "3.0.1",
124 | "node-aead-crypto-darwin-arm64": "3.0.1",
125 | "node-aead-crypto-darwin-universal": "3.0.1",
126 | "node-aead-crypto-darwin-x64": "3.0.1",
127 | "node-aead-crypto-linux-arm-gnueabihf": "3.0.1",
128 | "node-aead-crypto-linux-arm64-gnu": "3.0.1",
129 | "node-aead-crypto-linux-arm64-musl": "3.0.1",
130 | "node-aead-crypto-linux-x64-gnu": "3.0.1",
131 | "node-aead-crypto-linux-x64-musl": "3.0.1",
132 | "node-aead-crypto-win32-arm64-msvc": "3.0.1",
133 | "node-aead-crypto-win32-ia32-msvc": "3.0.1",
134 | "node-aead-crypto-win32-x64-msvc": "3.0.1"
135 | }
136 | },
137 | "node_modules/node-aead-crypto-android-arm-eabi": {
138 | "version": "3.0.1",
139 | "resolved": "https://registry.npmjs.org/node-aead-crypto-android-arm-eabi/-/node-aead-crypto-android-arm-eabi-3.0.1.tgz",
140 | "integrity": "sha512-bIAOQpwVPiAdi558WCOtbRQxjdQaQysLB12zzgb4LxXzNelNfQCx7gl/lBtQtsDd+MXTWW/acURM9X8c0Y627Q==",
141 | "cpu": [
142 | "arm"
143 | ],
144 | "optional": true,
145 | "os": [
146 | "android"
147 | ],
148 | "engines": {
149 | "node": ">= 10"
150 | }
151 | },
152 | "node_modules/node-aead-crypto-android-arm64": {
153 | "version": "3.0.1",
154 | "resolved": "https://registry.npmjs.org/node-aead-crypto-android-arm64/-/node-aead-crypto-android-arm64-3.0.1.tgz",
155 | "integrity": "sha512-EzKow9IduaOatF1hxoi2aNu+a70q7LtVVs/H04VcUBe93FbSuLRtSSOnEmvwwBProz2FV9Y0WhFrAbM+ruRXbA==",
156 | "cpu": [
157 | "arm64"
158 | ],
159 | "optional": true,
160 | "os": [
161 | "android"
162 | ],
163 | "engines": {
164 | "node": ">= 10"
165 | }
166 | },
167 | "node_modules/node-aead-crypto-darwin-arm64": {
168 | "version": "3.0.1",
169 | "resolved": "https://registry.npmjs.org/node-aead-crypto-darwin-arm64/-/node-aead-crypto-darwin-arm64-3.0.1.tgz",
170 | "integrity": "sha512-qb5jCE5xfKWJGNwFGhzpcdEZf16RDXOpHu2zckM1rZw4xpfZpSaIzU5J6mBTHzuYfQJrpQSj/sZPuFGIjqEvBA==",
171 | "cpu": [
172 | "arm64"
173 | ],
174 | "optional": true,
175 | "os": [
176 | "darwin"
177 | ],
178 | "engines": {
179 | "node": ">= 10"
180 | }
181 | },
182 | "node_modules/node-aead-crypto-darwin-universal": {
183 | "version": "3.0.1",
184 | "resolved": "https://registry.npmjs.org/node-aead-crypto-darwin-universal/-/node-aead-crypto-darwin-universal-3.0.1.tgz",
185 | "integrity": "sha512-0v44Z90wONd3B9KLPMWDi7p5IZLQUPBY27X9k2R9ZBuIgK00Zkyfd995xgaHeLPN8VLiddg5UmqdOISY88reMQ==",
186 | "optional": true,
187 | "os": [
188 | "darwin"
189 | ],
190 | "engines": {
191 | "node": ">= 10"
192 | }
193 | },
194 | "node_modules/node-aead-crypto-darwin-x64": {
195 | "version": "3.0.1",
196 | "resolved": "https://registry.npmjs.org/node-aead-crypto-darwin-x64/-/node-aead-crypto-darwin-x64-3.0.1.tgz",
197 | "integrity": "sha512-Co6T1sb9R0W6uxlDwnLRlmCP2+5ZKYlQYAY5cWMaTC3RApZY2Qz7GlsK3+6hBaGr8iu4BG2Qdvb5gpS9A9ngLQ==",
198 | "cpu": [
199 | "x64"
200 | ],
201 | "optional": true,
202 | "os": [
203 | "darwin"
204 | ],
205 | "engines": {
206 | "node": ">= 10"
207 | }
208 | },
209 | "node_modules/node-aead-crypto-linux-arm-gnueabihf": {
210 | "version": "3.0.1",
211 | "resolved": "https://registry.npmjs.org/node-aead-crypto-linux-arm-gnueabihf/-/node-aead-crypto-linux-arm-gnueabihf-3.0.1.tgz",
212 | "integrity": "sha512-5sZobc1hqIQyULpaOVXw6Q+UIgMRIX3/CzHrCvvmWdc9LXG7ZZ7jzv5F8uTXBtJMXBVm3JdmD5bcu80uy9hfPg==",
213 | "cpu": [
214 | "arm"
215 | ],
216 | "optional": true,
217 | "os": [
218 | "linux"
219 | ],
220 | "engines": {
221 | "node": ">= 10"
222 | }
223 | },
224 | "node_modules/node-aead-crypto-linux-arm64-gnu": {
225 | "version": "3.0.1",
226 | "resolved": "https://registry.npmjs.org/node-aead-crypto-linux-arm64-gnu/-/node-aead-crypto-linux-arm64-gnu-3.0.1.tgz",
227 | "integrity": "sha512-cieHU0schCllZlDj54SKlYYknZSqBB83K44mFrIjfA/QLo1LQ5vgzpL7xZZLYe82HdcHRtVBLn9zfl1rtb3x+w==",
228 | "cpu": [
229 | "arm64"
230 | ],
231 | "optional": true,
232 | "os": [
233 | "linux"
234 | ],
235 | "engines": {
236 | "node": ">= 10"
237 | }
238 | },
239 | "node_modules/node-aead-crypto-linux-arm64-musl": {
240 | "version": "3.0.1",
241 | "resolved": "https://registry.npmjs.org/node-aead-crypto-linux-arm64-musl/-/node-aead-crypto-linux-arm64-musl-3.0.1.tgz",
242 | "integrity": "sha512-NU2gUYA4cueaxXtULB4h+a85UIHLB6oH7lt9qHNSQtWkFesoQSUBStmzukX75zhNBI7tvi1Z+jukUrOPYe2ixQ==",
243 | "cpu": [
244 | "arm64"
245 | ],
246 | "optional": true,
247 | "os": [
248 | "linux"
249 | ],
250 | "engines": {
251 | "node": ">= 10"
252 | }
253 | },
254 | "node_modules/node-aead-crypto-linux-x64-gnu": {
255 | "version": "3.0.1",
256 | "resolved": "https://registry.npmjs.org/node-aead-crypto-linux-x64-gnu/-/node-aead-crypto-linux-x64-gnu-3.0.1.tgz",
257 | "integrity": "sha512-KK+JrrtagnpzBsOofLE+kAf5reB5LGllh1Sdxknccg0e9oQEsL5dzTCjof5iMSdKZEBBKGrWxftMl8UxAR56Jg==",
258 | "cpu": [
259 | "x64"
260 | ],
261 | "optional": true,
262 | "os": [
263 | "linux"
264 | ],
265 | "engines": {
266 | "node": ">= 10"
267 | }
268 | },
269 | "node_modules/node-aead-crypto-linux-x64-musl": {
270 | "version": "3.0.1",
271 | "resolved": "https://registry.npmjs.org/node-aead-crypto-linux-x64-musl/-/node-aead-crypto-linux-x64-musl-3.0.1.tgz",
272 | "integrity": "sha512-CniTRbq1q+qaN2a0MB3PYZZVYVl7rS54MxT9gMaOBEd7KuG5dXry7G/cwwbJ0oR3Agjyt2mTWcW36SjJPudKXw==",
273 | "cpu": [
274 | "x64"
275 | ],
276 | "optional": true,
277 | "os": [
278 | "linux"
279 | ],
280 | "engines": {
281 | "node": ">= 10"
282 | }
283 | },
284 | "node_modules/node-aead-crypto-win32-arm64-msvc": {
285 | "version": "3.0.1",
286 | "resolved": "https://registry.npmjs.org/node-aead-crypto-win32-arm64-msvc/-/node-aead-crypto-win32-arm64-msvc-3.0.1.tgz",
287 | "integrity": "sha512-zDpx5flNM+v9rwN1qwtHudubEqTDtALkL6aCX+KwBG2uccV/PNFsy9imCDyLT86A/7D+U6WPZCpafZgN+w2aBg==",
288 | "cpu": [
289 | "arm64"
290 | ],
291 | "optional": true,
292 | "os": [
293 | "win32"
294 | ],
295 | "engines": {
296 | "node": ">= 10"
297 | }
298 | },
299 | "node_modules/node-aead-crypto-win32-ia32-msvc": {
300 | "version": "3.0.1",
301 | "resolved": "https://registry.npmjs.org/node-aead-crypto-win32-ia32-msvc/-/node-aead-crypto-win32-ia32-msvc-3.0.1.tgz",
302 | "integrity": "sha512-XD3iIsFG4kWn+XT3PabblNmejS3rNjKAkihCM6R1nPHpGLZFKOPpkummRBi0dWs3s01cV6jx59YG2r1FsZwJ0g==",
303 | "cpu": [
304 | "ia32"
305 | ],
306 | "optional": true,
307 | "os": [
308 | "win32"
309 | ],
310 | "engines": {
311 | "node": ">= 10"
312 | }
313 | },
314 | "node_modules/node-aead-crypto-win32-x64-msvc": {
315 | "version": "3.0.1",
316 | "resolved": "https://registry.npmjs.org/node-aead-crypto-win32-x64-msvc/-/node-aead-crypto-win32-x64-msvc-3.0.1.tgz",
317 | "integrity": "sha512-I2rehJKYEDXlA2uf3Z/Cnjtg74ClO3cjZhpW/SVKHGfSnxSvLK7BJ3yNAV6x+XpaHBYJMlRvWZqnHqgaHuxWUA==",
318 | "cpu": [
319 | "x64"
320 | ],
321 | "optional": true,
322 | "os": [
323 | "win32"
324 | ],
325 | "engines": {
326 | "node": ">= 10"
327 | }
328 | },
329 | "node_modules/node-coap-client": {
330 | "version": "2.1.0",
331 | "resolved": "https://registry.npmjs.org/node-coap-client/-/node-coap-client-2.1.0.tgz",
332 | "integrity": "sha512-HwD6I83vyWRcun2En/hy/mG+M29RQiy3odvSRdNQCXugEDfS9CuQMA6Uc0ZLoIbsCGzAwJCbFBqenLNGAbflbQ==",
333 | "dependencies": {
334 | "debug": "^4.3.4",
335 | "node-dtls-client": "^1.1.1"
336 | },
337 | "engines": {
338 | "node": ">=12"
339 | }
340 | },
341 | "node_modules/node-dtls-client": {
342 | "version": "1.1.1",
343 | "resolved": "https://registry.npmjs.org/node-dtls-client/-/node-dtls-client-1.1.1.tgz",
344 | "integrity": "sha512-kwQ8j5OW/cWCcLeFbUC8dyXXXMYetfIFC132wK8BzaUVr7izKWVeVrbYhUsl7yLh+qCrhf+bI3+fu2viTIJajA==",
345 | "dependencies": {
346 | "debug": "^4.3.4",
347 | "semver": "^7.3.7"
348 | },
349 | "engines": {
350 | "node": ">=12"
351 | },
352 | "optionalDependencies": {
353 | "node-aead-crypto": "^3.0.1"
354 | }
355 | },
356 | "node_modules/node-tradfri-client": {
357 | "version": "3.2.0",
358 | "resolved": "https://registry.npmjs.org/node-tradfri-client/-/node-tradfri-client-3.2.0.tgz",
359 | "integrity": "sha512-tsu9z3FANuiNPqscnAZ9D3OkPHWL7+IlBFlPfbJpLQmMajLJFH1d22BzE70ylOFZZlXWaGMHpKLijExe0+ngUQ==",
360 | "dependencies": {
361 | "alcalzone-shared": "^4.0.8",
362 | "debug": "^4.3.4",
363 | "mdns-server": "^1.0.11",
364 | "node-coap-client": "^2.1.0",
365 | "reflect-metadata": "^0.1.13"
366 | },
367 | "engines": {
368 | "node": ">=12"
369 | }
370 | },
371 | "node_modules/reflect-metadata": {
372 | "version": "0.1.13",
373 | "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz",
374 | "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg=="
375 | },
376 | "node_modules/semver": {
377 | "version": "7.5.1",
378 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.1.tgz",
379 | "integrity": "sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==",
380 | "dependencies": {
381 | "lru-cache": "^6.0.0"
382 | },
383 | "bin": {
384 | "semver": "bin/semver.js"
385 | },
386 | "engines": {
387 | "node": ">=10"
388 | }
389 | },
390 | "node_modules/sprintf-js": {
391 | "version": "1.1.2",
392 | "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz",
393 | "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug=="
394 | },
395 | "node_modules/yallist": {
396 | "version": "4.0.0",
397 | "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
398 | "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
399 | },
400 | "node_modules/yow": {
401 | "version": "1.0.118",
402 | "resolved": "https://registry.npmjs.org/yow/-/yow-1.0.118.tgz",
403 | "integrity": "sha512-xIzxaiZ/3K4AHpTHrYdnYYeTGVJWIcF9E0cJfvpKIm/aGTvSynJGjrkexg4hAlTRHTgFhprina80Hwpkq/VaXA==",
404 | "dependencies": {
405 | "sprintf-js": "^1.1.2"
406 | }
407 | }
408 | },
409 | "dependencies": {
410 | "@leichtgewicht/ip-codec": {
411 | "version": "2.0.4",
412 | "resolved": "https://registry.npmjs.org/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz",
413 | "integrity": "sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A=="
414 | },
415 | "alcalzone-shared": {
416 | "version": "4.0.8",
417 | "resolved": "https://registry.npmjs.org/alcalzone-shared/-/alcalzone-shared-4.0.8.tgz",
418 | "integrity": "sha512-Rr0efCjNL9lw7miDvU8exL87Y42ehsLU2jUGNQUphhnlvxnTMrHeApWgoOSGZvsE2PhxC3KO7Z+VpQ/IbuV3aA==",
419 | "requires": {
420 | "debug": "^4.3.4"
421 | }
422 | },
423 | "color-convert": {
424 | "version": "2.0.1",
425 | "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
426 | "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
427 | "requires": {
428 | "color-name": "~1.1.4"
429 | }
430 | },
431 | "color-name": {
432 | "version": "1.1.4",
433 | "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
434 | "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
435 | },
436 | "debug": {
437 | "version": "4.3.4",
438 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
439 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
440 | "requires": {
441 | "ms": "2.1.2"
442 | }
443 | },
444 | "dns-packet": {
445 | "version": "5.6.0",
446 | "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-5.6.0.tgz",
447 | "integrity": "sha512-rza3UH1LwdHh9qyPXp8lkwpjSNk/AMD3dPytUoRoqnypDUhY0xvbdmVhWOfxO68frEfV9BU8V12Ez7ZsHGZpCQ==",
448 | "requires": {
449 | "@leichtgewicht/ip-codec": "^2.0.1"
450 | }
451 | },
452 | "dotenv": {
453 | "version": "8.2.0",
454 | "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
455 | "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw=="
456 | },
457 | "lru-cache": {
458 | "version": "6.0.0",
459 | "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
460 | "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
461 | "requires": {
462 | "yallist": "^4.0.0"
463 | }
464 | },
465 | "mdns-server": {
466 | "version": "1.0.11",
467 | "resolved": "https://registry.npmjs.org/mdns-server/-/mdns-server-1.0.11.tgz",
468 | "integrity": "sha512-luzHnhQYmxaqrvYb8akwH2V/lSSyAumDoAK1zmogvpsj7sd4l04AF/LchBYH44NQVm7oo/KBVVFg3AbsJXr12w==",
469 | "requires": {
470 | "dns-packet": "^5.2.2"
471 | }
472 | },
473 | "ms": {
474 | "version": "2.1.2",
475 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
476 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
477 | },
478 | "node-aead-crypto": {
479 | "version": "3.0.1",
480 | "resolved": "https://registry.npmjs.org/node-aead-crypto/-/node-aead-crypto-3.0.1.tgz",
481 | "integrity": "sha512-z1PSiyueg0Demr4iLJ5pqoB1NDP9OsBrsSiGGNx3GaQDBOWY2wyVjS4xRCPiWEN/yu3pgb2PklqaksW1Z4L8aw==",
482 | "optional": true,
483 | "requires": {
484 | "node-aead-crypto-android-arm-eabi": "3.0.1",
485 | "node-aead-crypto-android-arm64": "3.0.1",
486 | "node-aead-crypto-darwin-arm64": "3.0.1",
487 | "node-aead-crypto-darwin-universal": "3.0.1",
488 | "node-aead-crypto-darwin-x64": "3.0.1",
489 | "node-aead-crypto-linux-arm-gnueabihf": "3.0.1",
490 | "node-aead-crypto-linux-arm64-gnu": "3.0.1",
491 | "node-aead-crypto-linux-arm64-musl": "3.0.1",
492 | "node-aead-crypto-linux-x64-gnu": "3.0.1",
493 | "node-aead-crypto-linux-x64-musl": "3.0.1",
494 | "node-aead-crypto-win32-arm64-msvc": "3.0.1",
495 | "node-aead-crypto-win32-ia32-msvc": "3.0.1",
496 | "node-aead-crypto-win32-x64-msvc": "3.0.1"
497 | }
498 | },
499 | "node-aead-crypto-android-arm-eabi": {
500 | "version": "3.0.1",
501 | "resolved": "https://registry.npmjs.org/node-aead-crypto-android-arm-eabi/-/node-aead-crypto-android-arm-eabi-3.0.1.tgz",
502 | "integrity": "sha512-bIAOQpwVPiAdi558WCOtbRQxjdQaQysLB12zzgb4LxXzNelNfQCx7gl/lBtQtsDd+MXTWW/acURM9X8c0Y627Q==",
503 | "optional": true
504 | },
505 | "node-aead-crypto-android-arm64": {
506 | "version": "3.0.1",
507 | "resolved": "https://registry.npmjs.org/node-aead-crypto-android-arm64/-/node-aead-crypto-android-arm64-3.0.1.tgz",
508 | "integrity": "sha512-EzKow9IduaOatF1hxoi2aNu+a70q7LtVVs/H04VcUBe93FbSuLRtSSOnEmvwwBProz2FV9Y0WhFrAbM+ruRXbA==",
509 | "optional": true
510 | },
511 | "node-aead-crypto-darwin-arm64": {
512 | "version": "3.0.1",
513 | "resolved": "https://registry.npmjs.org/node-aead-crypto-darwin-arm64/-/node-aead-crypto-darwin-arm64-3.0.1.tgz",
514 | "integrity": "sha512-qb5jCE5xfKWJGNwFGhzpcdEZf16RDXOpHu2zckM1rZw4xpfZpSaIzU5J6mBTHzuYfQJrpQSj/sZPuFGIjqEvBA==",
515 | "optional": true
516 | },
517 | "node-aead-crypto-darwin-universal": {
518 | "version": "3.0.1",
519 | "resolved": "https://registry.npmjs.org/node-aead-crypto-darwin-universal/-/node-aead-crypto-darwin-universal-3.0.1.tgz",
520 | "integrity": "sha512-0v44Z90wONd3B9KLPMWDi7p5IZLQUPBY27X9k2R9ZBuIgK00Zkyfd995xgaHeLPN8VLiddg5UmqdOISY88reMQ==",
521 | "optional": true
522 | },
523 | "node-aead-crypto-darwin-x64": {
524 | "version": "3.0.1",
525 | "resolved": "https://registry.npmjs.org/node-aead-crypto-darwin-x64/-/node-aead-crypto-darwin-x64-3.0.1.tgz",
526 | "integrity": "sha512-Co6T1sb9R0W6uxlDwnLRlmCP2+5ZKYlQYAY5cWMaTC3RApZY2Qz7GlsK3+6hBaGr8iu4BG2Qdvb5gpS9A9ngLQ==",
527 | "optional": true
528 | },
529 | "node-aead-crypto-linux-arm-gnueabihf": {
530 | "version": "3.0.1",
531 | "resolved": "https://registry.npmjs.org/node-aead-crypto-linux-arm-gnueabihf/-/node-aead-crypto-linux-arm-gnueabihf-3.0.1.tgz",
532 | "integrity": "sha512-5sZobc1hqIQyULpaOVXw6Q+UIgMRIX3/CzHrCvvmWdc9LXG7ZZ7jzv5F8uTXBtJMXBVm3JdmD5bcu80uy9hfPg==",
533 | "optional": true
534 | },
535 | "node-aead-crypto-linux-arm64-gnu": {
536 | "version": "3.0.1",
537 | "resolved": "https://registry.npmjs.org/node-aead-crypto-linux-arm64-gnu/-/node-aead-crypto-linux-arm64-gnu-3.0.1.tgz",
538 | "integrity": "sha512-cieHU0schCllZlDj54SKlYYknZSqBB83K44mFrIjfA/QLo1LQ5vgzpL7xZZLYe82HdcHRtVBLn9zfl1rtb3x+w==",
539 | "optional": true
540 | },
541 | "node-aead-crypto-linux-arm64-musl": {
542 | "version": "3.0.1",
543 | "resolved": "https://registry.npmjs.org/node-aead-crypto-linux-arm64-musl/-/node-aead-crypto-linux-arm64-musl-3.0.1.tgz",
544 | "integrity": "sha512-NU2gUYA4cueaxXtULB4h+a85UIHLB6oH7lt9qHNSQtWkFesoQSUBStmzukX75zhNBI7tvi1Z+jukUrOPYe2ixQ==",
545 | "optional": true
546 | },
547 | "node-aead-crypto-linux-x64-gnu": {
548 | "version": "3.0.1",
549 | "resolved": "https://registry.npmjs.org/node-aead-crypto-linux-x64-gnu/-/node-aead-crypto-linux-x64-gnu-3.0.1.tgz",
550 | "integrity": "sha512-KK+JrrtagnpzBsOofLE+kAf5reB5LGllh1Sdxknccg0e9oQEsL5dzTCjof5iMSdKZEBBKGrWxftMl8UxAR56Jg==",
551 | "optional": true
552 | },
553 | "node-aead-crypto-linux-x64-musl": {
554 | "version": "3.0.1",
555 | "resolved": "https://registry.npmjs.org/node-aead-crypto-linux-x64-musl/-/node-aead-crypto-linux-x64-musl-3.0.1.tgz",
556 | "integrity": "sha512-CniTRbq1q+qaN2a0MB3PYZZVYVl7rS54MxT9gMaOBEd7KuG5dXry7G/cwwbJ0oR3Agjyt2mTWcW36SjJPudKXw==",
557 | "optional": true
558 | },
559 | "node-aead-crypto-win32-arm64-msvc": {
560 | "version": "3.0.1",
561 | "resolved": "https://registry.npmjs.org/node-aead-crypto-win32-arm64-msvc/-/node-aead-crypto-win32-arm64-msvc-3.0.1.tgz",
562 | "integrity": "sha512-zDpx5flNM+v9rwN1qwtHudubEqTDtALkL6aCX+KwBG2uccV/PNFsy9imCDyLT86A/7D+U6WPZCpafZgN+w2aBg==",
563 | "optional": true
564 | },
565 | "node-aead-crypto-win32-ia32-msvc": {
566 | "version": "3.0.1",
567 | "resolved": "https://registry.npmjs.org/node-aead-crypto-win32-ia32-msvc/-/node-aead-crypto-win32-ia32-msvc-3.0.1.tgz",
568 | "integrity": "sha512-XD3iIsFG4kWn+XT3PabblNmejS3rNjKAkihCM6R1nPHpGLZFKOPpkummRBi0dWs3s01cV6jx59YG2r1FsZwJ0g==",
569 | "optional": true
570 | },
571 | "node-aead-crypto-win32-x64-msvc": {
572 | "version": "3.0.1",
573 | "resolved": "https://registry.npmjs.org/node-aead-crypto-win32-x64-msvc/-/node-aead-crypto-win32-x64-msvc-3.0.1.tgz",
574 | "integrity": "sha512-I2rehJKYEDXlA2uf3Z/Cnjtg74ClO3cjZhpW/SVKHGfSnxSvLK7BJ3yNAV6x+XpaHBYJMlRvWZqnHqgaHuxWUA==",
575 | "optional": true
576 | },
577 | "node-coap-client": {
578 | "version": "2.1.0",
579 | "resolved": "https://registry.npmjs.org/node-coap-client/-/node-coap-client-2.1.0.tgz",
580 | "integrity": "sha512-HwD6I83vyWRcun2En/hy/mG+M29RQiy3odvSRdNQCXugEDfS9CuQMA6Uc0ZLoIbsCGzAwJCbFBqenLNGAbflbQ==",
581 | "requires": {
582 | "debug": "^4.3.4",
583 | "node-dtls-client": "^1.1.1"
584 | }
585 | },
586 | "node-dtls-client": {
587 | "version": "1.1.1",
588 | "resolved": "https://registry.npmjs.org/node-dtls-client/-/node-dtls-client-1.1.1.tgz",
589 | "integrity": "sha512-kwQ8j5OW/cWCcLeFbUC8dyXXXMYetfIFC132wK8BzaUVr7izKWVeVrbYhUsl7yLh+qCrhf+bI3+fu2viTIJajA==",
590 | "requires": {
591 | "debug": "^4.3.4",
592 | "node-aead-crypto": "^3.0.1",
593 | "semver": "^7.3.7"
594 | }
595 | },
596 | "node-tradfri-client": {
597 | "version": "3.2.0",
598 | "resolved": "https://registry.npmjs.org/node-tradfri-client/-/node-tradfri-client-3.2.0.tgz",
599 | "integrity": "sha512-tsu9z3FANuiNPqscnAZ9D3OkPHWL7+IlBFlPfbJpLQmMajLJFH1d22BzE70ylOFZZlXWaGMHpKLijExe0+ngUQ==",
600 | "requires": {
601 | "alcalzone-shared": "^4.0.8",
602 | "debug": "^4.3.4",
603 | "mdns-server": "^1.0.11",
604 | "node-coap-client": "^2.1.0",
605 | "reflect-metadata": "^0.1.13"
606 | }
607 | },
608 | "reflect-metadata": {
609 | "version": "0.1.13",
610 | "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz",
611 | "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg=="
612 | },
613 | "semver": {
614 | "version": "7.5.1",
615 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.1.tgz",
616 | "integrity": "sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==",
617 | "requires": {
618 | "lru-cache": "^6.0.0"
619 | }
620 | },
621 | "sprintf-js": {
622 | "version": "1.1.2",
623 | "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz",
624 | "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug=="
625 | },
626 | "yallist": {
627 | "version": "4.0.0",
628 | "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
629 | "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
630 | },
631 | "yow": {
632 | "version": "1.0.118",
633 | "resolved": "https://registry.npmjs.org/yow/-/yow-1.0.118.tgz",
634 | "integrity": "sha512-xIzxaiZ/3K4AHpTHrYdnYYeTGVJWIcF9E0cJfvpKIm/aGTvSynJGjrkexg4hAlTRHTgFhprina80Hwpkq/VaXA==",
635 | "requires": {
636 | "sprintf-js": "^1.1.2"
637 | }
638 | }
639 | }
640 | }
641 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "homebridge-ikea-tradfri-gateway",
3 | "displayName": "IKEA Trådfri Gateway",
4 | "version": "1.2.41",
5 | "description": "homebridge-ikea-tradfri-gateway",
6 | "main": "index.js",
7 | "scripts": {
8 | "npm-version-patch": "npm version patch",
9 | "npm-publish": "npm publish",
10 | "git-commit": "git add -A && git commit -m '-' && git push",
11 | "git-reset": "git reset --hard HEAD",
12 | "goto-github": "open https://github.com/meg768/homebridge-ikea-tradfri-gateway",
13 | "goto-npm": "open https://www.npmjs.com/package/homebridge-ikea-tradfri-gateway"
14 | },
15 | "repository": {
16 | "type": "git",
17 | "url": "git+https://github.com/meg768/homebridge-ikea-tradfri-gateway.git"
18 | },
19 | "keywords": [
20 | "homebrige",
21 | "ikea",
22 | "tradfri",
23 | "trådfri",
24 | "homebridge-plugin"
25 | ],
26 | "engines": {
27 | "node": ">=0.12.0",
28 | "homebridge": ">=0.2.0"
29 | },
30 | "dependencies": {
31 | "color-convert": "^2.0.1",
32 | "dotenv": "^8.2.0",
33 | "node-tradfri-client": "^3.2.0",
34 | "yow": "^1.0.118"
35 | },
36 | "author": "",
37 | "license": "ISC",
38 | "bugs": {
39 | "url": "https://github.com/meg768/homebridge-ikea-tradfri-gateway/issues"
40 | },
41 | "homepage": "https://github.com/meg768/homebridge-ikea-tradfri-gateway#readme"
42 | }
43 |
--------------------------------------------------------------------------------
/scripts/install-config.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var Path = require('path');
4 | var fs = require('fs');
5 |
6 | function install() {
7 |
8 | var homebridgeConfig = Path.join(process.env.HOME, '.homebridge/config.json');
9 | var thisConfig = Path.join('.', 'config.json');
10 |
11 | var homebridge = JSON.parse(fs.readFileSync(homebridgeConfig));
12 | var config = JSON.parse(fs.readFileSync(thisConfig));
13 |
14 | if (!homebridge.accessories)
15 | homebridge.accessories = [];
16 |
17 | if (!homebridge.platforms)
18 | homebridge.platforms = [];
19 |
20 | if (!config.accessories)
21 | config.accessories = [];
22 |
23 | if (!config.platforms)
24 | config.platforms = [];
25 |
26 |
27 | config.accessories.forEach((accessory) => {
28 |
29 | // Remove existing
30 | homebridge.accessories = homebridge.accessories.filter((item) => {
31 | return item.accessory.toLowerCase() != accessory.accessory.toLowerCase();
32 | });
33 |
34 | // And add this one
35 | homebridge.accessories.push(accessory);
36 |
37 | });
38 |
39 | config.platforms.forEach((platform) => {
40 |
41 | // Remove existing platform from homebridge
42 | homebridge.platforms = homebridge.platforms.filter((item) => {
43 | return item.platform.toLowerCase() != platform.platform.toLowerCase();
44 | });
45 |
46 | // And add this one
47 | homebridge.platforms.push(platform);
48 |
49 | });
50 |
51 |
52 | fs.writeFileSync(homebridgeConfig, JSON.stringify(homebridge, null, ' '));
53 | }
54 |
55 | install();
56 |
--------------------------------------------------------------------------------
/src/accessory.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var Events = require('events');
4 |
5 |
6 | module.exports = class Accessory extends Events {
7 |
8 | constructor(platform, name, id) {
9 |
10 | super();
11 |
12 | if (name == '')
13 | name = 'Namnlös';
14 |
15 | this.name = name;
16 | this.id = id;
17 | this.platform = platform;
18 | this.uuid = this.generateUUID(id);
19 | this.log = platform.log;
20 | this.homebridge = platform.homebridge;
21 | this.Characteristic = platform.homebridge.hap.Characteristic;
22 | this.Service = platform.homebridge.hap.Service;
23 | this.services = {};
24 |
25 | // Important, set uuid_base to a unique uuid otherwise
26 | // two accessories with the same name cannot be created...
27 | this.uuid_base = this.uuid;
28 | }
29 |
30 | generateUUID(id) {
31 | return this.platform.homebridge.hap.uuid.generate(id.toString());
32 | }
33 |
34 | addAccessoryInformation() {
35 | var service = new this.Service.AccessoryInformation();
36 |
37 | var manufacturer = this.getManufacturer();
38 | var model = this.getModel();
39 | var firmwareVersion = this.getFirmwareVersion();
40 | var serialNumber = this.getSerialNumber();
41 |
42 | if (manufacturer)
43 | service.setCharacteristic(this.Characteristic.Manufacturer, manufacturer);
44 |
45 | if (model)
46 | service.setCharacteristic(this.Characteristic.Model, model);
47 |
48 | if (firmwareVersion)
49 | service.setCharacteristic(this.Characteristic.FirmwareRevision, firmwareVersion);
50 |
51 | if (serialNumber)
52 | service.setCharacteristic(this.Characteristic.SerialNumber, serialNumber);
53 |
54 |
55 | this.addService('deviceInfo', service);
56 |
57 | }
58 |
59 | getManufacturer() {
60 | }
61 |
62 | getModel() {
63 | }
64 |
65 | getFirmwareVersion() {
66 | }
67 |
68 | getSerialNumber() {
69 | return this.id;
70 | }
71 |
72 | addService(name, service) {
73 | this.services[name] = service;
74 | }
75 |
76 | identify(callback) {
77 | this.log('Identify called for accessory \'%s\'.', this.name);
78 | callback();
79 | }
80 |
81 | getServices() {
82 | var services = [];
83 |
84 | for (var id in this.services) {
85 | services.push(this.services[id]);
86 | }
87 |
88 | return services;
89 | }
90 |
91 | };
92 |
--------------------------------------------------------------------------------
/src/air-purifier.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var Device = require('./device.js');
3 |
4 | module.exports = class AirPurifier extends Device {
5 |
6 | constructor(platform, device) {
7 | super(platform, device);
8 |
9 | this.log('Creating new air purifier %s (%s)...', this.name, this.id);
10 | this.airPurifier = new this.Service.AirPurifier(this.name, this.uuid);
11 | this.airQualitySensor = new this.Service.AirQualitySensor(this.name, this.uuid);
12 |
13 | this.addService('airPurifier', this.airPurifier);
14 | this.addService('airQualitySensor', this.airQualitySensor);
15 |
16 | this.enablePower();
17 | this.enableSpeed();
18 | this.enableAirQuality();
19 | this.enableControlLock();
20 | this.enableState();
21 | this.enableStatus();
22 | }
23 |
24 | deviceChanged(device) {
25 | super.deviceChanged();
26 |
27 | this.updatePower();
28 | this.updateSpeed();
29 | this.updateAirQuality();
30 | this.updateControlLock();
31 | this.updateState();
32 | this.updateStatus();
33 | }
34 |
35 | enablePower() {
36 | var active = this.airPurifier.getCharacteristic(this.Characteristic.Active);
37 | active.on('get', (callback) => {
38 | callback(null, this.active);
39 | });
40 | active.on('set', (value, callback) => {
41 | this.setPower(value, callback);
42 | });
43 | this.updatePower();
44 | }
45 |
46 | enableSpeed() {
47 | var autoSpeed = this.airPurifier.getCharacteristic(this.Characteristic.TargetAirPurifierState);
48 | var percentSpeed = this.airPurifier.getCharacteristic(this.Characteristic.RotationSpeed);
49 | autoSpeed.on('get', (callback) => {
50 | callback(null, this.autoSpeed);
51 | });
52 | autoSpeed.on('set', (value, callback) => {
53 | this.setSpeed(value, this.percentSpeed, callback);
54 | });
55 | percentSpeed.on('get', (callback) => {
56 | callback(null, this.percentSpeed);
57 | });
58 | percentSpeed.on('set', (value, callback) => {
59 | this.setSpeed(this.autoSpeed, value, callback);
60 | });
61 | this.updateSpeed();
62 | }
63 |
64 | enableState() {
65 | var currentAirPurifierState = this.airPurifier.getCharacteristic(this.Characteristic.CurrentAirPurifierState);
66 | currentAirPurifierState.on('get', (callback) => {
67 | callback(null, this.currentAirPurifierState);
68 | });
69 | this.updateState();
70 | }
71 |
72 | enableAirQuality() {
73 | var airQuality = this.airQualitySensor.getCharacteristic(this.Characteristic.AirQuality);
74 | var pm2_5Density = this.airQualitySensor.getCharacteristic(this.Characteristic.PM2_5Density);
75 | airQuality.on('get', (callback) => {
76 | callback(null, this.airQuality);
77 | });
78 | pm2_5Density.on('get', (callback) => {
79 | callback(null, this.pm2_5Density);
80 | });
81 | this.updateAirQuality();
82 | }
83 |
84 | enableControlLock() {
85 | var lockPhysicalControls = this.airPurifier.getCharacteristic(this.Characteristic.LockPhysicalControls);
86 | lockPhysicalControls.on('get', (callback) => {
87 | callback(null, this.lockPhysicalControls);
88 | });
89 | lockPhysicalControls.on('set', (value, callback) => {
90 | this.setControlLock(value, callback);
91 | });
92 | this.updateControlLock();
93 | }
94 |
95 | enableStatus() {
96 | var alive = this.airPurifier.addCharacteristic(this.Characteristic.StatusActive);
97 | var aliveSensor = this.airQualitySensor.addCharacteristic(this.Characteristic.StatusActive);
98 |
99 | alive.on('get', (callback) => {
100 | this.log('Purifier %s in currently %s.', this.name, this.device.alive ? 'ALIVE' : 'DEAD');
101 | callback(null, this.device.alive);
102 | });
103 | aliveSensor.on('get', (callback) => {
104 | this.log.debug('Sensors %s in currently %s.', this.name, this.active ? 'ALIVE' : 'DEAD');
105 | callback(null, this.active);
106 | });
107 | this.updateStatus();
108 | }
109 |
110 | setPower(value, callback) {
111 | this.log('Setting active to %s on air purifier \'%s\'.', value ? 'ACTIVE' : 'INACTIVE', this.name);
112 | if (this.active == value) {
113 | if (callback)
114 | callback();
115 | } else {
116 | this.active = value;
117 | this.platform.gateway.operateAirPurifier(this.device, {
118 | fanMode: this.active
119 | })
120 | .then(() => {
121 | if (callback)
122 | callback();
123 | })
124 | .catch((error) => {
125 | this.log.debug(error);
126 | });
127 | };
128 | }
129 |
130 | setSpeed(autoSpeed, percentSpeed, callback) {
131 | this.log('Setting control mode to %s on air purifier \'%s\'.', autoSpeed ? 'AUTO' : 'MANUAL', this.name);
132 | this.log('Setting speed to %s%% on air purifier \'%s\'.', percentSpeed, this.name);
133 | this.fanSpeed = percentSpeed/2 | 0;
134 | if (autoSpeed == 0) {
135 | this.fanMode = this.fanSpeed;
136 | } else {
137 | this.fanMode = 1;
138 | this.autoSpeed = 1;
139 | };
140 | this.log.debug('SET - FANMODE', this.fanMode, 'FANSPEED (0-50)', this.fanSpeed);
141 | this.platform.gateway.operateAirPurifier(this.device, {
142 | fanMode: this.fanMode,
143 | fanSpeed: this.fanSpeed
144 | }).then(() => {
145 | if (callback)
146 | callback();
147 | })
148 | .catch((error) => {
149 | this.log(error);
150 | });
151 | }
152 |
153 | setControlLock(value, callback) {
154 | this.log('Setting child lock to %s on air purifier \'%s\'.', value ? 'LOCK' : 'UNLOCK', this.name);
155 | this.lockPhysicalControls = value;
156 |
157 | this.platform.gateway.operateAirPurifier(this.device, {
158 | controlsLocked: this.lockPhysicalControls
159 | })
160 | .then(() => {
161 | if (callback)
162 | callback();
163 | })
164 | .catch((error) => {
165 | this.log(error);
166 | });
167 | }
168 |
169 | updatePower() {
170 | var purifier = this.device.airPurifierList[0];
171 | var active = this.airPurifier.getCharacteristic(this.Characteristic.Active);
172 | if (active.value != this.active) {
173 | this.log('Updating active to \'%s\' on air purifier \'%s\'.', this.active ? 'ACTIVE' : 'INACTIVE', this.name);
174 | } else {
175 | this.log.debug('Updating active to \'%s\' on air purifier \'%s\'.', this.active ? 'ACTIVE' : 'INACTIVE', this.name);
176 | }
177 | this.active = (purifier.fanMode != 0);
178 | active.updateValue(this.active);
179 | }
180 |
181 | updateSpeed() {
182 | var purifier = this.device.airPurifierList[0];
183 | var autoSpeed = this.airPurifier.getCharacteristic(this.Characteristic.TargetAirPurifierState);
184 | var percentSpeed = this.airPurifier.getCharacteristic(this.Characteristic.RotationSpeed);
185 | if (this.percentSpeed != purifier.fanSpeed*2) {
186 | this.log('Updating speed to %s%% on air purifier \'%s\'.', this.percentSpeed, this.name);
187 | } else {
188 | this.log.debug('Updating speed to %s%% on air purifier \'%s\'.', this.percentSpeed, this.name);
189 | }
190 |
191 | this.percentSpeed = purifier.fanSpeed*2;
192 | percentSpeed.updateValue(this.percentSpeed);
193 |
194 | if (this.autoSpeed != autoSpeed.value) {
195 | this.log('Updating control mode to \'%s\' on air purifier \'%s\'.', this.autoSpeed ? 'AUTO' : 'MANUAL', this.name);
196 | } else {
197 | this.log.debug('Updating control mode to \'%s\' on air purifier \'%s\'.', this.autoSpeed ? 'AUTO' : 'MANUAL', this.name);
198 | }
199 | if (purifier.fanMode == 1 || purifier.fanMode == 0) {
200 | this.autoSpeed = 1;
201 | } else {
202 | this.autoSpeed = 0;
203 | };
204 | autoSpeed.updateValue(this.autoSpeed);
205 | }
206 |
207 | updateState() {
208 | var purifier = this.device.airPurifierList[0];
209 | var currentAirPurifierState = this.airPurifier.getCharacteristic(this.Characteristic.CurrentAirPurifierState);
210 | if (currentAirPurifierState.value != this.currentAirPurifierState) {
211 | this.log('Updating state to %s on air purifier \'%s\'.', this.currentAirPurifierState/2 ? 'PURIFYING_AIR' : 'INACTIVE', this.name);
212 | } else {
213 | this.log.debug('Updating state to %s on air purifier \'%s\'.', this.currentAirPurifierState/2 ? 'PURIFYING_AIR' : 'INACTIVE', this.name);
214 | }
215 |
216 | if (purifier.fanMode == 0 || purifier.fanSpeed == 0) {
217 | this.currentAirPurifierState = 0;
218 | } else if (purifier.fanSpeed > 0) {
219 | this.currentAirPurifierState = 2;
220 | } else {
221 | this.currentAirPurifierState = 0;
222 | }
223 | currentAirPurifierState.updateValue(this.currentAirPurifierState);
224 | }
225 |
226 | updateAirQuality() {
227 | var purifier = this.device.airPurifierList[0];
228 | var airQuality = this.airQualitySensor.getCharacteristic(this.Characteristic.AirQuality);
229 | var pm2_5Density = this.airQualitySensor.getCharacteristic(this.Characteristic.PM2_5Density);
230 | if (this.pm2_5Density != purifier.airQuality) {
231 | this.log('Updating air quality to PM2.5 \= %sppm \(%s\) on air purifier \'%s\'.', this.pm2_5Density, this.airQualityDesc, this.name);
232 | } else {
233 | this.log.debug('Updating air quality to PM2.5 \= %sppm \(%s\) on air purifier \'%s\'.', this.pm2_5Density, this.airQualityDesc, this.name);
234 | }
235 |
236 | this.pm2_5Density = purifier.airQuality;
237 | var airQualityDesc = 'UNKNOWN';
238 | if (purifier.airQuality > 0 && purifier.airQuality <= 15) {
239 | this.airQuality = 1;
240 | this.airQualityDesc = 'EXCELLENT';
241 | } else if (purifier.airQuality <= 35) {
242 | this.airQuality = 2;
243 | this.airQualityDesc = 'GOOD';
244 | } else if (purifier.airQuality <= 55) {
245 | this.airQuality = 3;
246 | this.airQualityDesc = 'FAIR';
247 | } else if (purifier.airQuality <= 85) {
248 | this.airQuality = 4;
249 | this.airQualityDesc = 'INFERIOR';
250 | } else if (purifier.airQuality <= 1000) {
251 | this.airQuality = 5;
252 | this.airQualityDesc = 'POOR';
253 | } else {
254 | this.airQuality = 0;
255 | this.pm2_5Density = 0;
256 | };
257 | airQuality.updateValue(this.airQuality);
258 | pm2_5Density.updateValue(this.pm2_5Density);
259 | // this.updateAirQualitySensor();
260 | }
261 |
262 | // updateAirQualitySensor() {
263 | // var airQuality = this.airQualitySensor.getCharacteristic(this.Characteristic.AirQuality);
264 | // var pm2_5Density = this.airQualitySensor.getCharacteristic(this.Characteristic.PM2_5Density);
265 | // airQuality.updateValue(this.airQuality);
266 | // pm2_5Density.updateValue(this.pm2_5Density);
267 | // }
268 |
269 | updateControlLock() {
270 | var purifier = this.device.airPurifierList[0];
271 | var lockPhysicalControls = this.airPurifier.getCharacteristic(this.Characteristic.LockPhysicalControls);
272 | if (this.lockPhysicalControls != purifier.controlsLocked) {
273 | this.log('Updating child lock to %s on air purifier \'%s\'.', this.lockPhysicalControls ? 'LOCK' : 'UNLOCK', this.name);
274 | } else {
275 | this.log.debug('Updating child lock to %s on air purifier \'%s\'.', this.lockPhysicalControls ? 'LOCK' : 'UNLOCK', this.name);
276 | }
277 |
278 | this.lockPhysicalControls = purifier.controlsLocked;
279 | lockPhysicalControls.updateValue(this.lockPhysicalControls);
280 | }
281 |
282 | updateStatus() {
283 | var alive = this.airPurifier.getCharacteristic(this.Characteristic.StatusActive);
284 | var aliveSensor = this.airQualitySensor.getCharacteristic(this.Characteristic.StatusActive);
285 | if (alive.value != this.device.alive) {
286 | this.log('Updating active status to %s on air purifier \'%s\'.', this.device.alive ? 'ALIVE' : 'DEAD', this.name);
287 | } else {
288 | this.log.debug('Updating active status to %s on air purifier \'%s\'.', this.device.alive ? 'ALIVE' : 'DEAD', this.name);
289 | }
290 |
291 | alive.updateValue(this.device.alive);
292 | aliveSensor.updateValue(this.active);
293 | }
294 |
295 | };
--------------------------------------------------------------------------------
/src/blind.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var Device = require('./device.js');
3 |
4 | module.exports = class Blind extends Device {
5 |
6 | constructor(platform, device) {
7 | super(platform, device);
8 |
9 | this.blind = new this.Service.WindowCovering(this.name, this.uuid);
10 | this.services.battery = new this.Service.BatteryService(`${this.name} Battery`);
11 | this.lowBatteryLimit = platform.config.lowBatteryLimit || 10;
12 | this.addService('blind', this.blind);
13 | this.enablePosition();
14 | this.enableTargetPosition();
15 | this.enableBattery();
16 | this.previousPosition = this.position;
17 | }
18 |
19 | deviceChanged(device) {
20 | super.deviceChanged();
21 | this.updatePosition();
22 | this.updateBatteryLevel();
23 | this.estimateTargetPositionIfNeeded();
24 | this.previousPosition = this.position;
25 | }
26 |
27 | enablePosition() {
28 | var position = this.blind.getCharacteristic(this.Characteristic.CurrentPosition)
29 | position.on('get', (callback) => {
30 | callback(null, this.position);
31 | });
32 | this.updatePosition();
33 | }
34 |
35 | enableTargetPosition() {
36 | var targetPosition = this.blind.getCharacteristic(this.Characteristic.TargetPosition);
37 | targetPosition.on('get', (callback) => {
38 | callback(null, this.targetPosition);
39 | });
40 | targetPosition.on('set', (value, callback) => {
41 | this.setTargetPosition(value, callback);
42 | });
43 | this.updateTargetPosition(this.position);
44 | }
45 |
46 | enableBattery() {
47 | var batteryLevel = this.services.battery.getCharacteristic(this.Characteristic.BatteryLevel);
48 | batteryLevel.on('get', (callback) => {
49 | callback(null, this.device.deviceInfo.battery);
50 | });
51 |
52 | var lowBatteryStatus = this.services.battery.getCharacteristic(this.Characteristic.StatusLowBattery);
53 | lowBatteryStatus.on('get', (callback) => {
54 | let battery = this.device.deviceInfo.battery
55 | callback(null, battery <= this.lowBatteryLimit);
56 | });
57 | }
58 |
59 | setTargetPosition(value, callback) {
60 | this.log('Setting target position to %s on blind \'%s\'', value, this.name);
61 | this.position = value;
62 | this.targetPosition = value;
63 | this.platform.gateway.operateBlind(this.device, {
64 | position: value
65 | })
66 | .then(() => {
67 | if (callback)
68 | callback();
69 | });
70 | }
71 |
72 | estimateTargetPositionIfNeeded() {
73 | let position = this.position;
74 | let increasing = this.previousPosition < position && this.targetPosition < position;
75 | let decreasing = this.previousPosition > position && this.targetPosition > position;
76 | if (increasing) {
77 | this.updateTargetPosition(100);
78 | } else if (decreasing) {
79 | this.updateTargetPosition(0);
80 | }
81 |
82 | setTimeout(() => {
83 | // If no new position we can assume that blinds has been stopped
84 | if (this.position === position) {
85 | this.updateTargetPosition(this.position);
86 | }
87 | }, 2000);
88 | }
89 |
90 | updatePosition() {
91 | var blind = this.device.blindList[0];
92 | var position = this.blind.getCharacteristic(this.Characteristic.CurrentPosition);
93 | this.position = blind.position;
94 | this.log('Updating position to %s on blind \'%s\'', this.position, this.name);
95 | position.updateValue(this.position);
96 | }
97 |
98 | updateTargetPosition(position) {
99 | var targetPosition = this.blind.getCharacteristic(this.Characteristic.TargetPosition);
100 | this.targetPosition = position;
101 | this.log('Updating target position to %s on blind \'%s\'', this.targetPosition, this.name);
102 | targetPosition.updateValue(this.targetPosition);
103 | }
104 |
105 | updateBatteryLevel() {
106 | var lowBatteryStatus = this.blind.getCharacteristic(this.Characteristic.StatusLowBattery);
107 | this.batteryLevel = this.device.deviceInfo.battery
108 | this.log('Updating battery level to %s on blind \'%s\'', this.batteryLevel, this.name);
109 | lowBatteryStatus.updateValue(this.batteryLevel <= this.lowBatteryLimit);
110 | }
111 | };
112 |
--------------------------------------------------------------------------------
/src/device.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var Accessory = require('./accessory.js');
4 |
5 |
6 | module.exports = class Device extends Accessory {
7 |
8 | constructor(platform, device) {
9 |
10 | super(platform, device.name, device.instanceId);
11 |
12 | this.device = device;
13 |
14 | this.addAccessoryInformation();
15 | }
16 |
17 | deviceChanged() {
18 | }
19 |
20 | getManufacturer() {
21 | return this.device.deviceInfo.manufacturer;
22 | }
23 |
24 | getModel() {
25 | return this.device.deviceInfo.modelNumber;
26 | }
27 |
28 | getFirmwareVersion() {
29 | return this.device.deviceInfo.firmwareVersion;
30 | }
31 |
32 | };
33 |
--------------------------------------------------------------------------------
/src/gateway.js:
--------------------------------------------------------------------------------
1 | var Ikea = require('node-tradfri-client');
2 |
3 | module.exports = class Gateway {
4 |
5 | constructor(log, config) {
6 |
7 | config = Object.assign({}, config);
8 |
9 | if (config.psk && !config.securityCode)
10 | config.securityCode = config.psk;
11 |
12 | if (process.env.IKEA_TRADFRI_SECURITY_CODE)
13 | config.securityCode = process.env.IKEA_TRADFRI_SECURITY_CODE;
14 |
15 | if (process.env.IKEA_TRADFRI_HOST)
16 | config.host = process.env.IKEA_TRADFRI_HOST;
17 |
18 | if (config.securityCode == undefined && (config.psk == undefined))
19 | throw new Error('The security code from the back of the IKEA gateway must be specified in ~/.homebridge/config.json.')
20 |
21 | if (config.securityCode == undefined && (config.psk == undefined || config.identity == undefined))
22 | throw new Error('You have to supply an identity and the corresponding psk!')
23 |
24 | this.config = config;
25 | this.log = log;
26 | this.gateway = null;
27 | }
28 |
29 | getHostName() {
30 | return new Promise((resolve, reject) => {
31 |
32 | if (this.config.host != undefined)
33 | resolve(this.config.host);
34 | else {
35 | this.log('Discovering gateway...');
36 |
37 | Ikea.discoverGateway().then((discovery) => {
38 | if (discovery && discovery.name) {
39 | this.log('Discovered host "%s"', discovery.name);
40 | resolve(discovery.name);
41 | }
42 | else {
43 | reject(new Error('Cannot discover gateway address. Sorry, you have to enter the IP address yourself in ~/.homebridge/config.json.'));
44 | }
45 |
46 | })
47 | .catch((error) => {
48 | reject(error);
49 | })
50 | }
51 | });
52 | }
53 |
54 | enablePing() {
55 |
56 | setInterval(() => {
57 | this.gateway.ping().then(() => {
58 | // this.log('Ping OK.');
59 | })
60 | .catch((error) => {
61 | this.log('Ping failed!');
62 | this.log(error);
63 | })
64 | }, 60000);
65 |
66 | return Promise.resolve();
67 |
68 | }
69 |
70 | connect() {
71 | return new Promise((resolve, reject) => {
72 | Promise.resolve().then(() => {
73 | return this.getHostName();
74 | })
75 |
76 | .then((host) => {
77 | if (this.config.clientOptions != undefined) {
78 | this.gateway = new Ikea.TradfriClient(host, this.config.clientOptions);
79 | } else {
80 | this.gateway = new Ikea.TradfriClient(host);
81 | }
82 |
83 | this.gateway.on('device updated', (device) => {
84 | this.deviceUpdated(device);
85 | });
86 |
87 | this.gateway.on('group updated', (group) => {
88 | this.groupUpdated(group);
89 | });
90 | return Promise.resolve();
91 | })
92 |
93 | .then(() => {
94 | if (this.config.identity != undefined && this.config.psk != undefined) {
95 | return { "identity": this.config.identity, "psk": this.config.psk };
96 | } else {
97 | return this.gateway.authenticate(this.config.securityCode);
98 | }
99 | })
100 | .then((credentials) => {
101 | return this.gateway.connect(credentials.identity, credentials.psk);
102 | })
103 | .then((connected) => {
104 | if (connected)
105 | return Promise.resolve();
106 | else
107 | reject(new Error('Could not connect.'));
108 | })
109 | .then(() => {
110 | this.log('Loading devices...');
111 | return this.gateway.observeDevices();
112 | })
113 | .then(() => {
114 | this.log('Loading groups and scenes...');
115 | return this.gateway.observeGroupsAndScenes();
116 |
117 | })
118 | .then(() => {
119 | return this.enablePing();
120 | })
121 | .then(() => {
122 | this.log('Done.');
123 | resolve();
124 | })
125 | .catch((error) => {
126 | reject(error);
127 | })
128 | });
129 | }
130 |
131 | deviceUpdated(device) {
132 | }
133 |
134 | groupUpdated(group) {
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/src/lightbulb.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var Device = require('./device.js');
3 |
4 | module.exports = class Lightbulb extends Device {
5 |
6 | constructor(platform, device) {
7 | super(platform, device);
8 |
9 | this.log('Creating new lightbulb %s (%s)...', this.name, this.id);
10 | this.lightbulb = new this.Service.Lightbulb(this.name, this.uuid);
11 |
12 | this.addService('lightbulb', this.lightbulb);
13 |
14 | this.enablePower();
15 | this.enableBrightness();
16 | this.enableStatus();
17 | }
18 |
19 | deviceChanged(device) {
20 | super.deviceChanged();
21 |
22 | this.updatePower();
23 | this.updateBrightness();
24 | this.updateStatus();
25 | }
26 |
27 | enablePower() {
28 | var power = this.lightbulb.getCharacteristic(this.Characteristic.On);
29 |
30 | power.on('get', (callback) => {
31 | callback(null, this.power);
32 | });
33 |
34 | power.on('set', (value, callback) => {
35 | this.setPower(value, callback);
36 | });
37 |
38 | this.updatePower();
39 |
40 | }
41 |
42 | enableBrightness() {
43 | var brightness = this.lightbulb.addCharacteristic(this.Characteristic.Brightness);
44 |
45 | brightness.on('get', (callback) => {
46 | callback(null, this.brightness);
47 | });
48 |
49 | brightness.on('set', (value, callback) => {
50 | this.setBrightness(value, callback);
51 | });
52 |
53 | this.updateBrightness();
54 | }
55 |
56 | enableStatus() {
57 | var alive = this.lightbulb.addCharacteristic(this.Characteristic.StatusActive);
58 |
59 | alive.on('get', (callback) => {
60 | this.log('Light %s in currently %s.', this.name, this.device.alive ? 'ALIVE' : 'DEAD');
61 | callback(null, this.device.alive);
62 | });
63 |
64 | this.updateStatus();
65 |
66 |
67 | }
68 |
69 | setPower(value, callback) {
70 | this.log('Setting power to %s on lightbulb \'%s\'', value ? 'ON' : 'OFF', this.name);
71 | this.power = value;
72 |
73 | this.platform.gateway.operateLight(this.device, {
74 | onOff: this.power
75 | })
76 | .then(() => {
77 | if (callback)
78 | callback();
79 | })
80 | .catch((error) => {
81 | this.log(error);
82 | });
83 | }
84 |
85 | setBrightness(value, callback) {
86 | this.log('Setting brightness to %s on lightbulb \'%s\'', value, this.name);
87 | this.brightness = value;
88 |
89 | this.platform.gateway.operateLight(this.device, {
90 | dimmer: this.brightness
91 | })
92 | .then(() => {
93 | if (callback)
94 | callback();
95 | });
96 | }
97 |
98 | updatePower() {
99 | var light = this.device.lightList[0];
100 | var power = this.lightbulb.getCharacteristic(this.Characteristic.On);
101 |
102 | this.power = light.onOff;
103 |
104 | this.log('Updating power to %s on lightbulb \'%s\'', this.power ? 'ON' : 'OFF', this.name);
105 | power.updateValue(this.power);
106 | }
107 |
108 | updateBrightness() {
109 | var light = this.device.lightList[0];
110 | var brightness = this.lightbulb.getCharacteristic(this.Characteristic.Brightness);
111 |
112 | this.brightness = light.dimmer;
113 |
114 | this.log('Updating brightness to %s%% on lightbulb \'%s\'', this.brightness, this.name);
115 | brightness.updateValue(this.brightness);
116 |
117 | }
118 |
119 | updateStatus() {
120 | var alive = this.lightbulb.getCharacteristic(this.Characteristic.StatusActive);
121 |
122 | this.log('Updating active status to %s on lightbulb \'%s\'', this.device.alive ? 'ALIVE' : 'DEAD', this.name);
123 | alive.updateValue(this.device.alive);
124 | }
125 |
126 | };
127 |
--------------------------------------------------------------------------------
/src/outlet.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var Device = require('./device.js');
3 |
4 | module.exports = class Outlet extends Device {
5 |
6 | constructor(platform, device) {
7 | super(platform, device);
8 |
9 | this.outlet = new this.Service.Outlet(this.name, this.uuid);
10 |
11 | this.addService('outlet', this.outlet);
12 |
13 | this.enablePower();
14 | this.enableStatus();
15 | }
16 |
17 | deviceChanged(device) {
18 | super.deviceChanged();
19 |
20 | this.updatePower();
21 | this.updateStatus();
22 | }
23 |
24 | enablePower() {
25 | var power = this.outlet.getCharacteristic(this.Characteristic.On);
26 |
27 | power.on('get', (callback) => {
28 | callback(null, this.power);
29 | });
30 |
31 | power.on('set', (value, callback) => {
32 | this.setPower(value, callback);
33 | });
34 |
35 | this.updatePower();
36 |
37 | }
38 |
39 |
40 |
41 | enableStatus() {
42 | var alive = this.outlet.addCharacteristic(this.Characteristic.StatusActive);
43 |
44 | alive.on('get', (callback) => {
45 | this.log('Outlet %s in currently %s.', this.name, this.device.alive ? 'ALIVE' : 'DEAD');
46 | callback(null, this.device.alive);
47 | });
48 |
49 | this.updateStatus();
50 |
51 |
52 | }
53 |
54 | setPower(value, callback) {
55 | this.log('Setting power to %s on outlet \'%s\'', value ? 'ON' : 'OFF', this.name);
56 | this.power = value;
57 |
58 | this.platform.gateway.operatePlug(this.device, {
59 | onOff: this.power
60 | })
61 | .then(() => {
62 | if (callback)
63 | callback();
64 | })
65 | .catch((error) => {
66 | this.log(error);
67 | });
68 | }
69 |
70 |
71 |
72 | updatePower() {
73 |
74 | var plug = this.device.plugList[0];
75 | var power = this.outlet.getCharacteristic(this.Characteristic.On);
76 |
77 | this.power = plug.onOff;
78 |
79 | this.log('Updating power to %s on outlet \'%s\'', this.power ? 'ON' : 'OFF', this.name);
80 | power.updateValue(this.power);
81 | }
82 |
83 |
84 | updateStatus() {
85 | var alive = this.outlet.getCharacteristic(this.Characteristic.StatusActive);
86 |
87 | this.log('Updating active status to %s on outlet \'%s\'', this.device.alive ? 'ALIVE' : 'DEAD', this.name);
88 | alive.updateValue(this.device.alive);
89 | }
90 |
91 | };
92 |
--------------------------------------------------------------------------------
/src/platform.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var isArray = require('yow/isArray');
4 |
5 | var Lightbulb = require('./lightbulb.js');
6 | var WarmWhiteLightbulb = require('./warm-white-lightbulb.js');
7 | var RgbLightbulb = require('./rgb-lightbulb.js');
8 | var Outlet = require('./outlet.js');
9 | var Remote = require('./remote.js');
10 | var Blind = require('./blind.js');
11 | var Blind = require('./blind.js');
12 | var AirPurifier = require('./air-purifier.js');
13 | var Gateway = require('./gateway.js');
14 | var Ikea = require('node-tradfri-client');
15 |
16 |
17 | var Accessory, Service, Characteristic, UUIDGen;
18 |
19 |
20 | module.exports = class Platform extends Gateway {
21 |
22 | constructor(log, config, homebridge) {
23 |
24 | Accessory = homebridge.platformAccessory;
25 | Service = homebridge.hap.Service;
26 | Characteristic = homebridge.hap.Characteristic;
27 | UUIDGen = homebridge.hap.uuid;
28 |
29 | super(log, config);
30 |
31 | this.homebridge = homebridge;
32 | this.devices = {};
33 |
34 | this.homebridge.on('didFinishLaunching', () => {
35 | this.log('didFinishLaunching');
36 | });
37 | }
38 |
39 | deviceUpdated(device) {
40 |
41 |
42 | var item = this.devices[device.instanceId];
43 |
44 | if (item != undefined) {
45 | item.device = device;
46 | item.deviceChanged();
47 | }
48 | else {
49 | }
50 | }
51 |
52 | groupUpdated(group) {
53 | }
54 |
55 |
56 | setup() {
57 |
58 | var expose = {};
59 |
60 | if (isArray(this.config.expose)) {
61 | this.config.expose.forEach((item) => {
62 | expose[item] = true;
63 | });
64 | }
65 | else {
66 | expose['outlets'] = true;
67 | expose['lightbulbs'] = true;
68 | expose['blinds'] = true;
69 | expose['remotes'] = true;
70 | expose['airPurifiers'] = true;
71 | expose['shortcut-buttons'] = true;
72 | expose['non-ikea-outlets'] = false;
73 | expose['non-ikea-lightbulbs'] = false;
74 | expose['non-ikea-blinds'] = false;
75 | expose['non-ikea-remotes'] = false;
76 | }
77 |
78 | for (var id in this.gateway.devices) {
79 | var device = this.gateway.devices[id];
80 | var supportedDevice = undefined;
81 |
82 | switch (device.type) {
83 | case Ikea.AccessoryTypes.plug: {
84 |
85 | // Make sure the device has a plugList and is to be exposed
86 | if (device.plugList && (expose['outlets'] || (device.deviceInfo.manufacturer !== 'IKEA of Sweden' && expose['non-ikea-outlets'])))
87 | supportedDevice = new Outlet(this, device);
88 |
89 | break;
90 | }
91 |
92 | case Ikea.AccessoryTypes.lightbulb: {
93 |
94 | // Make sure the device has a lightList and is to be exposed
95 | if (device.lightList && (expose['lightbulbs'] || (device.deviceInfo.manufacturer !== 'IKEA of Sweden' && expose['non-ikea-lightbulbs']))) {
96 | var spectrum = device.lightList[0]._spectrum;
97 |
98 | switch(spectrum) {
99 | case 'white': {
100 | supportedDevice = new WarmWhiteLightbulb(this, device);
101 | break;
102 | }
103 | case 'rgbw':
104 | case 'rgb': {
105 | supportedDevice = new RgbLightbulb(this, device);
106 | break;
107 | }
108 | default: {
109 | supportedDevice = new Lightbulb(this, device);
110 | break;
111 | }
112 | }
113 |
114 | }
115 |
116 | break;
117 | }
118 |
119 | case Ikea.AccessoryTypes.blind: {
120 |
121 | // Make sure the device has a blindList and is to be exposed
122 | if (device.blindList && (expose['blinds'] || (device.deviceInfo.manufacturer !== 'IKEA of Sweden' && expose['non-ikea-blinds'])))
123 | supportedDevice = new Blind(this, device);
124 |
125 | break;
126 | }
127 |
128 | case Ikea.AccessoryTypes.remote:
129 | case Ikea.AccessoryTypes.slaveRemote: {
130 |
131 | // Make sure the device has a remoteList and is to be exposed
132 | const isShortcutButton = device.deviceInfo.modelNumber === 'TRADFRI SHORTCUT Button';
133 | if (device.switchList && ((isShortcutButton && expose['shortcut-buttons']) || (!isShortcutButton && expose['remotes'] || (device.deviceInfo.manufacturer !== 'IKEA of Sweden' && expose['non-ikea-remotes']))))
134 | supportedDevice = new Remote(this, device);
135 |
136 | break;
137 | }
138 |
139 | case Ikea.AccessoryTypes.airPurifier: {
140 |
141 | // Make sure the device has a airPurifierList and is to be exposed
142 | if (device.airPurifierList && (expose['airPurifiers'] || (device.deviceInfo.manufacturer !== 'IKEA of Sweden' && expose['non-ikea-airPurifiers'])))
143 | supportedDevice = new AirPurifier(this, device);
144 |
145 | break;
146 | }
147 | }
148 |
149 | if (this.config.ignore && this.config.ignore.indexOf(id) > -1) {
150 | supportedDevice = false;
151 | }
152 |
153 | if (supportedDevice) {
154 | this.devices[device.instanceId] = supportedDevice;
155 | }
156 | else {
157 | this.log('The following device is ignored.');
158 | this.log(JSON.stringify(device.deviceInfo));
159 | }
160 | }
161 |
162 | return Promise.resolve();
163 |
164 | }
165 |
166 | accessories(callback) {
167 |
168 | this.connect().then(() => {
169 | return this.setup();
170 | })
171 | .then(() => {
172 | var accessories = [];
173 |
174 | for (var id in this.devices) {
175 | accessories.push(this.devices[id]);
176 | }
177 |
178 | callback(accessories);
179 | })
180 | .catch((error) => {
181 | // Display error and make sure to stop.
182 | // If we just return an empty array, all our automation
183 | // rules and scenarios will be removed from the Home App.
184 | console.log(error);
185 | process.exit(1);
186 | throw error;
187 | })
188 |
189 |
190 | }
191 |
192 |
193 | }
194 |
--------------------------------------------------------------------------------
/src/remote.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var Device = require('./device.js');
3 |
4 | module.exports = class Remote extends Device {
5 |
6 | constructor(platform, device) {
7 | super(platform, device);
8 |
9 | this.services.battery = new this.Service.BatteryService(`${this.name} Battery`);
10 | this.lowBatteryLimit = platform.config.lowBatteryLimit || 10;
11 | this.enableBattery();
12 | }
13 |
14 | deviceChanged(device) {
15 | super.deviceChanged();
16 | this.updateBatteryLevel();
17 | }
18 |
19 | enableBattery() {
20 | var batteryLevel = this.services.battery.getCharacteristic(this.Characteristic.BatteryLevel);
21 | batteryLevel.on('get', (callback) => {
22 | callback(null, this.device.deviceInfo.battery);
23 | });
24 |
25 | var lowBatteryStatus = this.services.battery.getCharacteristic(this.Characteristic.StatusLowBattery);
26 | lowBatteryStatus.on('get', (callback) => {
27 | let battery = this.device.deviceInfo.battery
28 | callback(null, battery <= this.lowBatteryLimit);
29 | });
30 | }
31 |
32 | updateBatteryLevel() {
33 | var lowBatteryStatus = this.blind.getCharacteristic(this.Characteristic.StatusLowBattery);
34 | this.batteryLevel = this.device.deviceInfo.battery
35 | this.log('Updating battery level to %s on blind \'%s\'', this.batteryLevel, this.name);
36 | lowBatteryStatus.updateValue(this.batteryLevel <= this.lowBatteryLimit);
37 | }
38 | };
39 |
--------------------------------------------------------------------------------
/src/rgb-lightbulb.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var Lightbulb = require('./lightbulb.js');
3 | var ColorConvert = require('color-convert');
4 |
5 | module.exports = class RgbLightbulb extends Lightbulb {
6 |
7 | constructor(platform, device) {
8 | super(platform, device);
9 |
10 | this.hue = 0;
11 | this.saturation = 0;
12 | this.luminance = 50;
13 |
14 | this.enableHue();
15 | this.enableSaturation();
16 | }
17 |
18 |
19 |
20 | deviceChanged() {
21 | super.deviceChanged();
22 | this.updateHue();
23 | this.updateSaturation();
24 | }
25 |
26 | updateHue() {
27 | var light = this.device.lightList[0];
28 | var hue = this.lightbulb.getCharacteristic(this.Characteristic.Hue);
29 | var color = ColorConvert.hex.hsl(light.color);
30 |
31 | hue.updateValue(this.hue = color[0]);
32 | this.log('Updating to color %s (%s, %s, %s) on lightbulb \'%s\'', light.color, this.hue, this.saturation, this.luminance, this.name);
33 | }
34 |
35 | updateSaturation() {
36 | var light = this.device.lightList[0];
37 | var saturation = this.lightbulb.getCharacteristic(this.Characteristic.Saturation);
38 | var color = ColorConvert.hex.hsl(light.color);
39 |
40 | saturation.updateValue(this.saturation = this.saturation = color[1]);
41 | this.log('Updating to color %s (%s, %s, %s) on lightbulb \'%s\'', light.color, this.hue, this.saturation, this.luminance, this.name);
42 | }
43 |
44 | enableHue() {
45 | var hue = this.lightbulb.getCharacteristic(this.Characteristic.Hue);
46 |
47 | this.updateHue();
48 |
49 | hue.on('get', (callback) => {
50 | callback(null, this.hue);
51 | });
52 |
53 | hue.on('set', (value, callback) => {
54 | // Set value
55 | this.hue = value;
56 | this.log('Setting hue to %s on lightbulb \'%s\'', this.hue, this.name);
57 |
58 | this.platform.gateway.operateLight(this.device, {
59 | color: ColorConvert.hsl.hex(this.hue, this.saturation, this.luminance),
60 | transitionTime: 0.1
61 | })
62 | .then(() => {
63 | if (callback)
64 | callback();
65 | })
66 | });
67 | }
68 |
69 |
70 | enableSaturation() {
71 | var saturation = this.lightbulb.getCharacteristic(this.Characteristic.Saturation);
72 |
73 | this.updateSaturation();
74 |
75 | saturation.on('get', (callback) => {
76 | callback(null, this.saturation);
77 | });
78 |
79 | saturation.on('set', (value, callback) => {
80 | // Set value
81 | this.saturation = value;
82 | this.log('Setting saturation to %s on lightbulb \'%s\'', this.saturation, this.name);
83 |
84 | this.platform.gateway.operateLight(this.device, {
85 | color: ColorConvert.hsl.hex(this.hue, this.saturation, this.luminance),
86 | transitionTime: 0.1
87 | })
88 | .then(() => {
89 | if (callback)
90 | callback();
91 | })
92 | });
93 | }
94 |
95 |
96 |
97 | };
98 |
--------------------------------------------------------------------------------
/src/warm-white-lightbulb.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var Lightbulb = require('./lightbulb.js');
3 |
4 | const COLOR_MIN = 140;
5 | const COLOR_MAX = 500;
6 |
7 | module.exports = class WarmWhiteLightbulb extends Lightbulb {
8 |
9 | constructor(platform, device) {
10 | super(platform, device);
11 |
12 | this.colorTemperature = (COLOR_MAX + COLOR_MIN) / 2;
13 |
14 | this.enableColorTemperature();
15 | }
16 |
17 | deviceChanged() {
18 | super.deviceChanged();
19 | this.updateColorTemperature();
20 | }
21 |
22 | enableColorTemperature() {
23 | var colorTemperature = this.lightbulb.getCharacteristic(this.Characteristic.ColorTemperature);
24 |
25 | colorTemperature.on('get', (callback) => {
26 | callback(null, this.colorTemperature);
27 | });
28 |
29 | colorTemperature.on('set', (value, callback) => {
30 | this.setColorTemperature(value, callback);
31 | });
32 |
33 | this.updateColorTemperature();
34 | }
35 |
36 | updateColorTemperature() {
37 | var light = this.device.lightList[0];
38 | var colorTemperature = this.lightbulb.getCharacteristic(this.Characteristic.ColorTemperature);
39 |
40 | this.colorTemperature = COLOR_MIN + ((COLOR_MAX - COLOR_MIN) * (light.colorTemperature / 100));
41 |
42 | this.log('Updating color temperature to %s on lightbulb \'%s\'', this.colorTemperature, this.name);
43 | colorTemperature.updateValue(this.colorTemperature);
44 | }
45 |
46 | setColorTemperature(value, callback) {
47 |
48 | // Make sure it is between MIN and MAX
49 | value = Math.max(Math.min(value, COLOR_MAX), COLOR_MIN);
50 |
51 | // Set value
52 | this.colorTemperature = value;
53 |
54 | // Compute color temperature in percent (0-100)
55 | var percent = parseInt(100 * (this.colorTemperature - COLOR_MIN) / (COLOR_MAX - COLOR_MIN));
56 |
57 | this.log('Setting color temperature to %s%% on lightbulb \'%s\'', percent, this.name);
58 |
59 | this.platform.gateway.operateLight(this.device, {
60 | colorTemperature: percent
61 | })
62 | .then(() => {
63 | if (callback)
64 | callback();
65 | })
66 | }
67 |
68 |
69 | };
70 |
--------------------------------------------------------------------------------
/test.js:
--------------------------------------------------------------------------------
1 |
2 | var Ikea = require('node-tradfri-client');
3 | var Path = require('path');
4 |
5 | require('dotenv').config({path: Path.join(process.env.HOME, '.homebridge/.env')});
6 |
7 |
8 | var Gateway = require('./src/gateway.js')
9 | var ikea = new Gateway({
10 | log: console.log,
11 | host: 'gw-b8d7af2a9d45'
12 | });
13 |
14 | ikea.gateway.connect().then(() => {
15 |
16 | console.log(ikea.gateway);
17 |
18 |
19 | var device = ikea.gateway.devices[65562];
20 | console.log('Device %s (%s)', device.instanceId, device.name);
21 |
22 | })
23 | .catch((error) => {
24 | console.log(error);
25 | });
26 |
--------------------------------------------------------------------------------