homebridge-blueair-purifier 0.1.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.
Files changed (44) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +191 -0
  3. package/config.schema.json +121 -0
  4. package/dist/accessory/AirPurifierAccessory.d.ts +26 -0
  5. package/dist/accessory/AirPurifierAccessory.d.ts.map +1 -0
  6. package/dist/accessory/AirPurifierAccessory.js +92 -0
  7. package/dist/accessory/AirPurifierAccessory.js.map +1 -0
  8. package/dist/api/BlueAirAwsApi.d.ts +69 -0
  9. package/dist/api/BlueAirAwsApi.d.ts.map +1 -0
  10. package/dist/api/BlueAirAwsApi.js +148 -0
  11. package/dist/api/BlueAirAwsApi.js.map +1 -0
  12. package/dist/api/Consts.d.ts +40 -0
  13. package/dist/api/Consts.d.ts.map +1 -0
  14. package/dist/api/Consts.js +50 -0
  15. package/dist/api/Consts.js.map +1 -0
  16. package/dist/api/GigyaApi.d.ts +18 -0
  17. package/dist/api/GigyaApi.d.ts.map +1 -0
  18. package/dist/api/GigyaApi.js +78 -0
  19. package/dist/api/GigyaApi.js.map +1 -0
  20. package/dist/device/BlueAirDevice.d.ts +12 -0
  21. package/dist/device/BlueAirDevice.d.ts.map +1 -0
  22. package/dist/device/BlueAirDevice.js +31 -0
  23. package/dist/device/BlueAirDevice.js.map +1 -0
  24. package/dist/index.d.ts +7 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +7 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/platform.d.ts +19 -0
  29. package/dist/platform.d.ts.map +1 -0
  30. package/dist/platform.js +87 -0
  31. package/dist/platform.js.map +1 -0
  32. package/dist/platformUtils.d.ts +37 -0
  33. package/dist/platformUtils.d.ts.map +1 -0
  34. package/dist/platformUtils.js +39 -0
  35. package/dist/platformUtils.js.map +1 -0
  36. package/dist/settings.d.ts +9 -0
  37. package/dist/settings.d.ts.map +1 -0
  38. package/dist/settings.js +12 -0
  39. package/dist/settings.js.map +1 -0
  40. package/homebridge-ui/public/css/bootstrap.min.css +6 -0
  41. package/homebridge-ui/public/index.html +263 -0
  42. package/homebridge-ui/public/js/bootstrap.min.js +7 -0
  43. package/homebridge-ui/server.js +120 -0
  44. package/package.json +45 -0
