homebridge-plugin-sol 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.project +11 -0
- package/LICENSE +176 -0
- package/README.md +137 -0
- package/config.schema.json +21 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/platform.d.ts +27 -0
- package/dist/platform.js +93 -0
- package/dist/platform.js.map +1 -0
- package/dist/platformAccessory.d.ts +34 -0
- package/dist/platformAccessory.js +250 -0
- package/dist/platformAccessory.js.map +1 -0
- package/dist/settings.d.ts +9 -0
- package/dist/settings.js +10 -0
- package/dist/settings.js.map +1 -0
- package/dist/sol-api.d.ts +70 -0
- package/dist/sol-api.js +222 -0
- package/dist/sol-api.js.map +1 -0
- package/package.json +47 -0
package/.project
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
|
|
3
|
+
<img src="https://github.com/homebridge/branding/raw/latest/logos/homebridge-wordmark-logo-vertical.png" width="150">
|
|
4
|
+
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<span align="center">
|
|
8
|
+
|
|
9
|
+
# Homebridge Platform Plugin SOL
|
|
10
|
+
|
|
11
|
+
</span>
|
|
12
|
+
|
|
13
|
+
This is the homebridge plugin for SOL smarthome controlled devices.
|
|
14
|
+
It is a very specific setup for one smarthome and not designed to work on other places.
|
|
15
|
+
SOL is a specific bridge connector for Fritzbox, Shelly, EVCC, Sungrow and Hue with a very specific frontend and caching mechanism.
|
|
16
|
+
|
|
17
|
+
This plugin provides several device types, like:
|
|
18
|
+
|
|
19
|
+
- switches (Fritzbox, Shelly)
|
|
20
|
+
- ligthbulbs (Hue)
|
|
21
|
+
- sensors for light and humidity (Shelly)
|
|
22
|
+
- sensors for battery and power management (EVCC, Fritzbox, Shelly, Sungrow).
|
|
23
|
+
|
|
24
|
+
This repository is based on the template Homebridge dynamic platform plugin together with the [developer documentation](https://developers.homebridge.io/).
|
|
25
|
+
|
|
26
|
+
### Build Plugin
|
|
27
|
+
|
|
28
|
+
TypeScript needs to be compiled into JavaScript before it can run. The following command will compile the contents of your [`src`](./src) directory and put the resulting code into the `dist` folder.
|
|
29
|
+
|
|
30
|
+
```shell
|
|
31
|
+
npm run build
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Link To Homebridge
|
|
35
|
+
|
|
36
|
+
We use a local home bridge installation to develop the plugin.
|
|
37
|
+
|
|
38
|
+
```shell
|
|
39
|
+
sudo npm install -g --unsafe-perm homebridge homebridge-config-ui-x
|
|
40
|
+
sudo hb-service install
|
|
41
|
+
sudo hb-service status
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
This installs a local homebridge.
|
|
45
|
+
|
|
46
|
+
Run this command so your global installation of Homebridge can discover the plugin in your development environment:
|
|
47
|
+
|
|
48
|
+
```shell
|
|
49
|
+
npm link
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
You can now start Homebridge, use the `-D` flag, so you can see debug log messages in your plugin:
|
|
53
|
+
|
|
54
|
+
```shell
|
|
55
|
+
homebridge -D
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Development
|
|
59
|
+
|
|
60
|
+
If you want to have your code compile automatically as you make changes, and restart Homebridge automatically between changes, you first need to add your plugin as a platform in `~/.homebridge/config.json`:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
{
|
|
64
|
+
...
|
|
65
|
+
"platforms": [
|
|
66
|
+
{
|
|
67
|
+
"name": "Config",
|
|
68
|
+
"port": 8581,
|
|
69
|
+
"platform": "config"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "SOL Platform",
|
|
73
|
+
"host": "http://localhost:8080",
|
|
74
|
+
"platform": "SOLHomebridgePlugin"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
and then you can run:
|
|
81
|
+
|
|
82
|
+
```shell
|
|
83
|
+
npm run watch
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
This will launch an instance of Homebridge in debug mode which will restart every time you make a change to the source code. It will load the config stored in the default location under `~/.homebridge`. You may need to stop other running instances of Homebridge while using this command to prevent conflicts. You can adjust the Homebridge startup command in the [`nodemon.json`](./nodemon.json) file.
|
|
87
|
+
|
|
88
|
+
### Publish Package
|
|
89
|
+
|
|
90
|
+
When you are ready to publish your plugin to [npm](https://www.npmjs.com/), make sure you have removed the `private` attribute from the [`package.json`](./package.json) file then run:
|
|
91
|
+
|
|
92
|
+
```shell
|
|
93
|
+
npm publish
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
If you are publishing a scoped plugin, i.e. `@username/homebridge-xxx` you will need to add `--access=public` to command the first time you publish.
|
|
97
|
+
|
|
98
|
+
#### Publishing Beta Versions
|
|
99
|
+
|
|
100
|
+
You can publish *beta* versions of your plugin for other users to test before you release it to everyone.
|
|
101
|
+
|
|
102
|
+
```shell
|
|
103
|
+
# create a new pre-release version (eg. 2.1.0-beta.1)
|
|
104
|
+
npm version prepatch --preid beta
|
|
105
|
+
|
|
106
|
+
# publish to @beta
|
|
107
|
+
npm publish --tag=beta
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Users can then install the *beta* version by appending `@beta` to the install command, for example:
|
|
111
|
+
|
|
112
|
+
```shell
|
|
113
|
+
sudo npm install -g homebridge-example-plugin@beta
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Best Practices
|
|
117
|
+
|
|
118
|
+
Consider creating your plugin with the [Homebridge Verified](https://github.com/homebridge/verified) criteria in mind. This will help you to create a plugin that is easy to use and works well with Homebridge.
|
|
119
|
+
You can then submit your plugin to the Homebridge Verified list for review.
|
|
120
|
+
The most up-to-date criteria can be found [here](https://github.com/homebridge/verified#requirements).
|
|
121
|
+
For reference, the current criteria are:
|
|
122
|
+
|
|
123
|
+
- The plugin must successfully install.
|
|
124
|
+
- The plugin must implement the [Homebridge Plugin Settings GUI](https://github.com/oznu/homebridge-config-ui-x/wiki/Developers:-Plugin-Settings-GUI).
|
|
125
|
+
- The plugin must not start unless it is configured.
|
|
126
|
+
- The plugin must not execute post-install scripts that modify the users' system in any way.
|
|
127
|
+
- The plugin must not contain any analytics or calls that enable you to track the user.
|
|
128
|
+
- The plugin must not throw unhandled exceptions, the plugin must catch and log its own errors.
|
|
129
|
+
- The plugin must be published to npm and the source code available on GitHub.
|
|
130
|
+
- A GitHub release - with patch notes - should be created for every new version of your plugin.
|
|
131
|
+
- The plugin must run on all [supported LTS versions of Node.js](https://github.com/homebridge/homebridge/wiki/How-To-Update-Node.js), at the time of writing this is Node.js v16 and v18.
|
|
132
|
+
- The plugin must not require the user to run Homebridge in a TTY or with non-standard startup parameters, even for initial configuration.
|
|
133
|
+
- If the plugin needs to write files to disk (cache, keys, etc.), it must store them inside the Homebridge storage directory.
|
|
134
|
+
|
|
135
|
+
### Todos
|
|
136
|
+
|
|
137
|
+
- Publish
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pluginAlias": "SOLHomebridgePlugin",
|
|
3
|
+
"pluginType": "platform",
|
|
4
|
+
"singular": true,
|
|
5
|
+
"schema": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"name": {
|
|
9
|
+
"title": "Name",
|
|
10
|
+
"type": "string",
|
|
11
|
+
"required": true,
|
|
12
|
+
"default": "SOL Platform"
|
|
13
|
+
},
|
|
14
|
+
"host": {
|
|
15
|
+
"title": "SOL URL",
|
|
16
|
+
"type": "string",
|
|
17
|
+
"required": true
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SOLHomebridgePlatform } from './platform.js';
|
|
2
|
+
import { PLATFORM_NAME } from './settings.js';
|
|
3
|
+
/**
|
|
4
|
+
* This method registers the platform with Homebridge
|
|
5
|
+
*/
|
|
6
|
+
export default (api) => {
|
|
7
|
+
api.registerPlatform(PLATFORM_NAME, SOLHomebridgePlatform);
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;GAEG;AACH,eAAe,CAAC,GAAQ,EAAE,EAAE;IAC1B,GAAG,CAAC,gBAAgB,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC;AAC7D,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { API, Characteristic, DynamicPlatformPlugin, Logging, PlatformAccessory, PlatformConfig, Service } from 'homebridge';
|
|
2
|
+
/**
|
|
3
|
+
* HomebridgePlatform
|
|
4
|
+
* This class is the main constructor for your plugin, this is where you should
|
|
5
|
+
* parse the user config and discover/register accessories with Homebridge.
|
|
6
|
+
*/
|
|
7
|
+
export declare class SOLHomebridgePlatform implements DynamicPlatformPlugin {
|
|
8
|
+
readonly log: Logging;
|
|
9
|
+
readonly config: PlatformConfig;
|
|
10
|
+
readonly api: API;
|
|
11
|
+
readonly Service: typeof Service;
|
|
12
|
+
readonly Characteristic: typeof Characteristic;
|
|
13
|
+
readonly accessories: PlatformAccessory[];
|
|
14
|
+
private readonly solApi;
|
|
15
|
+
constructor(log: Logging, config: PlatformConfig, api: API);
|
|
16
|
+
/**
|
|
17
|
+
* This function is invoked when homebridge restores cached accessories from disk at startup.
|
|
18
|
+
* It should be used to set up event handlers for characteristics and update respective values.
|
|
19
|
+
*/
|
|
20
|
+
configureAccessory(accessory: PlatformAccessory): void;
|
|
21
|
+
/**
|
|
22
|
+
* This is an example method showing how to register discovered accessories.
|
|
23
|
+
* Accessories must only be registered once, previously created accessories
|
|
24
|
+
* must not be registered again to prevent "duplicate UUID" errors.
|
|
25
|
+
*/
|
|
26
|
+
discoverDevices(): Promise<void>;
|
|
27
|
+
}
|
package/dist/platform.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { SOLPlatformAccessory } from './platformAccessory.js';
|
|
2
|
+
import { PLATFORM_NAME, PLUGIN_NAME } from './settings.js';
|
|
3
|
+
import { SolApi } from './sol-api.js';
|
|
4
|
+
/**
|
|
5
|
+
* HomebridgePlatform
|
|
6
|
+
* This class is the main constructor for your plugin, this is where you should
|
|
7
|
+
* parse the user config and discover/register accessories with Homebridge.
|
|
8
|
+
*/
|
|
9
|
+
export class SOLHomebridgePlatform {
|
|
10
|
+
log;
|
|
11
|
+
config;
|
|
12
|
+
api;
|
|
13
|
+
Service;
|
|
14
|
+
Characteristic;
|
|
15
|
+
// this is used to track restored cached accessories
|
|
16
|
+
accessories = [];
|
|
17
|
+
solApi;
|
|
18
|
+
constructor(log, config, api) {
|
|
19
|
+
this.log = log;
|
|
20
|
+
this.config = config;
|
|
21
|
+
this.api = api;
|
|
22
|
+
this.Service = api.hap.Service;
|
|
23
|
+
this.Characteristic = api.hap.Characteristic;
|
|
24
|
+
this.log.debug('Finished initializing platform:', this.config.name);
|
|
25
|
+
this.solApi = new SolApi(this.log, this.config.host);
|
|
26
|
+
// When this event is fired it means Homebridge has restored all cached accessories from disk.
|
|
27
|
+
// Dynamic Platform plugins should only register new accessories after this event was fired,
|
|
28
|
+
// in order to ensure they weren't added to homebridge already. This event can also be used
|
|
29
|
+
// to start discovery of new accessories.
|
|
30
|
+
this.api.on('didFinishLaunching', () => {
|
|
31
|
+
this.log.debug('Executed didFinishLaunching callback');
|
|
32
|
+
// run the method to discover / register your devices as accessories
|
|
33
|
+
this.discoverDevices();
|
|
34
|
+
setInterval(() => {
|
|
35
|
+
this.discoverDevices();
|
|
36
|
+
}, 30000);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* This function is invoked when homebridge restores cached accessories from disk at startup.
|
|
41
|
+
* It should be used to set up event handlers for characteristics and update respective values.
|
|
42
|
+
*/
|
|
43
|
+
configureAccessory(accessory) {
|
|
44
|
+
this.log.info('Loading accessory from cache:', accessory.displayName);
|
|
45
|
+
// add the restored accessory to the accessories cache, so we can track if it has already been registered
|
|
46
|
+
this.accessories.push(accessory);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* This is an example method showing how to register discovered accessories.
|
|
50
|
+
* Accessories must only be registered once, previously created accessories
|
|
51
|
+
* must not be registered again to prevent "duplicate UUID" errors.
|
|
52
|
+
*/
|
|
53
|
+
async discoverDevices() {
|
|
54
|
+
// EXAMPLE ONLY
|
|
55
|
+
// A real plugin you would discover accessories from the local network, cloud services
|
|
56
|
+
// or a user-defined array in the platform config.
|
|
57
|
+
// get all devices from SOL
|
|
58
|
+
const devices = await this.solApi.getDevices();
|
|
59
|
+
// loop over the discovered devices and register each one if it has not already been registered
|
|
60
|
+
for await (const device of devices) {
|
|
61
|
+
// generate a unique id for the accessory this should be generated from
|
|
62
|
+
// something globally unique, but constant, for example, the device serial
|
|
63
|
+
// number or MAC address
|
|
64
|
+
const uuid = this.api.hap.uuid.generate(device.id);
|
|
65
|
+
// see if an accessory with the same uuid has already been registered and restored from
|
|
66
|
+
// the cached devices we stored in the `configureAccessory` method above
|
|
67
|
+
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
68
|
+
if (existingAccessory) {
|
|
69
|
+
// the accessory already exists
|
|
70
|
+
this.log.info('Restoring existing accessory from cache:', existingAccessory.displayName);
|
|
71
|
+
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. e.g.:
|
|
72
|
+
existingAccessory.context.device = device;
|
|
73
|
+
new SOLPlatformAccessory(this, existingAccessory, device, this.solApi);
|
|
74
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
// the accessory does not yet exist, so we need to create it
|
|
78
|
+
this.log.info('Adding new accessory:', device.name);
|
|
79
|
+
// create a new accessory
|
|
80
|
+
const accessory = new this.api.platformAccessory(device.name, uuid);
|
|
81
|
+
// store a copy of the device object in the `accessory.context`
|
|
82
|
+
// the `context` property can be used to store any data about the accessory you may need
|
|
83
|
+
accessory.context.device = device;
|
|
84
|
+
// create the accessory handler for the newly create accessory
|
|
85
|
+
// this is imported from `platformAccessory.ts`
|
|
86
|
+
new SOLPlatformAccessory(this, accessory, device, this.solApi);
|
|
87
|
+
// link the accessory to your platform
|
|
88
|
+
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;;;GAIG;AACH,MAAM,OAAO,qBAAqB;IASd;IACA;IACA;IAVF,OAAO,CAAiB;IACxB,cAAc,CAAwB;IAEtD,oDAAoD;IACpC,WAAW,GAAwB,EAAE,CAAC;IACrC,MAAM,CAAS;IAEhC,YACkB,GAAY,EACZ,MAAsB,EACtB,GAAQ;QAFR,QAAG,GAAH,GAAG,CAAS;QACZ,WAAM,GAAN,MAAM,CAAgB;QACtB,QAAG,GAAH,GAAG,CAAK;QAExB,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC;QAE7C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,iCAAiC,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpE,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,IAAK,CAAC,CAAC;QAEtD,8FAA8F;QAC9F,4FAA4F;QAC5F,2FAA2F;QAC3F,yCAAyC;QACzC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,oBAAoB,EAAE,GAAG,EAAE;YACrC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;YACvD,oEAAoE;YACpE,IAAI,CA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AM,CAAC,CAAC;gBACvE,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;YAC1D,CAAC;iBAAM,CAAC;gBACN,4DAA4D;gBAC5D,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,uBAAuB,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;gBAEpD,yBAAyB;gBACzB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAEpE,+DAA+D;gBAC/D,wFAAwF;gBACxF,SAAS,CAAC,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;gBAElC,8DAA8D;gBAC9D,+CAA+C;gBAC/C,IAAI,oBAAoB,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;gBAE/D,sCAAsC;gBACtC,IAAI,CAAC,GAAG,CAAC,2BAA2B,CAAC,WAAW,EAAE,aAAa,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;YAChF,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CharacteristicValue, PlatformAccessory } from 'homebridge';
|
|
2
|
+
import type { SOLHomebridgePlatform } from './platform.js';
|
|
3
|
+
import { SolApi, SolDevice } from './sol-api.js';
|
|
4
|
+
/**
|
|
5
|
+
* Platform Accessory
|
|
6
|
+
* An instance of this class is created for each accessory your platform registers
|
|
7
|
+
* Each accessory may expose multiple services of different service types.
|
|
8
|
+
*/
|
|
9
|
+
export declare class SOLPlatformAccessory {
|
|
10
|
+
private readonly platform;
|
|
11
|
+
private readonly accessory;
|
|
12
|
+
private readonly device;
|
|
13
|
+
private readonly solApi;
|
|
14
|
+
constructor(platform: SOLHomebridgePlatform, accessory: PlatformAccessory, device: SolDevice, solApi: SolApi);
|
|
15
|
+
/**
|
|
16
|
+
* Handle "SET" requests from HomeKit
|
|
17
|
+
* These are sent when the user changes the state of an accessory, for example, turning on a Light bulb.
|
|
18
|
+
*/
|
|
19
|
+
setOn(value: CharacteristicValue): Promise<void>;
|
|
20
|
+
getOn(): Promise<CharacteristicValue>;
|
|
21
|
+
setBrightness(value: CharacteristicValue): Promise<void>;
|
|
22
|
+
getBrightness(): Promise<CharacteristicValue>;
|
|
23
|
+
setSaturation(value: CharacteristicValue): Promise<void>;
|
|
24
|
+
getSaturation(): Promise<CharacteristicValue>;
|
|
25
|
+
setHue(value: CharacteristicValue): Promise<void>;
|
|
26
|
+
getHue(): Promise<CharacteristicValue>;
|
|
27
|
+
getDaylight(): Promise<CharacteristicValue>;
|
|
28
|
+
getCurrentTemperature(): Promise<CharacteristicValue>;
|
|
29
|
+
getCurrentHumidity(): Promise<CharacteristicValue>;
|
|
30
|
+
getBatteryLevel(): Promise<CharacteristicValue>;
|
|
31
|
+
getChargingState(): Promise<CharacteristicValue>;
|
|
32
|
+
getLowBatteryStatus(): Promise<CharacteristicValue>;
|
|
33
|
+
getModel(): any;
|
|
34
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { PLUGIN_AUTHOR } from './settings.js';
|
|
2
|
+
/**
|
|
3
|
+
* Platform Accessory
|
|
4
|
+
* An instance of this class is created for each accessory your platform registers
|
|
5
|
+
* Each accessory may expose multiple services of different service types.
|
|
6
|
+
*/
|
|
7
|
+
export class SOLPlatformAccessory {
|
|
8
|
+
platform;
|
|
9
|
+
accessory;
|
|
10
|
+
device;
|
|
11
|
+
solApi;
|
|
12
|
+
constructor(platform, accessory, device, solApi) {
|
|
13
|
+
this.platform = platform;
|
|
14
|
+
this.accessory = accessory;
|
|
15
|
+
this.device = device;
|
|
16
|
+
this.solApi = solApi;
|
|
17
|
+
// set accessory information
|
|
18
|
+
// see https://developers.homebridge.io/#/service/AccessoryInformation
|
|
19
|
+
this.accessory.getService(this.platform.Service.AccessoryInformation)
|
|
20
|
+
.setCharacteristic(this.platform.Characteristic.Manufacturer, PLUGIN_AUTHOR + ' [' + device.bridge + ']')
|
|
21
|
+
.setCharacteristic(this.platform.Characteristic.Model, this.getModel())
|
|
22
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.id)
|
|
23
|
+
.setCharacteristic(this.platform.Characteristic.Active, device.state.reachable)
|
|
24
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, device.version)
|
|
25
|
+
.setCharacteristic(this.platform.Characteristic.Name, device.name);
|
|
26
|
+
// HAP-NodeJS WARNING: The accessory 'Zimmer Mats-Ole' has an invalid 'Name' characteristic ('Zimmer Mats-Ole').
|
|
27
|
+
// Please use only alphanumeric, space, and apostrophe characters. Ensure it starts and ends with an alphabetic
|
|
28
|
+
// or numeric character, and avoid emojis. This may prevent the accessory from being added in the Home App or
|
|
29
|
+
// cause unresponsiveness.
|
|
30
|
+
switch (device.type) {
|
|
31
|
+
case 'lightbulb': {
|
|
32
|
+
// https://developers.homebridge.io/#/service/Lightbulb
|
|
33
|
+
// - for Hue, Shelly, Fritzbox
|
|
34
|
+
// get the LightBulb service if it exists, otherwise create a new LightBulb service
|
|
35
|
+
// you can create multiple services for each accessory
|
|
36
|
+
const lightbulb = this.accessory.getService(this.platform.Service.Lightbulb)
|
|
37
|
+
|| this.accessory.addService(this.platform.Service.Lightbulb);
|
|
38
|
+
// register handlers for the On/Off Characteristic
|
|
39
|
+
lightbulb.getCharacteristic(this.platform.Characteristic.On)
|
|
40
|
+
.onSet(this.setOn.bind(this)) // SET - bind to the `setOn` method below
|
|
41
|
+
.onGet(this.getOn.bind(this)); // GET - bind to the `getOn` method below
|
|
42
|
+
if (device.capability.brightness) {
|
|
43
|
+
// register handlers for the Brightness Characteristic
|
|
44
|
+
lightbulb.getCharacteristic(this.platform.Characteristic.Brightness)
|
|
45
|
+
.onGet(this.getBrightness.bind(this))
|
|
46
|
+
.onSet(this.setBrightness.bind(this)); // SET - bind to the 'setBrightness` method below
|
|
47
|
+
}
|
|
48
|
+
if (device.capability.color) {
|
|
49
|
+
// need to find a way from rgb to hue, saturation, color temperature
|
|
50
|
+
lightbulb.getCharacteristic(this.platform.Characteristic.Saturation)
|
|
51
|
+
.onGet(this.getSaturation.bind(this))
|
|
52
|
+
.onSet(this.setSaturation.bind(this));
|
|
53
|
+
lightbulb.getCharacteristic(this.platform.Characteristic.Hue)
|
|
54
|
+
.onGet(this.getHue.bind(this))
|
|
55
|
+
.onSet(this.setHue.bind(this));
|
|
56
|
+
}
|
|
57
|
+
if (device.capability.temperature) {
|
|
58
|
+
const temperatureSensor = this.accessory.getService(this.platform.Service.TemperatureSensor)
|
|
59
|
+
|| this.accessory.addService(this.platform.Service.TemperatureSensor);
|
|
60
|
+
temperatureSensor.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
|
|
61
|
+
.onGet(this.getCurrentTemperature.bind(this));
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
case 'daylight': {
|
|
66
|
+
// https://developers.homebridge.io/#/service/LightSensor
|
|
67
|
+
// - for Shelly
|
|
68
|
+
const lightsensor = this.accessory.getService(this.platform.Service.LightSensor)
|
|
69
|
+
|| this.accessory.addService(this.platform.Service.LightSensor);
|
|
70
|
+
// register handlers for the Brightness Characteristic
|
|
71
|
+
lightsensor.getCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel)
|
|
72
|
+
.onGet(this.getDaylight.bind(this));
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
case 'sensor': {
|
|
76
|
+
// https://developers.homebridge.io/#/service/Battery
|
|
77
|
+
switch (device.reference) {
|
|
78
|
+
case 'evcc_vehicle':
|
|
79
|
+
case 'evcc_house_akku': {
|
|
80
|
+
const batterySensor = this.accessory.getService(this.platform.Service.Battery)
|
|
81
|
+
|| this.accessory.addService(this.platform.Service.Battery);
|
|
82
|
+
// create handlers for required characteristics
|
|
83
|
+
batterySensor.getCharacteristic(this.platform.Characteristic.BatteryLevel)
|
|
84
|
+
.onGet(this.getBatteryLevel.bind(this));
|
|
85
|
+
batterySensor.getCharacteristic(this.platform.Characteristic.ChargingState)
|
|
86
|
+
.onGet(this.getChargingState.bind(this));
|
|
87
|
+
batterySensor.getCharacteristic(this.platform.Characteristic.StatusLowBattery)
|
|
88
|
+
.onGet(this.getLowBatteryStatus.bind(this));
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// https://developers.homebridge.io/#/service/CarbonDioxideSensor
|
|
93
|
+
// - for Shelly
|
|
94
|
+
// https://developers.homebridge.io/#/service/CarbonMonoxideSensor
|
|
95
|
+
// - for Shelly
|
|
96
|
+
// https://developers.homebridge.io/#/service/HeaterCooler
|
|
97
|
+
// - for Bosch
|
|
98
|
+
// https://developers.homebridge.io/#/service/HumiditySensor
|
|
99
|
+
// - for Shelly
|
|
100
|
+
if (device.capability.humidity) {
|
|
101
|
+
const humiditySensor = this.accessory.getService(this.platform.Service.HumiditySensor)
|
|
102
|
+
|| this.accessory.addService(this.platform.Service.HumiditySensor);
|
|
103
|
+
humiditySensor.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
|
|
104
|
+
.onGet(this.getCurrentHumidity.bind(this));
|
|
105
|
+
}
|
|
106
|
+
// https://developers.homebridge.io/#/service/PowerManagement
|
|
107
|
+
// - for Fritzbox, Shelly, Sungrow, EVCC ???
|
|
108
|
+
// https://developers.homebridge.io/#/service/SmokeSensor
|
|
109
|
+
// - for Shelly
|
|
110
|
+
// https://developers.homebridge.io/#/service/TemperatureSensor
|
|
111
|
+
// - for Shelly, Fritzbox
|
|
112
|
+
if (device.capability.temperature) {
|
|
113
|
+
const temperatureSensor = this.accessory.getService(this.platform.Service.TemperatureSensor)
|
|
114
|
+
|| this.accessory.addService(this.platform.Service.TemperatureSensor);
|
|
115
|
+
temperatureSensor.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
|
|
116
|
+
.onGet(this.getCurrentTemperature.bind(this));
|
|
117
|
+
}
|
|
118
|
+
// https://developers.homebridge.io/#/service/WiFiRouter
|
|
119
|
+
// - for Fritzbox
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
default: {
|
|
123
|
+
// https://developers.homebridge.io/#/service/Switch
|
|
124
|
+
// - for Shelly, Fritzbox, Hue
|
|
125
|
+
const mySwitch = this.accessory.getService(this.platform.Service.Switch)
|
|
126
|
+
|| this.accessory.addService(this.platform.Service.Switch);
|
|
127
|
+
// register handlers for the Brightness Characteristic
|
|
128
|
+
mySwitch.getCharacteristic(this.platform.Characteristic.On)
|
|
129
|
+
.onSet(this.setOn.bind(this)) // SET - bind to the `setOn` method below
|
|
130
|
+
.onGet(this.getOn.bind(this));
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Creating multiple services of the same type.
|
|
136
|
+
*
|
|
137
|
+
* To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
138
|
+
* when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
139
|
+
* this.accessory.getService('NAME') || this.accessory.addService(this.platform.Service.Lightbulb, 'NAME', 'USER_DEFINED_SUBTYPE_ID');
|
|
140
|
+
*
|
|
141
|
+
* The USER_DEFINED_SUBTYPE must be unique to the platform accessory (if you platform exposes multiple accessories, each accessory
|
|
142
|
+
* can use the same subtype id.)
|
|
143
|
+
*/
|
|
144
|
+
// Example: add two "motion sensor" services to the accessory
|
|
145
|
+
// const motionSensorOneService = this.accessory.getService('Motion Sensor One Name')
|
|
146
|
+
// || this.accessory.addService(this.platform.Service.MotionSensor, 'Motion Sensor One Name', 'YourUniqueIdentifier-1');
|
|
147
|
+
// const motionSensorTwoService = this.accessory.getService('Motion Sensor Two Name')
|
|
148
|
+
// || this.accessory.addService(this.platform.Service.MotionSensor, 'Motion Sensor Two Name', 'YourUniqueIdentifier-2');
|
|
149
|
+
/**
|
|
150
|
+
* Updating characteristics values asynchronously.
|
|
151
|
+
*
|
|
152
|
+
* Example showing how to update the state of a Characteristic asynchronously instead
|
|
153
|
+
* of using the `on('get')` handlers.
|
|
154
|
+
* Here we change update the motion sensor trigger states on and off every 10 seconds
|
|
155
|
+
* the `updateCharacteristic` method.
|
|
156
|
+
*
|
|
157
|
+
*/
|
|
158
|
+
// let motionDetected = false;
|
|
159
|
+
// setInterval(() => {
|
|
160
|
+
// EXAMPLE - inverse the trigger
|
|
161
|
+
// motionDetected = !motionDetected;
|
|
162
|
+
// push the new value to HomeKit
|
|
163
|
+
// motionSensorOneService.updateCharacteristic(this.platform.Characteristic.MotionDetected, motionDetected);
|
|
164
|
+
// motionSensorTwoService.updateCharacteristic(this.platform.Characteristic.MotionDetected, !motionDetected);
|
|
165
|
+
// this.platform.log.debug('Triggering motionSensorOneService:', motionDetected);
|
|
166
|
+
// this.platform.log.debug('Triggering motionSensorTwoService:', !motionDetected);
|
|
167
|
+
// }, 10000);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Handle "SET" requests from HomeKit
|
|
171
|
+
* These are sent when the user changes the state of an accessory, for example, turning on a Light bulb.
|
|
172
|
+
*/
|
|
173
|
+
async setOn(value) {
|
|
174
|
+
// if you need to return an error to show the device as "Not Responding" in the Home app:
|
|
175
|
+
if (!this.device.state.reachable) {
|
|
176
|
+
throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
177
|
+
}
|
|
178
|
+
this.platform.log.debug('[' + this.device.name + '] Set Characteristic On ->', value);
|
|
179
|
+
const newDevice = this.solApi.setState(this.device, value);
|
|
180
|
+
Promise.all([newDevice]).then(() => this.device.state.on = value);
|
|
181
|
+
}
|
|
182
|
+
async getOn() {
|
|
183
|
+
if (!this.device.state.reachable) {
|
|
184
|
+
throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
185
|
+
}
|
|
186
|
+
return this.device.state.on;
|
|
187
|
+
}
|
|
188
|
+
async setBrightness(value) {
|
|
189
|
+
this.platform.log.debug('[' + this.device.name + '] Set Characteristic Brightness ->', value);
|
|
190
|
+
const newDevice = this.solApi.setBrightness(this.device, value);
|
|
191
|
+
Promise.all([newDevice]).then(() => this.device.state.brightness = value);
|
|
192
|
+
}
|
|
193
|
+
async getBrightness() {
|
|
194
|
+
return this.device.state.brightness;
|
|
195
|
+
}
|
|
196
|
+
async setSaturation(value) {
|
|
197
|
+
this.platform.log.debug('[' + this.device.name + '] Set Characteristic Saturation ->', value);
|
|
198
|
+
const newDevice = this.solApi.setColor(this.device, this.device.state.hsb.saturation2hex(value));
|
|
199
|
+
Promise.all([newDevice]).then(() => this.device.state.hsb.saturation = value);
|
|
200
|
+
}
|
|
201
|
+
async getSaturation() {
|
|
202
|
+
return this.device.state.hsb.saturation;
|
|
203
|
+
}
|
|
204
|
+
async setHue(value) {
|
|
205
|
+
this.platform.log.debug('[' + this.device.name + '] Set Characteristic Hue ->', value);
|
|
206
|
+
const newDevice = this.solApi.setColor(this.device, this.device.state.hsb.hue2hex(value));
|
|
207
|
+
Promise.all([newDevice]).then(() => this.device.state.hsb.hue = value);
|
|
208
|
+
}
|
|
209
|
+
async getHue() {
|
|
210
|
+
return this.device.state.hsb.hue;
|
|
211
|
+
}
|
|
212
|
+
async getDaylight() {
|
|
213
|
+
return this.device.state.on ? 100000 : 0.0001;
|
|
214
|
+
}
|
|
215
|
+
async getCurrentTemperature() {
|
|
216
|
+
return this.device.state.temperature;
|
|
217
|
+
}
|
|
218
|
+
async getCurrentHumidity() {
|
|
219
|
+
return this.device.state.humidity;
|
|
220
|
+
}
|
|
221
|
+
async getBatteryLevel() {
|
|
222
|
+
return this.device.state.power;
|
|
223
|
+
}
|
|
224
|
+
async getChargingState() {
|
|
225
|
+
return this.platform.Characteristic.ChargingState.NOT_CHARGING;
|
|
226
|
+
}
|
|
227
|
+
async getLowBatteryStatus() {
|
|
228
|
+
if (this.device.state.power < 1) {
|
|
229
|
+
return this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
|
|
230
|
+
}
|
|
231
|
+
return this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
|
|
232
|
+
}
|
|
233
|
+
getModel() {
|
|
234
|
+
switch (this.device.bridge) {
|
|
235
|
+
case 'hue': {
|
|
236
|
+
return this.device.extra.type;
|
|
237
|
+
}
|
|
238
|
+
case 'shelly': {
|
|
239
|
+
return this.device.bridge + '-' + this.device.extra.type + '-' + this.device.extra.version + ' ' + this.device.extra.ip;
|
|
240
|
+
}
|
|
241
|
+
case 'fritzbox': {
|
|
242
|
+
return this.device.bridge + '-' + this.device.extra.type;
|
|
243
|
+
}
|
|
244
|
+
default: {
|
|
245
|
+
return this.device.name;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=platformAccessory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platformAccessory.js","sourceRoot":"","sources":["../src/platformAccessory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IAEZ;IACA;IACA;IACA;IAJnB,YACmB,QAA+B,EAC/B,SAA4B,EAC5B,MAAiB,EACjB,MAAc;QAHd,aAAQ,GAAR,QAAQ,CAAuB;QAC/B,cAAS,GAAT,SAAS,CAAmB;QAC5B,WAAM,GAAN,MAAM,CAAW;QACjB,WAAM,GAAN,MAAM,CAAQ;QAE/B,4BAA4B;QAC5B,sEAAsE;QACtE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,oBAAoB,CAAE;aACnE,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,EAAE,aAAa,GAAG,IAAI,GAAC,MAAM,CAAC,MAAM,GAAC,GA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AK,CAAC,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1H,CAAC;YACD,KAAK,UAAU,CAAC,CAAC,CAAC;gBAChB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;YAC3D,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YAC1B,CAAC;QACD,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is the name of the platform that users will use to register the plugin in the Homebridge config.json
|
|
3
|
+
*/
|
|
4
|
+
export declare const PLATFORM_NAME = "SOLHomebridgePlugin";
|
|
5
|
+
/**
|
|
6
|
+
* This must match the name of your plugin as defined the package.json
|
|
7
|
+
*/
|
|
8
|
+
export declare const PLUGIN_NAME = "homebridge-plugin-sol";
|
|
9
|
+
export declare const PLUGIN_AUTHOR = "Thoralf Rickert-Wendt";
|
package/dist/settings.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is the name of the platform that users will use to register the plugin in the Homebridge config.json
|
|
3
|
+
*/
|
|
4
|
+
export const PLATFORM_NAME = 'SOLHomebridgePlugin';
|
|
5
|
+
/**
|
|
6
|
+
* This must match the name of your plugin as defined the package.json
|
|
7
|
+
*/
|
|
8
|
+
export const PLUGIN_NAME = 'homebridge-plugin-sol';
|
|
9
|
+
export const PLUGIN_AUTHOR = 'Thoralf Rickert-Wendt';
|
|
10
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,qBAAqB,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAGnD,MAAM,CAAC,MAAM,aAAa,GAAG,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Logging } from 'homebridge';
|
|
2
|
+
export declare class SolApi {
|
|
3
|
+
private readonly log;
|
|
4
|
+
private readonly endpoint;
|
|
5
|
+
constructor(log: Logging, endpoint: string);
|
|
6
|
+
/**
|
|
7
|
+
* returns list of all SOL devices
|
|
8
|
+
*/
|
|
9
|
+
getDevices(): Promise<SolDevice[]>;
|
|
10
|
+
setState(device: SolDevice, state: boolean): Promise<SolDevice | undefined>;
|
|
11
|
+
setBrightness(device: SolDevice, value: number): Promise<SolDevice | undefined>;
|
|
12
|
+
setColor(device: SolDevice, value: string): Promise<SolDevice | undefined>;
|
|
13
|
+
}
|
|
14
|
+
export declare class SolDevice {
|
|
15
|
+
id: string;
|
|
16
|
+
reference: string;
|
|
17
|
+
name: string;
|
|
18
|
+
room: string;
|
|
19
|
+
type: string;
|
|
20
|
+
singleton: boolean;
|
|
21
|
+
bridge: string;
|
|
22
|
+
capability: SolCapability;
|
|
23
|
+
state: SolState;
|
|
24
|
+
extra: any;
|
|
25
|
+
elements: SolDeviceElement[];
|
|
26
|
+
version: string;
|
|
27
|
+
constructor(device: any, version: string);
|
|
28
|
+
}
|
|
29
|
+
export declare class SolDeviceElement {
|
|
30
|
+
id: string;
|
|
31
|
+
reference: string;
|
|
32
|
+
name: string;
|
|
33
|
+
checked: string;
|
|
34
|
+
capability: SolCapability;
|
|
35
|
+
state: SolState;
|
|
36
|
+
extra: any;
|
|
37
|
+
constructor(element: any);
|
|
38
|
+
}
|
|
39
|
+
export declare class SolCapability {
|
|
40
|
+
brightness: boolean;
|
|
41
|
+
color: boolean;
|
|
42
|
+
switch: boolean;
|
|
43
|
+
power: boolean;
|
|
44
|
+
temperature: boolean;
|
|
45
|
+
humidity: boolean;
|
|
46
|
+
constructor(capability: any);
|
|
47
|
+
}
|
|
48
|
+
export declare class SolState {
|
|
49
|
+
reachable: boolean;
|
|
50
|
+
on: boolean;
|
|
51
|
+
brightness: number;
|
|
52
|
+
rgb: string;
|
|
53
|
+
hsb: SolHSB;
|
|
54
|
+
power: number;
|
|
55
|
+
temperature: number;
|
|
56
|
+
humidity: number;
|
|
57
|
+
constructor(state: any);
|
|
58
|
+
}
|
|
59
|
+
export declare class SolHSB {
|
|
60
|
+
hue: number;
|
|
61
|
+
saturation: number;
|
|
62
|
+
brightness: number;
|
|
63
|
+
constructor(color: any);
|
|
64
|
+
saturation2hex(saturation: number): string;
|
|
65
|
+
hue2hex(hue: number): string;
|
|
66
|
+
private hex2rgb;
|
|
67
|
+
private rgb2hex;
|
|
68
|
+
private rgb2hsb;
|
|
69
|
+
private hsb2rgb;
|
|
70
|
+
}
|
package/dist/sol-api.js
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
export class SolApi {
|
|
4
|
+
log;
|
|
5
|
+
endpoint;
|
|
6
|
+
constructor(log, endpoint) {
|
|
7
|
+
this.log = log;
|
|
8
|
+
this.endpoint = endpoint;
|
|
9
|
+
// nothing to do
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* returns list of all SOL devices
|
|
13
|
+
*/
|
|
14
|
+
async getDevices() {
|
|
15
|
+
const devices = [];
|
|
16
|
+
const url = `${this.endpoint}/api/homebridge/devices`;
|
|
17
|
+
try {
|
|
18
|
+
const response = await axios.get(url);
|
|
19
|
+
const data = response.data;
|
|
20
|
+
if (typeof data === 'string') {
|
|
21
|
+
this.log.info(`ERROR received error from ${url}: ${data}`);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
if ('devices' in data) {
|
|
25
|
+
data.devices.forEach((device) => {
|
|
26
|
+
this.log.info(`Received Status for SOL Device ${device.name}`);
|
|
27
|
+
devices.push(new SolDevice(device, data.status.version));
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (exception) {
|
|
33
|
+
this.log.error(`ERROR received from ${url}: ${exception}\n`);
|
|
34
|
+
}
|
|
35
|
+
return devices;
|
|
36
|
+
}
|
|
37
|
+
async setState(device, state) {
|
|
38
|
+
const enable = state ? 'true' : 'false';
|
|
39
|
+
const url = `${this.endpoint}/api/switch/?reference=${device.reference}&enable=${enable}`;
|
|
40
|
+
try {
|
|
41
|
+
const response = await axios.get(url);
|
|
42
|
+
const data = response.data;
|
|
43
|
+
if ('smarthome' in data) {
|
|
44
|
+
return new SolDevice(data.smarthome, data.status.version);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch (exception) {
|
|
48
|
+
this.log.error(`ERROR received from ${url}: ${exception}\n`);
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
async setBrightness(device, value) {
|
|
53
|
+
const url = `${this.endpoint}/api/brightness/`;
|
|
54
|
+
const body = { reference: device.reference, value: value };
|
|
55
|
+
try {
|
|
56
|
+
const response = await axios.post(url, body);
|
|
57
|
+
const data = response.data;
|
|
58
|
+
if ('smarthome' in data) {
|
|
59
|
+
return new SolDevice(data.smarthome, data.status.version);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (exception) {
|
|
63
|
+
this.log.error(`ERROR received from ${url}: ${exception}\n`);
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
async setColor(device, value) {
|
|
68
|
+
const url = `${this.endpoint}/api/color/`;
|
|
69
|
+
const body = { reference: device.reference, value: value };
|
|
70
|
+
try {
|
|
71
|
+
const response = await axios.post(url, body);
|
|
72
|
+
const data = response.data;
|
|
73
|
+
if ('smarthome' in data) {
|
|
74
|
+
return new SolDevice(data.smarthome, data.status.version);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (exception) {
|
|
78
|
+
this.log.error(`ERROR received from ${url}: ${exception}\n`);
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export class SolDevice {
|
|
84
|
+
id;
|
|
85
|
+
reference;
|
|
86
|
+
name;
|
|
87
|
+
room;
|
|
88
|
+
type;
|
|
89
|
+
singleton;
|
|
90
|
+
bridge;
|
|
91
|
+
capability;
|
|
92
|
+
state;
|
|
93
|
+
extra;
|
|
94
|
+
elements;
|
|
95
|
+
version;
|
|
96
|
+
constructor(device, version) {
|
|
97
|
+
this.version = version;
|
|
98
|
+
this.id = device.id;
|
|
99
|
+
this.reference = device.reference;
|
|
100
|
+
this.name = device.name;
|
|
101
|
+
this.room = device.room;
|
|
102
|
+
this.type = device.type;
|
|
103
|
+
this.singleton = device.singleton;
|
|
104
|
+
this.bridge = device.bridge;
|
|
105
|
+
this.capability = new SolCapability(device.capabilities);
|
|
106
|
+
this.state = new SolState(device.state);
|
|
107
|
+
this.extra = device.extra;
|
|
108
|
+
this.elements = [];
|
|
109
|
+
device.elements.forEach((element) => this.elements.push(new SolDeviceElement(element)));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export class SolDeviceElement {
|
|
113
|
+
id;
|
|
114
|
+
reference;
|
|
115
|
+
name;
|
|
116
|
+
checked;
|
|
117
|
+
capability;
|
|
118
|
+
state;
|
|
119
|
+
extra;
|
|
120
|
+
constructor(element) {
|
|
121
|
+
this.id = element.id;
|
|
122
|
+
this.reference = element.reference;
|
|
123
|
+
this.name = element.name;
|
|
124
|
+
this.checked = element.checked;
|
|
125
|
+
this.capability = new SolCapability(element.capabilities);
|
|
126
|
+
this.state = new SolState(element.state);
|
|
127
|
+
this.extra = element.extra;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export class SolCapability {
|
|
131
|
+
brightness;
|
|
132
|
+
color;
|
|
133
|
+
switch;
|
|
134
|
+
power;
|
|
135
|
+
temperature;
|
|
136
|
+
humidity;
|
|
137
|
+
constructor(capability) {
|
|
138
|
+
this.brightness = 'brightness' in capability ? capability.brightness : false;
|
|
139
|
+
this.color = 'color' in capability ? capability.color : false;
|
|
140
|
+
this.switch = 'switch' in capability ? capability.switch : false;
|
|
141
|
+
this.power = 'power' in capability ? capability.power : false;
|
|
142
|
+
this.temperature = 'temperature' in capability ? capability.temperature : false;
|
|
143
|
+
this.humidity = 'humidity' in capability ? capability.humidity : false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
export class SolState {
|
|
147
|
+
reachable;
|
|
148
|
+
on;
|
|
149
|
+
brightness;
|
|
150
|
+
rgb;
|
|
151
|
+
hsb;
|
|
152
|
+
power;
|
|
153
|
+
temperature;
|
|
154
|
+
humidity;
|
|
155
|
+
constructor(state) {
|
|
156
|
+
this.reachable = 'reachable' in state ? state.reachable : false;
|
|
157
|
+
this.on = 'on' in state ? state.on : false;
|
|
158
|
+
this.brightness = 'brightness' in state ? state.brightness : 0;
|
|
159
|
+
this.rgb = 'rgb' in state ? state.rgb : '#000000';
|
|
160
|
+
this.hsb = new SolHSB(state.hsb);
|
|
161
|
+
this.power = 'power' in state ? state.power : 0;
|
|
162
|
+
this.temperature = 'temperature' in state ? state.temperature : 0;
|
|
163
|
+
this.humidity = 'humidity' in state ? state.humidity : 0;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
export class SolHSB {
|
|
167
|
+
hue = 0;
|
|
168
|
+
saturation = 0;
|
|
169
|
+
brightness = 0;
|
|
170
|
+
constructor(color) {
|
|
171
|
+
if (color != null) {
|
|
172
|
+
this.hue = color.hue;
|
|
173
|
+
this.saturation = color.saturation;
|
|
174
|
+
this.brightness = color.brightness;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
saturation2hex(saturation) {
|
|
178
|
+
return this.rgb2hex(this.hsb2rgb({ h: this.hue, s: saturation, b: this.brightness }));
|
|
179
|
+
}
|
|
180
|
+
hue2hex(hue) {
|
|
181
|
+
return this.rgb2hex(this.hsb2rgb({ h: hue, s: this.saturation, b: this.brightness }));
|
|
182
|
+
}
|
|
183
|
+
hex2rgb(hex) {
|
|
184
|
+
let ha = hex.slice(hex.startsWith('#') ? 1 : 0);
|
|
185
|
+
if (ha.length === 3) {
|
|
186
|
+
ha = [...ha].map(x => x + x).join('');
|
|
187
|
+
}
|
|
188
|
+
const h = parseInt(ha, 16);
|
|
189
|
+
return {
|
|
190
|
+
r: (h >>> (16)),
|
|
191
|
+
g: ((h & (0x00ff00)) >>> (8)),
|
|
192
|
+
b: ((h & (0x0000ff)) >>> (0)),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
rgb2hex(color) {
|
|
196
|
+
return ((color.r << 16) + (color.g << 8) + color.b).toString(16).padStart(6, '0');
|
|
197
|
+
}
|
|
198
|
+
rgb2hsb(color) {
|
|
199
|
+
color.r /= 255;
|
|
200
|
+
color.g /= 255;
|
|
201
|
+
color.b /= 255;
|
|
202
|
+
const v = Math.max(color.r, color.g, color.b), n = v - Math.min(color.r, color.g, color.b);
|
|
203
|
+
const h = n === 0 ? 0 : n && v === color.r ? (color.g - color.b) / n : v === color.g ? 2 + (color.b - color.r) / n : 4 + (color.r - color.g) / n;
|
|
204
|
+
return {
|
|
205
|
+
h: 60 * (h < 0 ? h + 6 : h),
|
|
206
|
+
s: v && (n / v) * 100,
|
|
207
|
+
b: v * 100,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
hsb2rgb(color) {
|
|
211
|
+
color.s /= 100;
|
|
212
|
+
color.b /= 100;
|
|
213
|
+
const k = (n) => (n + color.h / 60) % 6;
|
|
214
|
+
const f = (n) => color.b * (1 - color.s * Math.max(0, Math.min(k(n), 4 - k(n), 1)));
|
|
215
|
+
return {
|
|
216
|
+
r: 255 * f(5),
|
|
217
|
+
g: 255 * f(3),
|
|
218
|
+
b: 255 * f(1),
|
|
219
|
+
};
|
|
220
|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C,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3B,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG;YACrB,CAAC,EAAE,CAAC,GAAG,GAAG;SACX,CAAC;IACJ,CAAC;IAEO,OAAO,CAAC,KAA0C;QACxD,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC;QACf,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC;QACf,MAAM,CAAC,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5F,OAAO;YACL,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YACb,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YACb,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;SACd,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "homebridge-plugin-sol",
|
|
3
|
+
"displayName": "SOL",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"version": "2.0.0",
|
|
6
|
+
"private": false,
|
|
7
|
+
"description": "This is a homebridge plugin to manage smarthome devices controlled via SOL.",
|
|
8
|
+
"author": "Thoralf Rickert-Wendt",
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"homepage": "https://github.com/trickert76/homebridge-plugin-sol#readme",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/trickert76/homebridge-plugin-sol.git"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/trickert76/homebridge-plugin-sol/issues"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"homebridge-plugin"
|
|
20
|
+
],
|
|
21
|
+
"main": "dist/index.js",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": "^18.20.4 || ^20.16.0 || ^22.6.0",
|
|
24
|
+
"homebridge": "^1.8.0 || ^2.0.0-beta.0"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "rimraf ./dist && tsc",
|
|
28
|
+
"lint": "eslint . --max-warnings=0",
|
|
29
|
+
"prepublishOnly": "npm run lint && npm run build",
|
|
30
|
+
"watch": "npm run build && npm link && nodemon"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@eslint/js": "^9.9.0",
|
|
34
|
+
"@types/eslint__js": "^8.42.3",
|
|
35
|
+
"@types/node": "^22.2.0",
|
|
36
|
+
"eslint": "^9.9.0",
|
|
37
|
+
"homebridge": "^2.0.0-beta.0",
|
|
38
|
+
"nodemon": "^3.1.4",
|
|
39
|
+
"rimraf": "^6.0.1",
|
|
40
|
+
"ts-node": "^10.9.2",
|
|
41
|
+
"typescript": "^5.5.4",
|
|
42
|
+
"typescript-eslint": "^8.0.1"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"axios": "^1.7.7"
|
|
46
|
+
}
|
|
47
|
+
}
|