homebridge-econet-rheem 1.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/LICENSE +176 -0
- package/README.md +64 -0
- package/config.schema.json +30 -0
- package/dist/accessories/thermostatAccessory.d.ts +26 -0
- package/dist/accessories/thermostatAccessory.js +185 -0
- package/dist/accessories/thermostatAccessory.js.map +1 -0
- package/dist/accessories/waterHeaterAccessory.d.ts +21 -0
- package/dist/accessories/waterHeaterAccessory.js +86 -0
- package/dist/accessories/waterHeaterAccessory.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/model/econet.d.ts +39 -0
- package/dist/model/econet.js +230 -0
- package/dist/model/econet.js.map +1 -0
- package/dist/model/enums.d.ts +13 -0
- package/dist/model/enums.js +16 -0
- package/dist/model/enums.js.map +1 -0
- package/dist/model/equipment.d.ts +16 -0
- package/dist/model/equipment.js +34 -0
- package/dist/model/equipment.js.map +1 -0
- package/dist/model/thermostat.d.ts +36 -0
- package/dist/model/thermostat.js +180 -0
- package/dist/model/thermostat.js.map +1 -0
- package/dist/model/utils.d.ts +3 -0
- package/dist/model/utils.js +14 -0
- package/dist/model/utils.js.map +1 -0
- package/dist/model/waterHeater.d.ts +22 -0
- package/dist/model/waterHeater.js +68 -0
- package/dist/model/waterHeater.js.map +1 -0
- package/dist/platform.d.ts +13 -0
- package/dist/platform.js +99 -0
- package/dist/platform.js.map +1 -0
- package/dist/settings.d.ts +8 -0
- package/dist/settings.js +9 -0
- package/dist/settings.js.map +1 -0
- package/notes +7 -0
- package/package.json +52 -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,64 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://github.com/homebridge/branding/raw/latest/logos/homebridge-wordmark-logo-vertical.png" width="150">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# Homebridge EcoNet Rheem Plugin
|
|
6
|
+
|
|
7
|
+
This Homebridge plugin integrates Rheem EcoNet-enabled devices into Apple HomeKit. **Currently, only Water Heaters have been fully implemented and tested.** Thermostat support and Celsius operation remain untested.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
1. Ensure you have [Homebridge](https://homebridge.io) installed and running.
|
|
12
|
+
2. Install this plugin via npm:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g homebridge-econet-rheem
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Configuration
|
|
19
|
+
|
|
20
|
+
Add the following to your Homebridge `config.json`:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"platforms": [
|
|
25
|
+
{
|
|
26
|
+
"platform": "HomebridgeEconetRheem",
|
|
27
|
+
"email": "your_econet_email",
|
|
28
|
+
"password": "your_econet_password",
|
|
29
|
+
"debug": false
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
- `platform`: (Required) Must be "HomebridgeEconetRheem".
|
|
36
|
+
- `email`: (Required) Your Econet account email.
|
|
37
|
+
- `password`: (Required) Your Econet account password.
|
|
38
|
+
- `debug`: (Optional) Set to `true` to enable debug logging. Default is `false`.
|
|
39
|
+
|
|
40
|
+
## Current Limitations
|
|
41
|
+
|
|
42
|
+
- **Water Heaters**: Fully implemented and tested in Farenheit.
|
|
43
|
+
- **Thermostats**: Not implemented or tested due to lack of hardware access.
|
|
44
|
+
- **Celsius Operation**: Untested.
|
|
45
|
+
|
|
46
|
+
## Contributing
|
|
47
|
+
|
|
48
|
+
Contributions to support Thermostat operation are welcome. To assist:
|
|
49
|
+
|
|
50
|
+
1. Set `"debug": true` in the plugin configuration.
|
|
51
|
+
2. Run Homebridge in debug mode:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
homebridge -D
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
3. Capture the JSON responses for HTTP and MQTT state changes.
|
|
58
|
+
4. Submit the captured data via a GitHub issue or pull request.
|
|
59
|
+
|
|
60
|
+
Your contributions will help enhance the plugin's functionality and device support.
|
|
61
|
+
|
|
62
|
+
## Disclaimer
|
|
63
|
+
|
|
64
|
+
This plugin is independently developed and is not affiliated with or endorsed by Rheem Manufacturing Company.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pluginAlias": "HomebridgeEconetRheem",
|
|
3
|
+
"pluginType": "platform",
|
|
4
|
+
"singular": true,
|
|
5
|
+
"strictValidation": false,
|
|
6
|
+
"schema": {
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"email": {
|
|
10
|
+
"title": "Email",
|
|
11
|
+
"type": "string",
|
|
12
|
+
"format": "email",
|
|
13
|
+
"required": true,
|
|
14
|
+
"description": "Rheem/Econet account email"
|
|
15
|
+
},
|
|
16
|
+
"password": {
|
|
17
|
+
"title": "Password",
|
|
18
|
+
"type": "string",
|
|
19
|
+
"required": true,
|
|
20
|
+
"description": "Rheem/Econet account password"
|
|
21
|
+
},
|
|
22
|
+
"debug": {
|
|
23
|
+
"title": "Password",
|
|
24
|
+
"type": "boolean",
|
|
25
|
+
"required": false,
|
|
26
|
+
"description": "Enabled additional debug logging"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
2
|
+
import { EconetRheemPlatform } from '../platform.js';
|
|
3
|
+
import { Thermostat } from '../model/thermostat.js';
|
|
4
|
+
export declare class ThermostatAccessory {
|
|
5
|
+
private readonly platform;
|
|
6
|
+
private readonly accessory;
|
|
7
|
+
private readonly thermostat;
|
|
8
|
+
private service;
|
|
9
|
+
private readonly Characteristic;
|
|
10
|
+
constructor(platform: EconetRheemPlatform, accessory: PlatformAccessory, thermostat: Thermostat);
|
|
11
|
+
private handleEquipmentUpdate;
|
|
12
|
+
private updateCharacteristics;
|
|
13
|
+
getActive(): Promise<CharacteristicValue>;
|
|
14
|
+
setActive(value: CharacteristicValue): Promise<void>;
|
|
15
|
+
private getCurrentRunningState;
|
|
16
|
+
private getCurrentState;
|
|
17
|
+
private getTargetState;
|
|
18
|
+
private setTargetState;
|
|
19
|
+
getCurrentTemperature(): Promise<CharacteristicValue>;
|
|
20
|
+
private getTargetTemperature;
|
|
21
|
+
private setTargetTemperature;
|
|
22
|
+
private getHeatingThresholdTemperature;
|
|
23
|
+
private setHeatingThresholdTemperature;
|
|
24
|
+
private getCoolingThresholdTemperature;
|
|
25
|
+
private setCoolingThresholdTemperature;
|
|
26
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { ThermostatOperationMode } from '../model/enums.js';
|
|
2
|
+
import { toCelsius, fromCelsius } from '../model/utils.js';
|
|
3
|
+
export class ThermostatAccessory {
|
|
4
|
+
platform;
|
|
5
|
+
accessory;
|
|
6
|
+
thermostat;
|
|
7
|
+
service;
|
|
8
|
+
Characteristic;
|
|
9
|
+
constructor(platform, accessory, thermostat) {
|
|
10
|
+
this.platform = platform;
|
|
11
|
+
this.accessory = accessory;
|
|
12
|
+
this.thermostat = thermostat;
|
|
13
|
+
this.Characteristic = platform.api.hap.Characteristic;
|
|
14
|
+
const Service = platform.api.hap.Service;
|
|
15
|
+
this.accessory.getService(Service.AccessoryInformation)
|
|
16
|
+
.setCharacteristic(this.Characteristic.Manufacturer, 'Rheem')
|
|
17
|
+
.setCharacteristic(this.Characteristic.Model, 'Thermostat')
|
|
18
|
+
.setCharacteristic(this.Characteristic.SerialNumber, this.thermostat.serialNumber);
|
|
19
|
+
this.service = this.accessory.getService(Service.Thermostat) ||
|
|
20
|
+
this.accessory.addService(Service.Thermostat);
|
|
21
|
+
this.service.setCharacteristic(this.Characteristic.Name, this.thermostat.deviceName);
|
|
22
|
+
this.service.getCharacteristic(this.Characteristic.Active)
|
|
23
|
+
.onGet(this.getActive.bind(this))
|
|
24
|
+
.onSet(this.setActive.bind(this));
|
|
25
|
+
this.service.getCharacteristic(this.Characteristic.CurrentHeatingCoolingState)
|
|
26
|
+
.onGet(this.getCurrentState.bind(this));
|
|
27
|
+
this.service.getCharacteristic(this.Characteristic.TargetHeatingCoolingState)
|
|
28
|
+
.onGet(this.getTargetState.bind(this))
|
|
29
|
+
.onSet(this.setTargetState.bind(this));
|
|
30
|
+
this.service.getCharacteristic(this.Characteristic.CurrentTemperature)
|
|
31
|
+
.onGet(this.getCurrentTemperature.bind(this));
|
|
32
|
+
this.service.getCharacteristic(this.Characteristic.TargetTemperature)
|
|
33
|
+
.onGet(this.getTargetTemperature.bind(this))
|
|
34
|
+
.onSet(this.setTargetTemperature.bind(this));
|
|
35
|
+
const minHeatTemp = toCelsius(this.thermostat.heatSetPointLimits[0], this.thermostat.units);
|
|
36
|
+
const maxHeatTemp = toCelsius(this.thermostat.heatSetPointLimits[1], this.thermostat.units);
|
|
37
|
+
this.service.getCharacteristic(this.Characteristic.HeatingThresholdTemperature)
|
|
38
|
+
.setProps({ minValue: minHeatTemp, maxValue: maxHeatTemp, minStep: 0.1 })
|
|
39
|
+
.onGet(this.getHeatingThresholdTemperature.bind(this))
|
|
40
|
+
.onSet(this.setHeatingThresholdTemperature.bind(this));
|
|
41
|
+
const minCoolTemp = toCelsius(this.thermostat.coolSetPointLimits[0], this.thermostat.units);
|
|
42
|
+
const maxCoolTemp = toCelsius(this.thermostat.coolSetPointLimits[1], this.thermostat.units);
|
|
43
|
+
this.service.getCharacteristic(this.Characteristic.CoolingThresholdTemperature)
|
|
44
|
+
.setProps({ minValue: minCoolTemp, maxValue: maxCoolTemp, minStep: 0.1 })
|
|
45
|
+
.onGet(this.getCoolingThresholdTemperature.bind(this))
|
|
46
|
+
.onSet(this.setCoolingThresholdTemperature.bind(this));
|
|
47
|
+
this.thermostat.setOnUpdateCallback(this.handleEquipmentUpdate.bind(this));
|
|
48
|
+
this.updateCharacteristics();
|
|
49
|
+
}
|
|
50
|
+
handleEquipmentUpdate(serial) {
|
|
51
|
+
if (serial === this.thermostat.serialNumber) {
|
|
52
|
+
this.updateCharacteristics();
|
|
53
|
+
this.platform.log.debug(`Received update for ${serial}, refreshed accessory state`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
updateCharacteristics() {
|
|
57
|
+
this.service.updateCharacteristic(this.Characteristic.Active, this.thermostat.isEnabled ? 1 : 0);
|
|
58
|
+
this.service.updateCharacteristic(this.Characteristic.CurrentHeaterCoolerState, this.getCurrentRunningState());
|
|
59
|
+
this.service.updateCharacteristic(this.Characteristic.CurrentHeatingCoolingState, this.getCurrentState());
|
|
60
|
+
this.service.updateCharacteristic(this.Characteristic.TargetHeatingCoolingState, this.getTargetState());
|
|
61
|
+
this.service.updateCharacteristic(this.Characteristic.CurrentTemperature, toCelsius(this.thermostat.currentTemp, this.thermostat.units));
|
|
62
|
+
this.service.updateCharacteristic(this.Characteristic.TargetTemperature, this.getTargetTemperature());
|
|
63
|
+
this.service.updateCharacteristic(this.Characteristic.HeatingThresholdTemperature, this.getHeatingThresholdTemperature());
|
|
64
|
+
this.service.updateCharacteristic(this.Characteristic.CoolingThresholdTemperature, this.getCoolingThresholdTemperature());
|
|
65
|
+
}
|
|
66
|
+
async getActive() {
|
|
67
|
+
return this.thermostat.isEnabled ? 1 : 0;
|
|
68
|
+
}
|
|
69
|
+
async setActive(value) {
|
|
70
|
+
const enabled = value === 1;
|
|
71
|
+
await this.thermostat.setEnabled(enabled);
|
|
72
|
+
}
|
|
73
|
+
getCurrentRunningState() {
|
|
74
|
+
const currentState = this.getCurrentRunningState();
|
|
75
|
+
if (!this.thermostat.isRunning || currentState === this.Characteristic.CurrentHeatingCoolingState.OFF) {
|
|
76
|
+
return this.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
77
|
+
}
|
|
78
|
+
if (currentState === this.Characteristic.CurrentHeatingCoolingState.HEAT) {
|
|
79
|
+
return this.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
80
|
+
}
|
|
81
|
+
return this.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
82
|
+
}
|
|
83
|
+
getCurrentState() {
|
|
84
|
+
if (!this.thermostat.isEnabled) {
|
|
85
|
+
return this.Characteristic.CurrentHeatingCoolingState.OFF;
|
|
86
|
+
}
|
|
87
|
+
switch (this.thermostat.mode) {
|
|
88
|
+
case ThermostatOperationMode.HEATING:
|
|
89
|
+
case ThermostatOperationMode.EMERGENCY_HEAT:
|
|
90
|
+
return this.Characteristic.CurrentHeatingCoolingState.HEAT;
|
|
91
|
+
case ThermostatOperationMode.COOLING:
|
|
92
|
+
return this.Characteristic.CurrentHeatingCoolingState.COOL;
|
|
93
|
+
default:
|
|
94
|
+
return this.Characteristic.CurrentHeatingCoolingState.OFF;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
getTargetState() {
|
|
98
|
+
switch (this.thermostat.mode) {
|
|
99
|
+
case ThermostatOperationMode.OFF:
|
|
100
|
+
return this.Characteristic.TargetHeatingCoolingState.OFF;
|
|
101
|
+
case ThermostatOperationMode.HEATING:
|
|
102
|
+
case ThermostatOperationMode.EMERGENCY_HEAT:
|
|
103
|
+
return this.Characteristic.TargetHeatingCoolingState.HEAT;
|
|
104
|
+
case ThermostatOperationMode.COOLING:
|
|
105
|
+
return this.Characteristic.TargetHeatingCoolingState.COOL;
|
|
106
|
+
case ThermostatOperationMode.AUTO:
|
|
107
|
+
return this.Characteristic.TargetHeatingCoolingState.AUTO;
|
|
108
|
+
default:
|
|
109
|
+
return this.Characteristic.TargetHeatingCoolingState.OFF;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async setTargetState(value) {
|
|
113
|
+
const state = value;
|
|
114
|
+
let mode;
|
|
115
|
+
switch (state) {
|
|
116
|
+
case this.Characteristic.TargetHeatingCoolingState.OFF:
|
|
117
|
+
mode = ThermostatOperationMode.OFF;
|
|
118
|
+
break;
|
|
119
|
+
case this.Characteristic.TargetHeatingCoolingState.HEAT:
|
|
120
|
+
mode = ThermostatOperationMode.HEATING;
|
|
121
|
+
break;
|
|
122
|
+
case this.Characteristic.TargetHeatingCoolingState.COOL:
|
|
123
|
+
mode = ThermostatOperationMode.COOLING;
|
|
124
|
+
break;
|
|
125
|
+
case this.Characteristic.TargetHeatingCoolingState.AUTO:
|
|
126
|
+
mode = ThermostatOperationMode.AUTO;
|
|
127
|
+
break;
|
|
128
|
+
default:
|
|
129
|
+
this.platform.log.error('Unsupported target state:', state);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
this.thermostat.setMode(mode);
|
|
133
|
+
}
|
|
134
|
+
async getCurrentTemperature() {
|
|
135
|
+
return toCelsius(this.thermostat.currentTemp, this.thermostat.units);
|
|
136
|
+
}
|
|
137
|
+
getTargetTemperature() {
|
|
138
|
+
const heatSetPoint = toCelsius(this.thermostat.heatSetPoint, this.thermostat.units);
|
|
139
|
+
const coolSetPoint = toCelsius(this.thermostat.coolSetPoint, this.thermostat.units);
|
|
140
|
+
switch (this.thermostat.mode) {
|
|
141
|
+
case ThermostatOperationMode.HEATING:
|
|
142
|
+
case ThermostatOperationMode.EMERGENCY_HEAT:
|
|
143
|
+
return heatSetPoint;
|
|
144
|
+
case ThermostatOperationMode.COOLING:
|
|
145
|
+
return coolSetPoint;
|
|
146
|
+
default: {
|
|
147
|
+
return (heatSetPoint + coolSetPoint) / 2;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async setTargetTemperature(value) {
|
|
152
|
+
const temp = fromCelsius(value, this.thermostat.units);
|
|
153
|
+
switch (this.thermostat.mode) {
|
|
154
|
+
case ThermostatOperationMode.HEATING:
|
|
155
|
+
case ThermostatOperationMode.EMERGENCY_HEAT:
|
|
156
|
+
this.thermostat.setSetPoint(undefined, undefined, temp);
|
|
157
|
+
break;
|
|
158
|
+
case ThermostatOperationMode.COOLING:
|
|
159
|
+
this.thermostat.setSetPoint(undefined, temp);
|
|
160
|
+
break;
|
|
161
|
+
case ThermostatOperationMode.AUTO: {
|
|
162
|
+
const deadband = this.thermostat.deadband;
|
|
163
|
+
const heatSetPoint = temp - deadband / 2;
|
|
164
|
+
const coolSetPoint = temp + deadband / 2;
|
|
165
|
+
this.thermostat.setSetPoint(undefined, coolSetPoint, heatSetPoint);
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
getHeatingThresholdTemperature() {
|
|
171
|
+
return toCelsius(this.thermostat.heatSetPoint, this.thermostat.units);
|
|
172
|
+
}
|
|
173
|
+
async setHeatingThresholdTemperature(value) {
|
|
174
|
+
const temp = fromCelsius(value, this.thermostat.units);
|
|
175
|
+
this.thermostat.setSetPoint(undefined, undefined, temp);
|
|
176
|
+
}
|
|
177
|
+
getCoolingThresholdTemperature() {
|
|
178
|
+
return toCelsius(this.thermostat.coolSetPoint, this.thermostat.units);
|
|
179
|
+
}
|
|
180
|
+
async setCoolingThresholdTemperature(value) {
|
|
181
|
+
const temp = fromCelsius(value, this.thermostat.units);
|
|
182
|
+
this.thermostat.setSetPoint(undefined, temp);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=thermostatAccessory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thermostatAccessory.js","sourceRoot":"","sources":["../../src/accessories/thermostatAccessory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE3D,MAAM,OAAO,mBAAmB;IAKX;IACA;IACA;IANX,OAAO,CAAU;IACR,cAAc,CAA6C;IAE5E,YACmB,QAA6B,EAC7B,SAA4B,EAC5B,UAAsB;QAFtB,aAAQ,GAAR,QAAQ,CAAqB;QAC7B,cAAS,GAAT,SAAS,CAAmB;QAC5B,eAAU,GAAV,UAAU,CAAY;QAGvC,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC;QACtD,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC;QAEzC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,oBAAoB,CAAE;aACrD,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,OAAO,CAAC;aAC5D,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,YAAY,CAAC;aAC1D,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,IAAI,C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,CAAC,CAAC;QACjE,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAC1D,CAAC;IAEO,8BAA8B;QACpC,OAAO,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACxE,CAAC;IAEO,KAAK,CAAC,8BAA8B,CAAC,KAA0B;QACrE,MAAM,IAAI,GAAG,WAAW,CAAC,KAAe,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACjE,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
2
|
+
import { EconetRheemPlatform } from '../platform.js';
|
|
3
|
+
import { WaterHeater } from '../model/waterHeater.js';
|
|
4
|
+
export declare class WaterHeaterAccessory {
|
|
5
|
+
private readonly platform;
|
|
6
|
+
private readonly accessory;
|
|
7
|
+
private readonly waterHeater;
|
|
8
|
+
private service;
|
|
9
|
+
private readonly Characteristic;
|
|
10
|
+
constructor(platform: EconetRheemPlatform, accessory: PlatformAccessory, waterHeater: WaterHeater);
|
|
11
|
+
private handleEquipmentUpdate;
|
|
12
|
+
updateCharacteristics(): void;
|
|
13
|
+
getActive(): Promise<CharacteristicValue>;
|
|
14
|
+
getCurrentState(): Promise<CharacteristicValue>;
|
|
15
|
+
getTargetState(): Promise<CharacteristicValue>;
|
|
16
|
+
setTargetState(value: CharacteristicValue): Promise<void>;
|
|
17
|
+
getCurrentTemperature(): Promise<CharacteristicValue>;
|
|
18
|
+
getHeatingThresholdTemperature(): Promise<CharacteristicValue>;
|
|
19
|
+
setHeatingThresholdTemperature(value: CharacteristicValue): Promise<void>;
|
|
20
|
+
setActive(value: CharacteristicValue): Promise<void>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { toCelsius, fromCelsius } from '../model/utils.js';
|
|
2
|
+
export class WaterHeaterAccessory {
|
|
3
|
+
platform;
|
|
4
|
+
accessory;
|
|
5
|
+
waterHeater;
|
|
6
|
+
service;
|
|
7
|
+
Characteristic;
|
|
8
|
+
constructor(platform, accessory, waterHeater) {
|
|
9
|
+
this.platform = platform;
|
|
10
|
+
this.accessory = accessory;
|
|
11
|
+
this.waterHeater = waterHeater;
|
|
12
|
+
this.Characteristic = platform.api.hap.Characteristic;
|
|
13
|
+
const Service = platform.api.hap.Service;
|
|
14
|
+
this.accessory.getService(Service.AccessoryInformation)
|
|
15
|
+
.setCharacteristic(this.Characteristic.Manufacturer, 'Rheem')
|
|
16
|
+
.setCharacteristic(this.Characteristic.Model, 'Water Heater')
|
|
17
|
+
.setCharacteristic(this.Characteristic.SerialNumber, this.waterHeater.serialNumber);
|
|
18
|
+
this.service = this.accessory.getService(Service.HeaterCooler) ||
|
|
19
|
+
this.accessory.addService(Service.HeaterCooler);
|
|
20
|
+
this.service.setCharacteristic(this.Characteristic.Name, this.waterHeater.deviceName);
|
|
21
|
+
this.service.getCharacteristic(this.Characteristic.Active)
|
|
22
|
+
.onGet(this.getActive.bind(this))
|
|
23
|
+
.onSet(this.setActive.bind(this));
|
|
24
|
+
this.service.getCharacteristic(this.Characteristic.CurrentHeaterCoolerState)
|
|
25
|
+
.onGet(this.getCurrentState.bind(this));
|
|
26
|
+
this.service.getCharacteristic(this.Characteristic.TargetHeaterCoolerState)
|
|
27
|
+
.setProps({ validValues: [this.Characteristic.TargetHeaterCoolerState.HEAT] })
|
|
28
|
+
.onGet(this.getTargetState.bind(this))
|
|
29
|
+
.onSet(this.setTargetState.bind(this));
|
|
30
|
+
this.service.getCharacteristic(this.Characteristic.CurrentTemperature)
|
|
31
|
+
.onGet(this.getCurrentTemperature.bind(this));
|
|
32
|
+
const minTemp = toCelsius(this.waterHeater.limits[0], this.waterHeater.units);
|
|
33
|
+
const maxTemp = toCelsius(this.waterHeater.limits[1], this.waterHeater.units);
|
|
34
|
+
this.service.getCharacteristic(this.Characteristic.HeatingThresholdTemperature)
|
|
35
|
+
.setProps({ minValue: minTemp, maxValue: maxTemp, minStep: 0.1 })
|
|
36
|
+
.onGet(this.getHeatingThresholdTemperature.bind(this))
|
|
37
|
+
.onSet(this.setHeatingThresholdTemperature.bind(this));
|
|
38
|
+
this.waterHeater.setOnUpdateCallback(this.handleEquipmentUpdate.bind(this));
|
|
39
|
+
this.updateCharacteristics();
|
|
40
|
+
}
|
|
41
|
+
handleEquipmentUpdate(serial) {
|
|
42
|
+
if (serial === this.waterHeater.serialNumber) {
|
|
43
|
+
this.updateCharacteristics();
|
|
44
|
+
this.platform.log.debug(`Received update for ${serial}, refreshed accessory state`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
updateCharacteristics() {
|
|
48
|
+
this.service.updateCharacteristic(this.Characteristic.Active, this.waterHeater.isEnabled ? 1 : 0);
|
|
49
|
+
this.service.updateCharacteristic(this.Characteristic.CurrentHeaterCoolerState, this.waterHeater.isRunning ? this.Characteristic.CurrentHeaterCoolerState.HEATING :
|
|
50
|
+
this.Characteristic.CurrentHeaterCoolerState.IDLE);
|
|
51
|
+
this.service.updateCharacteristic(this.Characteristic.TargetHeaterCoolerState, this.Characteristic.TargetHeaterCoolerState.HEAT);
|
|
52
|
+
this.service.updateCharacteristic(this.Characteristic.CurrentTemperature, toCelsius(this.waterHeater.currentTemp, this.waterHeater.units));
|
|
53
|
+
this.service.updateCharacteristic(this.Characteristic.HeatingThresholdTemperature, toCelsius(this.waterHeater.setPoint, this.waterHeater.units));
|
|
54
|
+
}
|
|
55
|
+
async getActive() {
|
|
56
|
+
return this.waterHeater.isEnabled ? 1 : 0;
|
|
57
|
+
}
|
|
58
|
+
async getCurrentState() {
|
|
59
|
+
return this.waterHeater.isRunning ?
|
|
60
|
+
this.Characteristic.CurrentHeaterCoolerState.HEATING :
|
|
61
|
+
this.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
62
|
+
}
|
|
63
|
+
async getTargetState() {
|
|
64
|
+
return this.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
65
|
+
}
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
67
|
+
async setTargetState(value) {
|
|
68
|
+
// Always HEAT, no-op for other states
|
|
69
|
+
}
|
|
70
|
+
async getCurrentTemperature() {
|
|
71
|
+
return toCelsius(this.waterHeater.currentTemp, this.waterHeater.units);
|
|
72
|
+
}
|
|
73
|
+
async getHeatingThresholdTemperature() {
|
|
74
|
+
return toCelsius(this.waterHeater.setPoint, this.waterHeater.units);
|
|
75
|
+
}
|
|
76
|
+
async setHeatingThresholdTemperature(value) {
|
|
77
|
+
const setPointC = value;
|
|
78
|
+
const setPointNative = fromCelsius(setPointC, this.waterHeater.units);
|
|
79
|
+
this.waterHeater.setSetPoint(setPointNative);
|
|
80
|
+
}
|
|
81
|
+
async setActive(value) {
|
|
82
|
+
const enabled = value === 1;
|
|
83
|
+
await this.waterHeater.setEnabled(enabled);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=waterHeaterAccessory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waterHeaterAccessory.js","sourceRoot":"","sources":["../../src/accessories/waterHeaterAccessory.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE3D,MAAM,OAAO,oBAAoB;IAKZ;IACA;IACA;IANX,OAAO,CAAU;IACR,cAAc,CAA6C;IAE5E,YACmB,QAA6B,EAC7B,SAA4B,EAC5B,WAAwB;QAFxB,aAAQ,GAAR,QAAQ,CAAqB;QAC7B,cAAS,GAAT,SAAS,CAAmB;QAC5B,gBAAW,GAAX,WAAW,CAAa;QAGzC,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,C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ED,KAAK,CAAC,eAAe;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;YACjC,IAAI,CAAC,cAAc,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;YACtD,IAAI,CAAC,cAAc,CAAC,wBAAwB,CAAC,IAAI,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,OAAO,IAAI,CAAC,cAAc,CAAC,uBAAuB,CAAC,IAAI,CAAC;IAC1D,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,cAAc,CAAC,KAA0B;QAC7C,sCAAsC;IACxC,CAAC;IAED,KAAK,CAAC,qBAAqB;QACzB,OAAO,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACzE,CAAC;IAED,KAAK,CAAC,8BAA8B;QAClC,OAAO,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACtE,CAAC;IAED,KAAK,CAAC,8BAA8B,CAAC,KAA0B;QAC7D,MAAM,SAAS,GAAG,KAAe,CAAC;QAClC,MAAM,cAAc,GAAG,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACtE,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,KAA0B;QACxC,MAAM,OAAO,GAAG,KAAe,KAAK,CAAC,CAAC;QACtC,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EconetRheemPlatform } 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, EconetRheemPlatform);
|
|
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,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;GAEG;AACH,eAAe,CAAC,GAAQ,EAAE,EAAE;IAC1B,GAAG,CAAC,gBAAgB,CAAC,aAAa,EAAE,mBAAmB,CAAC,CAAC;AAC3D,CAAC,CAAC"}
|