package/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,191 @@
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 Template
10
+
11
+ </span>
12
+
13
+ This is a template Homebridge dynamic platform plugin and can be used as a base to help you get started developing your own plugin.
14
+
15
+ This template should be used in conjunction with the [developer documentation](https://developers.homebridge.io/). A full list of all supported service types, and their characteristics is available on this site.
16
+
17
+ ### Clone As Template
18
+
19
+ Click the link below to create a new GitHub Repository using this template, or click the *Use This Template* button above.
20
+
21
+ <span align="center">
22
+
23
+ ### [Create New Repository From Template](https://github.com/homebridge/homebridge-plugin-template/generate)
24
+
25
+ </span>
26
+
27
+ ### Setup Development Environment
28
+
29
+ To develop Homebridge plugins you must have Node.js 18 or later installed, and a modern code editor such as [VS Code](https://code.visualstudio.com/). This plugin template uses [TypeScript](https://www.typescriptlang.org/) to make development easier and comes with pre-configured settings for [VS Code](https://code.visualstudio.com/) and ESLint. If you are using VS Code install these extensions:
30
+
31
+ - [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
32
+
33
+ ### Install Development Dependencies
34
+
35
+ Using a terminal, navigate to the project folder and run this command to install the development dependencies:
36
+
37
+ ```shell
38
+ npm install
39
+ ```
40
+
41
+ ### Update package.json
42
+
43
+ Open the [`package.json`](./package.json) and change the following attributes:
44
+
45
+ - `name` - this should be prefixed with `homebridge-` or `@username/homebridge-`, is case-sensitive, and contains no spaces nor special characters apart from a dash `-`
46
+ - `displayName` - this is the "nice" name displayed in the Homebridge UI
47
+ - `repository.url` - Link to your GitHub repo
48
+ - `bugs.url` - Link to your GitHub repo issues page
49
+
50
+ When you are ready to publish the plugin you should set `private` to false, or remove the attribute entirely.
51
+
52
+ ### Update Plugin Defaults
53
+
54
+ Open the [`src/settings.ts`](./src/settings.ts) file and change the default values:
55
+
56
+ - `PLATFORM_NAME` - Set this to be the name of your platform. This is the name of the platform that users will use to register the plugin in the Homebridge `config.json`.
57
+ - `PLUGIN_NAME` - Set this to be the same name you set in the [`package.json`](./package.json) file.
58
+
59
+ Open the [`config.schema.json`](./config.schema.json) file and change the following attribute:
60
+
61
+ - `pluginAlias` - set this to match the `PLATFORM_NAME` you defined in the previous step.
62
+
63
+ ### Build Plugin
64
+
65
+ 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.
66
+
67
+ ```shell
68
+ npm run build
69
+ ```
70
+
71
+ ### Link To Homebridge
72
+
73
+ Run this command so your global installation of Homebridge can discover the plugin in your development environment:
74
+
75
+ ```shell
76
+ npm link
77
+ ```
78
+
79
+ You can now start Homebridge, use the `-D` flag, so you can see debug log messages in your plugin:
80
+
81
+ ```shell
82
+ homebridge -D
83
+ ```
84
+
85
+ ### Watch For Changes and Build Automatically
86
+
87
+ 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`:
88
+ ```
89
+ {
90
+ ...
91
+ "platforms": [
92
+ {
93
+ "name": "Config",
94
+ "port": 8581,
95
+ "platform": "config"
96
+ },
97
+ {
98
+ "name": "<PLUGIN_NAME>",
99
+ //... any other options, as listed in config.schema.json ...
100
+ "platform": "<PLATFORM_NAME>"
101
+ }
102
+ ]
103
+ }
104
+ ```
105
+
106
+ and then you can run:
107
+
108
+ ```shell
109
+ npm run watch
110
+ ```
111
+
112
+ 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.
113
+
114
+ ### Customise Plugin
115
+
116
+ You can now start customising the plugin template to suit your requirements.
117
+
118
+ - [`src/platform.ts`](./src/platform.ts) - this is where your device setup and discovery should go.
119
+ - [`src/platformAccessory.ts`](./src/platformAccessory.ts) - this is where your accessory control logic should go, you can rename or create multiple instances of this file for each accessory type you need to implement as part of your platform plugin. You can refer to the [developer documentation](https://developers.homebridge.io/) to see what characteristics you need to implement for each service type.
120
+ - [`config.schema.json`](./config.schema.json) - update the config schema to match the config you expect from the user. See the [Plugin Config Schema Documentation](https://developers.homebridge.io/#/config-schema).
121
+
122
+ ### Versioning Your Plugin
123
+
124
+ Given a version number `MAJOR`.`MINOR`.`PATCH`, such as `1.4.3`, increment the:
125
+
126
+ 1. **MAJOR** version when you make breaking changes to your plugin,
127
+ 2. **MINOR** version when you add functionality in a backwards compatible manner, and
128
+ 3. **PATCH** version when you make backwards compatible bug fixes.
129
+
130
+ You can use the `npm version` command to help you with this:
131
+
132
+ ```shell
133
+ # major update / breaking changes
134
+ npm version major
135
+
136
+ # minor update / new features
137
+ npm version update
138
+
139
+ # patch / bugfixes
140
+ npm version patch
141
+ ```
142
+
143
+ ### Publish Package
144
+
145
+ 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:
146
+
147
+ ```shell
148
+ npm publish
149
+ ```
150
+
151
+ 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.
152
+
153
+ #### Publishing Beta Versions
154
+
155
+ You can publish *beta* versions of your plugin for other users to test before you release it to everyone.
156
+
157
+ ```shell
158
+ # create a new pre-release version (eg. 2.1.0-beta.1)
159
+ npm version prepatch --preid beta
160
+
161
+ # publish to @beta
162
+ npm publish --tag=beta
163
+ ```
164
+
165
+ Users can then install the *beta* version by appending `@beta` to the install command, for example:
166
+
167
+ ```shell
168
+ sudo npm install -g homebridge-example-plugin@beta
169
+ ```
170
+
171
+ ### Best Practices
172
+ 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.
173
+ You can then submit your plugin to the Homebridge Verified list for review.
174
+ The most up-to-date criteria can be found [here](https://github.com/homebridge/verified#requirements).
175
+ For reference, the current criteria are:
176
+
177
+ - The plugin must successfully install.
178
+ - The plugin must implement the [Homebridge Plugin Settings GUI](https://github.com/oznu/homebridge-config-ui-x/wiki/Developers:-Plugin-Settings-GUI).
179
+ - The plugin must not start unless it is configured.
180
+ - The plugin must not execute post-install scripts that modify the users' system in any way.
181
+ - The plugin must not contain any analytics or calls that enable you to track the user.
182
+ - The plugin must not throw unhandled exceptions, the plugin must catch and log its own errors.
183
+ - The plugin must be published to npm and the source code available on GitHub.
184
+ - A GitHub release - with patch notes - should be created for every new version of your plugin.
185
+ - 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.
186
+ - The plugin must not require the user to run Homebridge in a TTY or with non-standard startup parameters, even for initial configuration.
187
+ - If the plugin needs to write files to disk (cache, keys, etc.), it must store them inside the Homebridge storage directory.
188
+
189
+ ### Useful Links
190
+ Note these links are here for help but are not supported/verified by the Homebridge team
191
+ - [Custom Characteristics](https://github.com/homebridge/homebridge-plugin-template/issues/20)
@@ -0,0 +1,121 @@
1
+ {
2
+ "pluginAlias": "blueair-purifier",
3
+ "pluginType": "platform",
4
+ "singular": true,
5
+ "schema": {
6
+ "type": "object",
7
+ "properties": {
8
+ "username": {
9
+ "title": "Username",
10
+ "description": "Username for BlueAir account",
11
+ "type": "string",
12
+ "required": true
13
+ },
14
+ "password": {
15
+ "title": "Password",
16
+ "description": "Password for BlueAir account",
17
+ "type": "string",
18
+ "required": true
19
+ },
20
+ "verboseLogging": {
21
+ "title": "Verbose Logging",
22
+ "description": "Enable to receive detailed log messages. Useful for troubleshooting.",
23
+ "type": "boolean"
24
+ },
25
+ "devices": {
26
+ "title": "Devices",
27
+ "type": "array",
28
+ "items": {
29
+ "type": "object",
30
+ "properties": {
31
+ "name": {
32
+ "title": "Name",
33
+ "type": "string",
34
+ "required": true
35
+ },
36
+ "id": {
37
+ "title": "ID",
38
+ "type": "string",
39
+ "required": true
40
+ },
41
+ "isAWSDevice": {
42
+ "title": "AWS Device",
43
+ "description": "Enable AWS integration. This is required for devices like DustMagnet, HealthProtect, and Blue Pure.",
44
+ "type": "boolean"
45
+ },
46
+ "led": {
47
+ "title": "LED",
48
+ "description": "Toggles if the LED switch service is created with the accessory.",
49
+ "type": "boolean"
50
+ },
51
+ "airQualitySensor": {
52
+ "title": "Air Quality Sensor",
53
+ "description": "Toggles if the air quality sensor service is created with the accessory.",
54
+ "type": "boolean"
55
+ },
56
+ "co2Sensor": {
57
+ "title": "CO2 Sensor",
58
+ "description": "Toggles if the CO2 sensor service is created with the accessory.",
59
+ "type": "boolean"
60
+ },
61
+ "temperatureSensor": {
62
+ "title": "Temperature Sensor",
63
+ "description": "Toggles if the temperature sensor service is created with the accessory.",
64
+ "type": "boolean"
65
+ },
66
+ "humiditySensor": {
67
+ "title": "Humidity Sensor",
68
+ "description": "Toggles if the humidity sensor service is created with the accessory.",
69
+ "type": "boolean"
70
+ },
71
+ "germShield": {
72
+ "title": "Germ Shield",
73
+ "description": "Toggles if the germ shield switch service is created with the accessory.",
74
+ "type": "boolean"
75
+ },
76
+ "nightMode": {
77
+ "title": "Night Mode",
78
+ "description": "Toggles if the night mode switch service is created with the accessory.",
79
+ "type": "boolean"
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }
85
+ },
86
+ "layout": [
87
+ {
88
+ "items": [
89
+ {
90
+ "ref": "common",
91
+ "type": "fieldset",
92
+ "expandable": true,
93
+ "expanded": true,
94
+ "title": "Common Settings",
95
+ "items": [
96
+ "username",
97
+ "password",
98
+ "verboseLogging"
99
+ ]
100
+ },
101
+ {
102
+ "key": "devices",
103
+ "type": "tabarray",
104
+ "title": "{{ value.name || 'new device' }}",
105
+ "items": [
106
+ "devices[].name",
107
+ "devices[].id",
108
+ "devices[].enableAWS",
109
+ "devices[].led",
110
+ "devices[].airQualitySensor",
111
+ "devices[].co2Sensor",
112
+ "devices[].temperatureSensor",
113
+ "devices[].humiditySensor",
114
+ "devices[].germShield",
115
+ "devices[].nightMode"
116
+ ]
117
+ }
118
+ ]
119
+ }
120
+ ]
121
+ }
@@ -0,0 +1,26 @@
1
+ import { CharacteristicValue, PlatformAccessory } from 'homebridge';
2
+ import { BlueAirPlatform } from '../platform';
3
+ import { BlueAirDevice } from '../device/BlueAirDevice';
4
+ import { DeviceConfig } from '../platformUtils';
5
+ export declare class AirPurifierAccessory {
6
+ protected readonly platform: BlueAirPlatform;
7
+ protected readonly accessory: PlatformAccessory;
8
+ protected readonly device: BlueAirDevice;
9
+ protected readonly configDev: DeviceConfig;
10
+ private service;
11
+ constructor(platform: BlueAirPlatform, accessory: PlatformAccessory, device: BlueAirDevice, configDev: DeviceConfig);
12
+ getActive(): CharacteristicValue;
13
+ setActive(value: CharacteristicValue): void;
14
+ getCurrentAirPurifierState(): CharacteristicValue;
15
+ getTargetAirPurifierState(): CharacteristicValue;
16
+ setTargetAirPurifierState(value: CharacteristicValue): void;
17
+ getLockPhysicalControls(): CharacteristicValue;
18
+ setLockPhysicalControls(value: CharacteristicValue): void;
19
+ getRotationSpeed(): CharacteristicValue;
20
+ setRotationSpeed(value: CharacteristicValue): void;
21
+ getFilterChangeIndication(): CharacteristicValue;
22
+ getFilterLifeLevel(): CharacteristicValue;
23
+ getCurrentTemperature(): CharacteristicValue;
24
+ getCurrentRelativeHumidity(): CharacteristicValue;
25
+ }
26
+ //# sourceMappingURL=AirPurifierAccessory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AirPurifierAccessory.d.ts","sourceRoot":"","sources":["../../src/accessory/AirPurifierAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAW,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,qBAAa,oBAAoB;IAK7B,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,eAAe;IAC5C,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,iBAAiB;IAC/C,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa;IACxC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,YAAY;IAN5C,OAAO,CAAC,OAAO,CAAU;gBAGJ,QAAQ,EAAE,eAAe,EACzB,SAAS,EAAE,iBAAiB,EAC5B,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,YAAY;IA2C5C,SAAS,IAAI,mBAAmB;IAIhC,SAAS,CAAC,KAAK,EAAE,mBAAmB;IAIpC,0BAA0B,IAAI,mBAAmB;IAMjD,yBAAyB,IAAI,mBAAmB;IAMhD,yBAAyB,CAAC,KAAK,EAAE,mBAAmB;IAIpD,uBAAuB,IAAI,mBAAmB;IAM9C,uBAAuB,CAAC,KAAK,EAAE,mBAAmB;IAIlD,gBAAgB,IAAI,mBAAmB;IAIvC,gBAAgB,CAAC,KAAK,EAAE,mBAAmB;IAI3C,yBAAyB,IAAI,mBAAmB;IAWhD,kBAAkB,IAAI,mBAAmB;IAIzC,qBAAqB,IAAI,mBAAmB;IAI5C,0BAA0B,IAAI,mBAAmB;CAGlD"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AirPurifierAccessory = void 0;
4
+ class AirPurifierAccessory {
5
+ constructor(platform, accessory, device, configDev) {
6
+ this.platform = platform;
7
+ this.accessory = accessory;
8
+ this.device = device;
9
+ this.configDev = configDev;
10
+ this.accessory
11
+ .getService(this.platform.Service.AccessoryInformation)
12
+ .setCharacteristic(this.platform.Characteristic.Manufacturer, 'BlueAir')
13
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, this.configDev.id);
14
+ this.service = this.accessory.getService(this.platform.Service.AirPurifier) ||
15
+ this.accessory.addService(this.platform.Service.AirPurifier);
16
+ this.service.setCharacteristic(this.platform.Characteristic.Name, this.configDev.name);
17
+ this.service.getCharacteristic(this.platform.Characteristic.Active)
18
+ .on('set', this.setActive.bind(this))
19
+ .on('get', this.getActive.bind(this));
20
+ this.service.getCharacteristic(this.platform.Characteristic.CurrentAirPurifierState)
21
+ .on('get', this.getCurrentAirPurifierState.bind(this));
22
+ this.service.getCharacteristic(this.platform.Characteristic.TargetAirPurifierState)
23
+ .on('set', this.setTargetAirPurifierState.bind(this))
24
+ .on('get', this.getTargetAirPurifierState.bind(this));
25
+ this.service.getCharacteristic(this.platform.Characteristic.LockPhysicalControls)
26
+ .on('set', this.setLockPhysicalControls.bind(this))
27
+ .on('get', this.getLockPhysicalControls.bind(this));
28
+ this.service.getCharacteristic(this.platform.Characteristic.RotationSpeed)
29
+ .on('set', this.setRotationSpeed.bind(this))
30
+ .on('get', this.getRotationSpeed.bind(this));
31
+ this.service.getCharacteristic(this.platform.Characteristic.FilterChangeIndication)
32
+ .on('get', this.getFilterChangeIndication.bind(this));
33
+ this.service.getCharacteristic(this.platform.Characteristic.FilterLifeLevel)
34
+ .on('get', this.getFilterLifeLevel.bind(this));
35
+ this.service.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
36
+ .on('get', this.getCurrentTemperature.bind(this));
37
+ this.service.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
38
+ .on('get', this.getCurrentRelativeHumidity.bind(this));
39
+ }
40
+ getActive() {
41
+ return this.device.state.standby ? this.platform.Characteristic.Active.INACTIVE : this.platform.Characteristic.Active.ACTIVE;
42
+ }
43
+ setActive(value) {
44
+ this.device.setState('standby', value === this.platform.Characteristic.Active.ACTIVE);
45
+ }
46
+ getCurrentAirPurifierState() {
47
+ return this.device.state.standby ?
48
+ this.platform.Characteristic.CurrentAirPurifierState.PURIFYING_AIR :
49
+ this.platform.Characteristic.CurrentAirPurifierState.IDLE;
50
+ }
51
+ getTargetAirPurifierState() {
52
+ return this.device.state.automode ?
53
+ this.platform.Characteristic.TargetAirPurifierState.AUTO :
54
+ this.platform.Characteristic.TargetAirPurifierState.MANUAL;
55
+ }
56
+ setTargetAirPurifierState(value) {
57
+ this.device.setState('automode', value === this.platform.Characteristic.TargetAirPurifierState.AUTO);
58
+ }
59
+ getLockPhysicalControls() {
60
+ return this.device.state.childlock ?
61
+ this.platform.Characteristic.LockPhysicalControls.CONTROL_LOCK_ENABLED :
62
+ this.platform.Characteristic.LockPhysicalControls.CONTROL_LOCK_DISABLED;
63
+ }
64
+ setLockPhysicalControls(value) {
65
+ this.device.setState('childlock', value === this.platform.Characteristic.LockPhysicalControls.CONTROL_LOCK_ENABLED);
66
+ }
67
+ getRotationSpeed() {
68
+ return this.device.state.fanspeed || 0;
69
+ }
70
+ setRotationSpeed(value) {
71
+ this.device.setState('fanspeed', value);
72
+ }
73
+ getFilterChangeIndication() {
74
+ if (this.device.state.filterusage === undefined) {
75
+ return this.platform.Characteristic.FilterChangeIndication.FILTER_OK;
76
+ }
77
+ return this.device.state.filterusage < 95 ?
78
+ this.platform.Characteristic.FilterChangeIndication.FILTER_OK :
79
+ this.platform.Characteristic.FilterChangeIndication.CHANGE_FILTER;
80
+ }
81
+ getFilterLifeLevel() {
82
+ return this.device.state.filterusage || 0;
83
+ }
84
+ getCurrentTemperature() {
85
+ return this.device.sensorData.temperature || 0;
86
+ }
87
+ getCurrentRelativeHumidity() {
88
+ return this.device.sensorData.humidity || 0;
89
+ }
90
+ }
91
+ exports.AirPurifierAccessory = AirPurifierAccessory;
92
+ //# sourceMappingURL=AirPurifierAccessory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AirPurifierAccessory.js","sourceRoot":"","sources":["../../src/accessory/AirPurifierAccessory.ts"],"names":[],"mappings":";;;AAKA,MAAa,oBAAoB;IAI/B,YACqB,QAAyB,EACzB,SAA4B,EAC5B,MAAqB,EACrB,SAAuB;QAHvB,aAAQ,GAAR,QAAQ,CAAiB;QACzB,cAAS,GAAT,SAAS,CAAmB;QAC5B,WAAM,GAAN,MAAM,CAAe;QACrB,cAAS,GAAT,SAAS,CAAc;QAE1C,IAAI,CAAC,SAAS;aACX,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,oBAAoB,CAAE;aACvD,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,EAAE,SAAS,CAAC;aACvE,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,EAAE,IAAI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