1
1
# sidecar-starter-pack
2
2
3
- Authentication and communication utilities for FarmBot sidecars
3
+ This library provides authentication, API, and control utilities for ** FarmBot sidecars** . A ** sidecar** is another computer such as a Raspberry Pi, laptop, or server that you are in full control of to install your own packages onto and run your own code, unlocking what cannot be done using FarmBot OS or the web app alone. For example, a sidecar could:
4
+
5
+ - Extend the capabilities of your FarmBot with specialized hardware such as a GPU, or a camera or other sensor requiring special drivers.
6
+ - Expose your FarmBot's hardware capabilities as a device in a larger ecosystem such as one for home automation or scientific research.
7
+ - Perform more advanced manipulation of your web app account's data which may be infeasible using the frontend interface.
4
8
5
9
[ ![ Test Status] ( https://github.com/FarmBot-Labs/sidecar-starter-pack/actions/workflows/test.yml/badge.svg?branch=main )] ( https://github.com/FarmBot-Labs/sidecar-starter-pack/actions?query=branch%3Amain )
6
10
[ ![ Coverage Status] ( https://coveralls.io/repos/github/FarmBot-Labs/sidecar-starter-pack/badge.svg?branch=main )] ( https://coveralls.io/github/FarmBot-Labs/sidecar-starter-pack?branch=main )
@@ -150,17 +154,17 @@ sidecar-starter-pack/
150
154
151
155
| class ` BasicCommands() ` | Description |
152
156
| :--- | :--- |
153
- | ` wait() ` | Pauses execution for a certain number of milliseconds. |
157
+ | ` wait() ` | Pauses FarmBot execution for a certain number of milliseconds. Note: You may need to combine this with a ` sleep() ` in your sidecar code . |
154
158
| ` e_stop() ` | Emergency locks (E-stops) the Farmduino microcontroller and resets peripheral pins to OFF. |
155
159
| ` unlock() ` | Unlocks a locked (E-stopped) device. |
156
- | ` reboot() ` | Reboots the FarmBot OS and reinitializes the device. |
157
- | ` shutdown() ` | Shuts down the FarmBot OS, turning the device off. |
160
+ | ` reboot() ` | Reboots FarmBot OS and reinitializes the device. |
161
+ | ` shutdown() ` | Shuts down FarmBot OS, turning the device off. Note: You will need to unplug and plug the FarmBot back in to turn it back on . |
158
162
159
163
### broker.py
160
164
161
165
| class ` BrokerConnect() ` | Description |
162
166
| :--- | :--- |
163
- | ` connect() ` | Establish persistent connection to send messages via message broker. |
167
+ | ` connect() ` | Establish a persistent connection to send messages via the message broker. |
164
168
| ` disconnect() ` | Disconnect from the message broker. |
165
169
| ` publish() ` | Publish messages containing CeleryScript via the message broker. |
166
170
| ` on_connect() ` | Callback function triggered when a connection to the message broker is successfully established. |
@@ -187,15 +191,15 @@ sidecar-starter-pack/
187
191
188
192
| class ` Information() ` | Description |
189
193
| :--- | :--- |
190
- | ` get_info() ` | Get information about a specific endpoint . |
191
- | ` edit_info() ` | Change information contained within an endpoint . |
192
- | ` add_info() ` | Create new information contained within an endpoint . |
193
- | ` delete_info() ` | Delete information contained within an endpoint . |
194
- | ` safe_z() ` | Returns the highest safe point along the z-axis . |
194
+ | ` get_info() ` | GET information from the API . |
195
+ | ` edit_info() ` | PATCH information in the API . |
196
+ | ` add_info() ` | POST information to the API . |
197
+ | ` delete_info() ` | DELETE information in the API . |
198
+ | ` safe_z() ` | Returns the safe Z coordinate . |
195
199
| ` garden_size() ` | Returns x-axis length, y-axis length, and area of garden bed. |
196
- | ` group() ` | Returns all group info or single by id. |
197
- | ` curve() ` | Returns all curve info or single by id. |
198
- | ` soil_height ()` | Use the camera to determine soil height at the current location. |
200
+ | ` group() ` | Returns all groups or a single group by id. |
201
+ | ` curve() ` | Returns all curves or a single curve by id. |
202
+ | ` measure_soil_height ()` | Use the camera to determine soil height at the current location. |
199
203
| ` read_status() ` | Returns the FarmBot status tree. |
200
204
| ` read_sensor() ` | Reads the given pin by id. |
201
205
@@ -205,16 +209,16 @@ sidecar-starter-pack/
205
209
| :--- | :--- |
206
210
| ` get_job() ` | Retrieves the status or details of the specified job. |
207
211
| ` set_job() ` | Initiates or modifies job with given parameters. |
208
- | ` complete_job() ` | Marks job as completed and triggers any associated actions . |
212
+ | ` complete_job() ` | Marks job as completed. |
209
213
210
214
### messages.py
211
215
212
216
| class ` MessageHandling() ` | Description |
213
217
| :--- | :--- |
214
- | ` log() ` | Sends new log message via the API. Requires the page to be refreshed before appearing. |
218
+ | ` log() ` | Sends new log message via the API. Requires the web app page to be refreshed before appearing. |
215
219
| ` message() ` | Sends new log message via the message broker. |
216
- | ` debug() ` | Sends debug message used for developer information or troubleshooting. |
217
- | ` toast() ` | Sends a message that pops up on the user interface briefly. |
220
+ | ` debug() ` | Sends debug message used for developer information or troubleshooting. These will not persist in the database. |
221
+ | ` toast() ` | Sends a message that pops up in the web app briefly. |
218
222
219
223
### movements.py
220
224
@@ -223,26 +227,26 @@ sidecar-starter-pack/
223
227
| ` move() ` | Moves to the specified (x, y, z) coordinate. |
224
228
| ` set_home() ` | Sets the current position as the home position for a specific axis. |
225
229
| ` find_home() ` | Moves the device to the home position for a specified axis. |
226
- | ` axis_length ()` | Returns the length of a specified axis. |
230
+ | ` find_axis_length ()` | Finds the length of a specified axis. |
227
231
| ` get_xyz() ` | Returns the current (x, y, z) coordinates of the FarmBot. |
228
- | ` check_position() ` | Verifies position of the FarmBot within specified tolerance range. |
232
+ | ` check_position() ` | Verifies the current position of the FarmBot is within the specified tolerance range. |
229
233
230
234
### peripherals.py
231
235
232
236
| class ` Peripherals() ` | Description |
233
237
| :--- | :--- |
234
238
| ` control_servo() ` | Set servo angle between 0-100 degrees. |
235
- | ` control_peripheral() ` | Set peripheral value (ON/OFF or slider value from 0-255) and mode (digital or analog ). |
236
- | ` toggle_peripheral() ` | Toggles the state of a specific peripheral between 'on ' (100%) and 'off ' (0%). |
237
- | ` on() ` | Turns specified peripheral 'on ' (100%). |
238
- | ` off() ` | Turns specified peripheral 'off ' (0%). |
239
+ | ` control_peripheral() ` | Set peripheral value (digital ON/OFF or analog value from 0-255). |
240
+ | ` toggle_peripheral() ` | Toggles the state of a specific peripheral between 'ON ' (100%) and 'OFF ' (0%). |
241
+ | ` on() ` | Turns specified peripheral 'ON ' (100%). |
242
+ | ` off() ` | Turns specified peripheral 'OFF ' (0%). |
239
243
240
244
### resources.py
241
245
242
246
| class ` Resources() ` | Description |
243
247
| :--- | :--- |
244
- | ` sequence() ` | Executes a predefined sequence. |
245
- | ` get_seed_tray_cell() ` | Identifies and returns the location of specified cell in the seed tray. |
248
+ | ` sequence() ` | Executes a predefined sequence by id . |
249
+ | ` get_seed_tray_cell() ` | Returns the coordinates of the specified cell in a seed tray. |
246
250
| ` detect_weeds() ` | Scans the garden to detect weeds. |
247
251
| ` lua() ` | Executes custom Lua code snippets to perform complex tasks or automations. |
248
252
| ` if_statement() ` | Performs conditional check and executes actions based on the outcome. |
@@ -253,9 +257,9 @@ sidecar-starter-pack/
253
257
254
258
| class ` ToolControls() ` | Description |
255
259
| :--- | :--- |
256
- | ` mount_tool() ` | Mounts the given tool and pulls it out of assigned slot. |
257
- | ` dismount_tool() ` | Dismounts the currently mounted tool into assigned slot. |
258
- | ` water() ` | Moves to and waters plant based on age and assigned watering curve. |
260
+ | ` mount_tool() ` | Mounts the given tool and pulls it out of its assigned slot. |
261
+ | ` dismount_tool() ` | Dismounts the currently mounted tool into its assigned slot. |
262
+ | ` water() ` | Moves to and waters a plant based on its age and assigned watering curve. |
259
263
| ` dispense() ` | Dispenses user-defined amount of liquid in milliliters. |
260
264
<!-- - | `verify_tool()` | Verifies if tool is mounted to UTM via tool verification pin and MOUNTED TOOL field in FarmBot’s state tree. | --->
261
265
@@ -280,3 +284,12 @@ message = {
280
284
]
281
285
}
282
286
```
287
+
288
+ ### Local development
289
+
290
+ If you are working on the sidecar-starter-pack itself, ensure any changes pass all tests before submitting a pull request.
291
+
292
+ ```
293
+ python -m pip install coverage
294
+ coverage run -m unittest discover
295
+ ```
0 commit comments