-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.txt
271 lines (143 loc) · 6.07 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
OpenSprinklerPiServer is a RESTful application written in Node.js to control the OpenSprinkler Pi product found at http://rayshobby.net.
It features a web based frontend to configure the zones, programs, and schedules. Also included is a Control4 driver so a user can integrate it with their C4 home automation system if desired.
Installation
-------------
-To install node.js on your pi, I recommend following the instructions found here: http://blog.rueedlinger.ch/2013/03/raspberry-pi-and-nodejs-basic-setup/
-After node is installed, simply unzip the OpenSprinklerPiServer into it's own directory, and run 'npm install' inside that directory to install all the dependencies (currently only restify).
-Now you can launch the app by running 'node app.js'.
-After it has started up, access the web frontend by browsing to http://<IP>:<PORT>/index.html
-Refer to the blog post above to configure the service to start automatically
Control4 Information
---------------------
The driver contains the ability to start, stop, and toggle zones and programs. The program names are hard coded in the driver as "A" and "B", so make sure you configure those names in the web frontend. I will add more programs (C and D), in the future.
Limitations/Known Bugs/TODOs
-----------------------------
-Scheduling is not yet implemented, though it is the next on my list. Control4 can handle scheduling, and some have even used Google Calendar to fire off a program as well.
-Reordering programs on the fly is not yet implemented.
-You can add a zone to a program multiple times, but removing those zones from the program is a little buggy.
-The Frontend is currently very ugly and simple. We're working on it!
-API documentation needs to be beautified a little bit
-If the app doesn't exit cleanly (By pressing Enter to quit), the GPIO's get locked, and the pi has to be rebooted.
Development Information
------------------------
By default , the app is set up to run on the raspberry pi, but you can change it so a PC will emulate the GPIOs of a Raspberry Pi. This is useful for development work. To run on a PC, you will need to do the following two steps:
in PiGpio.js, comment line number 1
in PiGpio.js, uncomment line number 2
It will then use the files in the ./gpio directory. It won't really do anything, but won't throw errors while running.
REST API Documentation
-----------------------
Commands that can be sent using the REST API (replace the IP with your actual IP):
POST /sprinkler/zone
Creates a new zone
Parameters
name string The friendly name of the zone
number int The physical zone number
Status Codes
201 Zone was successfully created
400 Data supplied is invalid, reason supplied in the body
409 Zone number already exists
Notes
zone numbers will be reordered to be the last zone number in the list, regardless of the number you put here
GET http://0.0.0.0/sprinkler/zone
List all Zones
Status Codes
200 All zones returned
GET http://0.0.0.0/sprinkler/zone
List specific zone
Status Codes
200 All zones returned
404 Zone not found, doesn't exist
PUT http://0.0.0.0/sprinkler/zone
Update Zone
Parameters
number int
method "Rename"
params
name string
Status Codes
200 Zone renamed
400 Data supplied is invalid, reason supplied in the body
404 Zone not found, doesn't exist
DELETE http://0.0.0.0/sprinkler/zone/1
Delete a Zone
Status Codes
200 Zone Deleted
404 Zone not found, doesn't exist
GET http://0.0.0.0/sprinkler/zone/1/start
Manually Start a Zone
Status Codes
200 Zone started
404 Zone not found, doesn't exist
GET http://0.0.0.0/sprinkler/zone/1/stop
Manually Stop a Zone
Status Codes
200 Zone Stopped
404 Zone not found, doesn't exist
GET http://0.0.0.0/sprinkler/zone/stop
Stop All Zones
Status Codes
200 All zones stopped
GET http://0.0.0.0/sprinkler/zone/1/toggle
Toggle a Zone On/Off
Status Codes
200 Zone toggled
404 Zone not found, doesn't exist
POST http://0.0.0.0/sprinkler/program
Create a Program
Parameters
name string
Status Codes
201 Program was successfully created
400 Data supplied is invalid, reason supplied in the body
409 Program name already exists
GET http://0.0.0.0/sprinkler/program
List All Programs
Status Codes
200 All programs returned
GET http://0.0.0.0/sprinkler/program/Program%20Name
List Specific Program
Status Codes
200 Program returned
404 Program name not found, doesn't exist
PUT http://0.0.0.0/sprinkler/program
Modify a Program
Parameters
name string
method "Add Zone", "Remove Zone", "Rename"
params
number string Zone number to add or remove [Add zone, Remove zone]
duration int duration the zone will run (in minutes) [Add zone]
name string new name of program [Rename]
Status Codes
200 Program sucessfully updated
400 Data supplied is invalid, reason supplied in the body
404 Program name not found, doesn't exist [All requests]
404 Zone not found [Add zone, Remove zone]
409 Program name already exists
DELETE http://0.0.0.0/sprinkler/program/Program%20Name
Delete a Program
Status Codes
200 Program deleted
404 Program not found, Doesn't exist
GET http://0.0.0.0/sprinkler/program/Program%20Name/start
Start a Program
Status Codes
200 Program started
404 Program not found, Doesn't exist
GET http://0.0.0.0/sprinkler/program/Program%20Name/stop
Stop a Program
Status Codes
200 Program stopped
404 Program not found, Doesn't exist
GET http://0.0.0.0/sprinkler/program/stop
Stop all Programs
Status Codes
200 All programs stopped
GET http://0.0.0.0/sprinkler/program/Program%20Name/next
Advance to next zone in a program
Status Codes
200 OK
GET http://0.0.0.0/sprinkler/program/next
Advance to next zone in any program
Status Codes
200 OK