homebridge-rainpoint 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 +143 -0
- package/config.schema.json +148 -0
- package/dist/IrrigationSystemAccessory.d.ts +26 -0
- package/dist/IrrigationSystemAccessory.d.ts.map +1 -0
- package/dist/IrrigationSystemAccessory.js +168 -0
- package/dist/IrrigationSystemAccessory.js.map +1 -0
- package/dist/SensorAccessory.d.ts +22 -0
- package/dist/SensorAccessory.d.ts.map +1 -0
- package/dist/SensorAccessory.js +74 -0
- package/dist/SensorAccessory.js.map +1 -0
- package/dist/ValveAccessory.d.ts +25 -0
- package/dist/ValveAccessory.d.ts.map +1 -0
- package/dist/ValveAccessory.js +119 -0
- package/dist/ValveAccessory.js.map +1 -0
- package/dist/api/RainPointClientInterface.d.ts +65 -0
- package/dist/api/RainPointClientInterface.d.ts.map +1 -0
- package/dist/api/RainPointClientInterface.js +3 -0
- package/dist/api/RainPointClientInterface.js.map +1 -0
- package/dist/api/RainPointHomeClient.d.ts +36 -0
- package/dist/api/RainPointHomeClient.d.ts.map +1 -0
- package/dist/api/RainPointHomeClient.js +359 -0
- package/dist/api/RainPointHomeClient.js.map +1 -0
- package/dist/api/RainPointTyClient.d.ts +113 -0
- package/dist/api/RainPointTyClient.d.ts.map +1 -0
- package/dist/api/RainPointTyClient.js +947 -0
- package/dist/api/RainPointTyClient.js.map +1 -0
- package/dist/api/constants.d.ts +53 -0
- package/dist/api/constants.d.ts.map +1 -0
- package/dist/api/constants.js +105 -0
- package/dist/api/constants.js.map +1 -0
- package/dist/api/dp-parser.d.ts +14 -0
- package/dist/api/dp-parser.d.ts.map +1 -0
- package/dist/api/dp-parser.js +100 -0
- package/dist/api/dp-parser.js.map +1 -0
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +23 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/types.d.ts +330 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +3 -0
- package/dist/api/types.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/naming.d.ts +14 -0
- package/dist/naming.d.ts.map +1 -0
- package/dist/naming.js +22 -0
- package/dist/naming.js.map +1 -0
- package/dist/platform.d.ts +52 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +277 -0
- package/dist/platform.js.map +1 -0
- package/dist/settings.d.ts +3 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +6 -0
- package/dist/settings.js.map +1 -0
- package/package.json +59 -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,143 @@
|
|
|
1
|
+
# Homebridge RainPoint
|
|
2
|
+
|
|
3
|
+
A [Homebridge](https://homebridge.io) plugin for RainPoint irrigation systems. Control your water timers, valves, and soil sensors from HomeKit via the RainPoint cloud API.
|
|
4
|
+
|
|
5
|
+
RainPoint devices are managed through one of two companion apps, each backed by a different cloud:
|
|
6
|
+
|
|
7
|
+
- **RainPoint TY** — the original app (Tuya-based), using the Tuya IoT cloud.
|
|
8
|
+
- **RainPoint Home** — the newer, self-developed app, using the RainPoint Home cloud.
|
|
9
|
+
|
|
10
|
+
This plugin supports both. Select the provider that matches the app you set your devices up with.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
| Feature | RainPoint Home | RainPoint TY |
|
|
15
|
+
|---------|----------------|--------------|
|
|
16
|
+
| Irrigation zone control (on/off) | ✅ | ✅ |
|
|
17
|
+
| Soil moisture & temperature sensors | ✅ | ✅ |
|
|
18
|
+
| Battery level monitoring | ✅ | ✅ |
|
|
19
|
+
| Multi-zone support | ✅ | ✅ |
|
|
20
|
+
| IrrigationSystem grouping or flat Valve layout | ✅ | ✅ |
|
|
21
|
+
| Automatic token refresh / re-authentication | ✅ | ✅ |
|
|
22
|
+
| Persistent cloud session across restarts | ✅ | ✅ |
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
### Via Homebridge UI (Recommended)
|
|
27
|
+
|
|
28
|
+
1. Search for `homebridge-rainpoint` in the Homebridge UI plugin search
|
|
29
|
+
2. Click Install
|
|
30
|
+
3. Configure with your RainPoint account credentials
|
|
31
|
+
|
|
32
|
+
### Via Command Line
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install -g homebridge-rainpoint
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Configuration
|
|
39
|
+
|
|
40
|
+
Add the platform to your Homebridge `config.json`. Pick the `provider` that matches the RainPoint app you use.
|
|
41
|
+
|
|
42
|
+
### RainPoint Home app
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"platforms": [
|
|
47
|
+
{
|
|
48
|
+
"platform": "RainPoint",
|
|
49
|
+
"name": "RainPoint",
|
|
50
|
+
"provider": "home",
|
|
51
|
+
"email": "your-email@example.com",
|
|
52
|
+
"password": "your-password",
|
|
53
|
+
"regionHome": "US"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### RainPoint TY app
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"platforms": [
|
|
64
|
+
{
|
|
65
|
+
"platform": "RainPoint",
|
|
66
|
+
"name": "RainPoint",
|
|
67
|
+
"provider": "ty",
|
|
68
|
+
"email": "your-email@example.com",
|
|
69
|
+
"password": "your-password",
|
|
70
|
+
"regionTy": "AZ",
|
|
71
|
+
"countryCode": "1"
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Configuration Options
|
|
78
|
+
|
|
79
|
+
| Option | Required | Default | Description |
|
|
80
|
+
|--------|----------|---------|-------------|
|
|
81
|
+
| `provider` | No | "home" | Which RainPoint app you use: `"home"` (RainPoint Home) or `"ty"` (RainPoint TY) |
|
|
82
|
+
| `email` | Yes | - | Your RainPoint account email |
|
|
83
|
+
| `password` | Yes | - | Your RainPoint account password |
|
|
84
|
+
| `regionHome` | No | "US" | Region for the RainPoint Home provider: `"US"` (Americas/International) or `"CN"` (China) |
|
|
85
|
+
| `regionTy` | No | "AZ" | Region for the RainPoint TY provider: `"AZ"` (Americas), `"EU"` (Europe), `"IN"` (India), or `"CN"` (China) |
|
|
86
|
+
| `countryCode` | No | "1" | Dialing code for your country (e.g. `1` for US, `91` for India, `86` for China). Only used with the RainPoint TY provider |
|
|
87
|
+
| `name` | No | "RainPoint" | Platform name shown in logs |
|
|
88
|
+
| `homeIndex` | No | 0 | Which home to use if you have multiple (0 = first) |
|
|
89
|
+
| `pollInterval` | No | 30 | How often to poll for updates (seconds, min 10) |
|
|
90
|
+
| `flatValves` | No | false | If true, each zone appears as a standalone Valve accessory instead of grouped under an IrrigationSystem |
|
|
91
|
+
| `debugmode` | No | false | Enable debug logging |
|
|
92
|
+
|
|
93
|
+
> In the Homebridge UI, `regionHome`, `regionTy`, and `countryCode` are shown conditionally based on the selected `provider`.
|
|
94
|
+
|
|
95
|
+
## HomeKit Accessories
|
|
96
|
+
|
|
97
|
+
### Irrigation Zones (Valve)
|
|
98
|
+
Each irrigation zone/port appears as a Valve accessory in HomeKit with:
|
|
99
|
+
- **Active** - Turn the zone on/off
|
|
100
|
+
- **InUse** - Indicates if the valve is currently running
|
|
101
|
+
- **Set Duration** - Set watering duration in seconds
|
|
102
|
+
- **Remaining Duration** - Remaining watering time
|
|
103
|
+
|
|
104
|
+
### Irrigation System
|
|
105
|
+
By default, zones are grouped under an IrrigationSystem accessory. Enable `flatValves` to create standalone Valve accessories instead.
|
|
106
|
+
|
|
107
|
+
### Soil Sensors
|
|
108
|
+
Soil moisture sensors appear as:
|
|
109
|
+
- **Humidity Sensor** - Current soil moisture percentage
|
|
110
|
+
- **Temperature Sensor** - Current soil temperature (if supported)
|
|
111
|
+
- **Battery** - Battery level and low battery alerts
|
|
112
|
+
|
|
113
|
+
## Naming Conventions
|
|
114
|
+
|
|
115
|
+
Zone names are derived from the names you set in the RainPoint app (`portDescribe`), prefixed with the device name so multi-valve accessories sort together and their source is obvious.
|
|
116
|
+
|
|
117
|
+
| Layout | 1-valve device | 2+ valve device |
|
|
118
|
+
|--------|----------------|-----------------|
|
|
119
|
+
| IrrigationSystem (default) | system = `Back Garden`, valve = `Back Garden: Valve` | system = `Back Garden`, valves = `Back Garden: Left Valve`, `Back Garden: Right Valve` |
|
|
120
|
+
| Flat Valves (`flatValves`) | accessory = `Front Garden (Left)` | accessories = `Back Garden: Left Valve`, `Back Garden: Right Valve` |
|
|
121
|
+
|
|
122
|
+
If a zone has no name in the RainPoint app, it falls back to `Valve N`.
|
|
123
|
+
|
|
124
|
+
## Running as a Child Bridge
|
|
125
|
+
|
|
126
|
+
It is recommended to run this plugin as a [child bridge](https://github.com/homebridge/homebridge/wiki/Child-Bridges) for better stability and isolation.
|
|
127
|
+
|
|
128
|
+
## How It Works
|
|
129
|
+
|
|
130
|
+
The plugin authenticates with your RainPoint account credentials against the cloud for the selected provider, discovers devices across your homes, polls device status at a configurable interval, and sends control commands to start/stop irrigation zones.
|
|
131
|
+
|
|
132
|
+
- **RainPoint Home** uses the RainPoint Home cloud API.
|
|
133
|
+
- **RainPoint TY** uses the Tuya IoT cloud API, including RSA-encrypted password login and AES-GCM-encrypted request/response payloads.
|
|
134
|
+
|
|
135
|
+
Device state is encoded using a binary Data Point (DP) system. The plugin parses these hex-encoded states to determine valve on/off status, moisture levels, temperatures, and battery levels.
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
Apache-2.0
|
|
140
|
+
|
|
141
|
+
## Feedback & Issues
|
|
142
|
+
|
|
143
|
+
Please submit any issues or feature requests to the [GitHub Issues](https://github.com/lukezbihlyj/homebridge-rainpoint/issues) page.
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pluginAlias": "RainPoint",
|
|
3
|
+
"pluginType": "platform",
|
|
4
|
+
"singular": true,
|
|
5
|
+
"headerDisplay": "RainPoint integration supporting water timers, valves, and soil sensors via RainPoint Home and RainPoint TY cloud APIs.",
|
|
6
|
+
"footerDisplay": "Each irrigation zone will appear as a Valve accessory in HomeKit. Soil sensors will appear as Humidity and Temperature sensors.",
|
|
7
|
+
"schema": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"name": {
|
|
11
|
+
"title": "Platform Name",
|
|
12
|
+
"type": "string",
|
|
13
|
+
"default": "RainPoint",
|
|
14
|
+
"description": "The name that will appear in the Homebridge log."
|
|
15
|
+
},
|
|
16
|
+
"provider": {
|
|
17
|
+
"title": "Provider",
|
|
18
|
+
"type": "string",
|
|
19
|
+
"default": "home",
|
|
20
|
+
"oneOf": [
|
|
21
|
+
{ "title": "RainPoint Home", "enum": ["home"] },
|
|
22
|
+
{ "title": "RainPoint TY", "enum": ["ty"] }
|
|
23
|
+
],
|
|
24
|
+
"description": "Which RainPoint app/provider you use."
|
|
25
|
+
},
|
|
26
|
+
"email": {
|
|
27
|
+
"title": "Email",
|
|
28
|
+
"type": "string",
|
|
29
|
+
"format": "email",
|
|
30
|
+
"description": "Your RainPoint account email address."
|
|
31
|
+
},
|
|
32
|
+
"password": {
|
|
33
|
+
"title": "Password",
|
|
34
|
+
"type": "string",
|
|
35
|
+
"description": "Your RainPoint account password.",
|
|
36
|
+
"x-schema-form": {
|
|
37
|
+
"type": "password"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"regionHome": {
|
|
41
|
+
"title": "Region",
|
|
42
|
+
"type": "string",
|
|
43
|
+
"default": "US",
|
|
44
|
+
"oneOf": [
|
|
45
|
+
{ "title": "Americas / International (US)", "enum": ["US"] },
|
|
46
|
+
{ "title": "China (CN)", "enum": ["CN"] }
|
|
47
|
+
],
|
|
48
|
+
"description": "Select your region for the RainPoint Home provider."
|
|
49
|
+
},
|
|
50
|
+
"regionTy": {
|
|
51
|
+
"title": "Region",
|
|
52
|
+
"type": "string",
|
|
53
|
+
"default": "AZ",
|
|
54
|
+
"oneOf": [
|
|
55
|
+
{ "title": "Americas (AZ)", "enum": ["AZ"] },
|
|
56
|
+
{ "title": "Europe (EU)", "enum": ["EU"] },
|
|
57
|
+
{ "title": "India (IN)", "enum": ["IN"] },
|
|
58
|
+
{ "title": "China (CN)", "enum": ["CN"] }
|
|
59
|
+
],
|
|
60
|
+
"description": "Select your region for the RainPoint TY provider."
|
|
61
|
+
},
|
|
62
|
+
"countryCode": {
|
|
63
|
+
"title": "Country Code",
|
|
64
|
+
"type": "string",
|
|
65
|
+
"default": "1",
|
|
66
|
+
"description": "Dialing code for your country (e.g. 1 for US, 91 for India, 86 for China). Only used with the RainPoint TY provider."
|
|
67
|
+
},
|
|
68
|
+
"homeIndex": {
|
|
69
|
+
"title": "Home Index",
|
|
70
|
+
"type": "integer",
|
|
71
|
+
"default": 0,
|
|
72
|
+
"minimum": 0,
|
|
73
|
+
"description": "Which home to use if you have multiple homes (0 = first home)."
|
|
74
|
+
},
|
|
75
|
+
"pollInterval": {
|
|
76
|
+
"title": "Poll Interval (seconds)",
|
|
77
|
+
"type": "integer",
|
|
78
|
+
"default": 30,
|
|
79
|
+
"minimum": 10,
|
|
80
|
+
"maximum": 300,
|
|
81
|
+
"description": "How often to poll the cloud for device status updates (in seconds). Minimum 10 seconds."
|
|
82
|
+
},
|
|
83
|
+
"flatValves": {
|
|
84
|
+
"title": "Flat Valve Layout",
|
|
85
|
+
"type": "boolean",
|
|
86
|
+
"default": false,
|
|
87
|
+
"description": "If enabled, each irrigation zone appears as a standalone Valve accessory instead of being grouped under an IrrigationSystem accessory."
|
|
88
|
+
},
|
|
89
|
+
"debugmode": {
|
|
90
|
+
"title": "Debug Mode",
|
|
91
|
+
"type": "boolean",
|
|
92
|
+
"default": false,
|
|
93
|
+
"description": "Enable debug logging."
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"required": [
|
|
97
|
+
"provider",
|
|
98
|
+
"email",
|
|
99
|
+
"password"
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
"layout": [
|
|
103
|
+
{
|
|
104
|
+
"type": "fieldset",
|
|
105
|
+
"title": "Account Credentials",
|
|
106
|
+
"items": [
|
|
107
|
+
"provider",
|
|
108
|
+
{
|
|
109
|
+
"key": "regionHome",
|
|
110
|
+
"condition": { "functionBody": "return model.provider === 'home'" }
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"key": "regionTy",
|
|
114
|
+
"condition": { "functionBody": "return model.provider === 'ty'" }
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"key": "countryCode",
|
|
118
|
+
"condition": { "functionBody": "return model.provider === 'ty'" }
|
|
119
|
+
},
|
|
120
|
+
"email",
|
|
121
|
+
"password"
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"type": "fieldset",
|
|
126
|
+
"title": "Connection Settings",
|
|
127
|
+
"items": [
|
|
128
|
+
"name",
|
|
129
|
+
"pollInterval"
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"type": "fieldset",
|
|
134
|
+
"title": "Accessory Layout",
|
|
135
|
+
"items": [
|
|
136
|
+
"homeIndex",
|
|
137
|
+
"flatValves"
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"type": "fieldset",
|
|
142
|
+
"title": "Advanced",
|
|
143
|
+
"items": [
|
|
144
|
+
"debugmode"
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PlatformAccessory } from 'homebridge';
|
|
2
|
+
import { RainPointPlatform, DeviceAccessoryContext } from './platform';
|
|
3
|
+
import { NormalizedDevice, NormalizedDeviceStatus } from './api/RainPointClientInterface';
|
|
4
|
+
export declare class IrrigationSystemAccessory {
|
|
5
|
+
private readonly platform;
|
|
6
|
+
private readonly accessory;
|
|
7
|
+
private readonly context;
|
|
8
|
+
private readonly device;
|
|
9
|
+
private systemService;
|
|
10
|
+
private valveAccessories;
|
|
11
|
+
private isOnline;
|
|
12
|
+
constructor(platform: RainPointPlatform, accessory: PlatformAccessory, context: DeviceAccessoryContext, device: NormalizedDevice);
|
|
13
|
+
getContext(): DeviceAccessoryContext;
|
|
14
|
+
private createValveServices;
|
|
15
|
+
updateStatus(status: NormalizedDeviceStatus): void;
|
|
16
|
+
private getActive;
|
|
17
|
+
private setActive;
|
|
18
|
+
private getInUse;
|
|
19
|
+
private getValveActive;
|
|
20
|
+
private setValveActive;
|
|
21
|
+
private getValveInUse;
|
|
22
|
+
private getValveSetDuration;
|
|
23
|
+
private setValveSetDuration;
|
|
24
|
+
private getValveRemainingDuration;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=IrrigationSystemAccessory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IrrigationSystemAccessory.d.ts","sourceRoot":"","sources":["../src/IrrigationSystemAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,iBAAiB,EAAuB,MAAM,YAAY,CAAC;AAE7E,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAI1F,qBAAa,yBAAyB;IAMlC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IARzB,OAAO,CAAC,aAAa,CAAU;IAC/B,OAAO,CAAC,gBAAgB,CAAwB;IAChD,OAAO,CAAC,QAAQ,CAAkB;gBAGf,QAAQ,EAAE,iBAAiB,EAC3B,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,gBAAgB;IAqC3C,UAAU,IAAI,sBAAsB;IAIpC,OAAO,CAAC,mBAAmB;IA2E3B,YAAY,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI;YAepC,SAAS;YAMT,SAAS;YAQT,QAAQ;YAYR,cAAc;YAQd,cAAc;YAsBd,aAAa;YAQb,mBAAmB;YAInB,mBAAmB;YAInB,yBAAyB;CAKxC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IrrigationSystemAccessory = void 0;
|
|
4
|
+
const ValveAccessory_1 = require("./ValveAccessory");
|
|
5
|
+
const naming_1 = require("./naming");
|
|
6
|
+
class IrrigationSystemAccessory {
|
|
7
|
+
constructor(platform, accessory, context, device) {
|
|
8
|
+
this.platform = platform;
|
|
9
|
+
this.accessory = accessory;
|
|
10
|
+
this.context = context;
|
|
11
|
+
this.device = device;
|
|
12
|
+
this.valveAccessories = [];
|
|
13
|
+
this.isOnline = false;
|
|
14
|
+
this.platform.log.debug('[%s] IrrigationSystemAccessory ctor: device.name=%s portNumber=%d portDescribe=%s accessory.displayName=%s', device.name, device.name, device.portNumber, JSON.stringify(device.portDescribe), this.accessory.displayName);
|
|
15
|
+
this.accessory.getService(this.platform.Service.AccessoryInformation)
|
|
16
|
+
.setCharacteristic(this.platform.Characteristic.Name, device.name)
|
|
17
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.id)
|
|
18
|
+
.setCharacteristic(this.platform.Characteristic.Model, device.model)
|
|
19
|
+
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'RainPoint');
|
|
20
|
+
// Keep the accessory's displayName in sync with the device name. A cached
|
|
21
|
+
// accessory from a prior run may have a stale displayName (e.g. a valve
|
|
22
|
+
// service name from when zone detection was different); the web UI shows
|
|
23
|
+
// displayName, so update it explicitly here.
|
|
24
|
+
this.accessory.displayName = device.name;
|
|
25
|
+
this.systemService = this.accessory.getService(this.platform.Service.IrrigationSystem)
|
|
26
|
+
|| this.accessory.addService(this.platform.Service.IrrigationSystem);
|
|
27
|
+
// Force the system service's displayName + Name characteristic to the device
|
|
28
|
+
// name (a cached service may carry a stale name from a previous run).
|
|
29
|
+
this.systemService.displayName = device.name;
|
|
30
|
+
this.systemService.setCharacteristic(this.platform.Characteristic.Name, device.name);
|
|
31
|
+
this.systemService.setCharacteristic(this.platform.Characteristic.ProgramMode, this.platform.Characteristic.ProgramMode.NO_PROGRAM_SCHEDULED);
|
|
32
|
+
this.systemService.getCharacteristic(this.platform.Characteristic.Active)
|
|
33
|
+
.onGet(this.getActive.bind(this))
|
|
34
|
+
.onSet(this.setActive.bind(this));
|
|
35
|
+
this.systemService.getCharacteristic(this.platform.Characteristic.InUse)
|
|
36
|
+
.onGet(this.getInUse.bind(this));
|
|
37
|
+
this.createValveServices();
|
|
38
|
+
}
|
|
39
|
+
getContext() {
|
|
40
|
+
return this.context;
|
|
41
|
+
}
|
|
42
|
+
createValveServices() {
|
|
43
|
+
const portNumber = this.device.portNumber || 1;
|
|
44
|
+
for (let port = 1; port <= portNumber; port++) {
|
|
45
|
+
const zoneName = (0, naming_1.zoneDisplayName)(this.device, port, false);
|
|
46
|
+
const subType = `zone${port}`;
|
|
47
|
+
// Look up the existing valve service by subtype ONLY (not displayName).
|
|
48
|
+
// getService(string) matches by subtype OR name, which can collide when a
|
|
49
|
+
// cached service from a prior run carries a stale displayName that happens
|
|
50
|
+
// to equal another zone's intended name. Matching subtype explicitly keeps
|
|
51
|
+
// each port's service stable across restarts.
|
|
52
|
+
let valveService = this.accessory.services.find(s => s.subtype === subType && s.UUID === this.platform.Service.Valve.UUID);
|
|
53
|
+
this.platform.log.debug('[%s] zone %d: zoneName=%s subType=%s existingService=%s', this.device.name, port, zoneName, subType, valveService ? `yes(display=${valveService.displayName})` : 'no');
|
|
54
|
+
if (!valveService) {
|
|
55
|
+
valveService = this.accessory.addService(this.platform.Service.Valve, zoneName, subType);
|
|
56
|
+
}
|
|
57
|
+
// Unconditionally overwrite displayName + Name so a cached service from a
|
|
58
|
+
// prior run (e.g. a 1-zone run that named zone1 "Right Valve") is renamed
|
|
59
|
+
// to the current zone name.
|
|
60
|
+
valveService.displayName = zoneName;
|
|
61
|
+
valveService.setCharacteristic(this.platform.Characteristic.Name, zoneName);
|
|
62
|
+
valveService.setCharacteristic(this.platform.Characteristic.ValveType, this.platform.Characteristic.ValveType.IRRIGATION);
|
|
63
|
+
const valveContext = {
|
|
64
|
+
...this.context,
|
|
65
|
+
port,
|
|
66
|
+
portName: zoneName,
|
|
67
|
+
};
|
|
68
|
+
const valveHandler = new ValveAccessory_1.ValveAccessory(this.platform, this.accessory, valveContext);
|
|
69
|
+
this.valveAccessories.push(valveHandler);
|
|
70
|
+
valveService.getCharacteristic(this.platform.Characteristic.Active)
|
|
71
|
+
.onGet(() => this.getValveActive(port))
|
|
72
|
+
.onSet((value) => this.setValveActive(port, value));
|
|
73
|
+
valveService.getCharacteristic(this.platform.Characteristic.InUse)
|
|
74
|
+
.onGet(() => this.getValveInUse(port));
|
|
75
|
+
valveService.getCharacteristic(this.platform.Characteristic.SetDuration)
|
|
76
|
+
.onGet(() => this.getValveSetDuration(port))
|
|
77
|
+
.onSet((value) => this.setValveSetDuration(port, value));
|
|
78
|
+
valveService.getCharacteristic(this.platform.Characteristic.RemainingDuration)
|
|
79
|
+
.onGet(() => this.getValveRemainingDuration(port));
|
|
80
|
+
this.systemService.addLinkedService(valveService);
|
|
81
|
+
}
|
|
82
|
+
// Remove stale valve services left over from a prior run (e.g. a zone that
|
|
83
|
+
// no longer exists, or a service whose subtype doesn't match the current
|
|
84
|
+
// zone1..zoneN scheme). This keeps the accessory tidy across detection changes.
|
|
85
|
+
const validSubtypes = new Set();
|
|
86
|
+
for (let p = 1; p <= portNumber; p++) {
|
|
87
|
+
validSubtypes.add(`zone${p}`);
|
|
88
|
+
}
|
|
89
|
+
const staleValveServices = this.accessory.services.filter(s => s.UUID === this.platform.Service.Valve.UUID
|
|
90
|
+
&& (!s.subtype || !validSubtypes.has(s.subtype)));
|
|
91
|
+
for (const stale of staleValveServices) {
|
|
92
|
+
this.platform.log.debug('[%s] Removing stale valve service %s', this.device.name, stale.subtype || stale.displayName);
|
|
93
|
+
this.accessory.removeService(stale);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
updateStatus(status) {
|
|
97
|
+
this.isOnline = status.online;
|
|
98
|
+
for (const valve of this.valveAccessories) {
|
|
99
|
+
valve.updateStatus(status);
|
|
100
|
+
}
|
|
101
|
+
this.systemService.updateCharacteristic(this.platform.Characteristic.Active, this.isOnline
|
|
102
|
+
? this.platform.Characteristic.Active.ACTIVE
|
|
103
|
+
: this.platform.Characteristic.Active.INACTIVE);
|
|
104
|
+
}
|
|
105
|
+
async getActive() {
|
|
106
|
+
return this.isOnline
|
|
107
|
+
? this.platform.Characteristic.Active.ACTIVE
|
|
108
|
+
: this.platform.Characteristic.Active.INACTIVE;
|
|
109
|
+
}
|
|
110
|
+
async setActive(value) {
|
|
111
|
+
this.platform.log.info('[%s] Setting irrigation system to %s', this.device.name, value ? 'ON' : 'OFF');
|
|
112
|
+
}
|
|
113
|
+
async getInUse() {
|
|
114
|
+
const anyOn = this.valveAccessories.some(v => {
|
|
115
|
+
const ctx = v.getContext();
|
|
116
|
+
const status = this.platform.getDeviceStatus(ctx.deviceId);
|
|
117
|
+
const zone = status?.zones.find(z => z.port === ctx.port);
|
|
118
|
+
return zone?.isOn ?? false;
|
|
119
|
+
});
|
|
120
|
+
return anyOn
|
|
121
|
+
? this.platform.Characteristic.InUse.IN_USE
|
|
122
|
+
: this.platform.Characteristic.InUse.NOT_IN_USE;
|
|
123
|
+
}
|
|
124
|
+
async getValveActive(port) {
|
|
125
|
+
const status = this.platform.getDeviceStatus(this.context.deviceId);
|
|
126
|
+
const zone = status?.zones.find(z => z.port === port);
|
|
127
|
+
return zone?.isOn
|
|
128
|
+
? this.platform.Characteristic.Active.ACTIVE
|
|
129
|
+
: this.platform.Characteristic.Active.INACTIVE;
|
|
130
|
+
}
|
|
131
|
+
async setValveActive(port, value) {
|
|
132
|
+
const targetActive = value;
|
|
133
|
+
const zoneName = this.device.portDescribe[port - 1] || `Zone ${port}`;
|
|
134
|
+
this.platform.log.info('[%s] Setting %s to %s', this.device.name, zoneName, targetActive === 1 ? 'ON' : 'OFF');
|
|
135
|
+
try {
|
|
136
|
+
if (targetActive === this.platform.Characteristic.Active.ACTIVE) {
|
|
137
|
+
await this.platform.client.turnZoneOn(this.context.deviceId, port);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
await this.platform.client.turnZoneOff(this.context.deviceId, port);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
this.platform.log.error('Failed to control valve: %s', error);
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
async getValveInUse(port) {
|
|
149
|
+
const status = this.platform.getDeviceStatus(this.context.deviceId);
|
|
150
|
+
const zone = status?.zones.find(z => z.port === port);
|
|
151
|
+
return zone?.isOn
|
|
152
|
+
? this.platform.Characteristic.InUse.IN_USE
|
|
153
|
+
: this.platform.Characteristic.InUse.NOT_IN_USE;
|
|
154
|
+
}
|
|
155
|
+
async getValveSetDuration(_port) {
|
|
156
|
+
return 600;
|
|
157
|
+
}
|
|
158
|
+
async setValveSetDuration(port, value) {
|
|
159
|
+
this.platform.log.debug('[%s] Set duration for zone %d to %d seconds', this.device.name, port, value);
|
|
160
|
+
}
|
|
161
|
+
async getValveRemainingDuration(port) {
|
|
162
|
+
const status = this.platform.getDeviceStatus(this.context.deviceId);
|
|
163
|
+
const zone = status?.zones.find(z => z.port === port);
|
|
164
|
+
return zone?.remainingDuration ?? 0;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
exports.IrrigationSystemAccessory = IrrigationSystemAccessory;
|
|
168
|
+
//# sourceMappingURL=IrrigationSystemAccessory.js.map
|