Proposed CSV upload format
This is a proposed format for bulk uploading sensors. To be vetted and verified with Ensemble folks.
Sensor | Name | Latitude | Longitude | Reading_types | External_ID | Depth | Brand | Model |
---|---|---|---|---|---|---|---|---|
Description | How the sensor will be labelled in LiteFarm. | The latitude for the sensor. | The longitude for the sensor. | Comma delimited list of sensor reading types. Valid values are:
| The sensor’s unique external id. This is the identity that will be used to register the sensor with external services and receive readings associated with this sensor. | Assumed to be in cm, only 1 depth per sensor. | The brand of sensor. | The model of sensor. |
Data type | String | Decimal | Decimal | Specific strings | String | Decimal | String | String |
Required? | Required | Required | Required | Required | Optional | Optional | Optional | Optional |
Example | “Sensor 1” | -31.3624425 | -64.2104754448 | soil_water_potential, temperature | “WERKTX” | 10 | “Ensemble Scientific” | “Model ABC” |
Upload Validation | 1 <= name.length <= 100 | -90 <= lat <= 90 | -180 <= long <= 180 | At least 1 of the following:
| 1 <= id.length <= 40 | 0 <= depth <= 1000 | String: < 100 length | String: < 100 length |
Error | “Invalid sensor name, must be between 1 and 100 characters” | “Invalid latitude value, must be between -90 and 90. and fewer than 10 decimals” | “Invalid longitude value, must be between -180 and 180. and fewer than 10 decimals” | “Invalid reading type detected, valid values include:
| “Sensor with external id: <id> already exists.” “Invalid external id, must be between 1 and 20 characters” | “Invalid depth, must be a decimal value between 0 and 1000.” | “Invalid brand, must be fewer than 100 characters.” | “Invalid model, must be fewer than 100 characters.” |
Notes | May need to group sensors with same / similar lat / long on the map. This should be default behaviour since sensors are points. For this project depths can be 10, 20, 30, 50. | If this is “Ensemble Scientific”, it should activate the need to register this sensor during the bulk creation endpoint. |
Definition of a sensor: A device with a single id, name, lat / long, and depth. Must have at least one reading parameter, but may have several. Optionally has a brand and model.
Validation should be performed via the API and through the UI during bulk upload as well.
Architectural guidance
As of May 2023, sensors have the following tables that support their operations:
farm_external_integration: Mapping of how LiteFarm and external partners refer to the same
farm.integrating_partner: Sensor companies LiteFarm integrates with. Currently “0” for non-supported and “1” “Ensemble Scientific”.
partner_reading_type: The types of sensor readings supported by each integrating partner.
sensor_reading_type: A junction table holding a reference to the sensor (location), partner reading type, and sensor reading type. For a sensor with multiple reading types, multiple entries will exist.
sensor: The attributes describing the physical device and it’s location that aren’t held in the location table.
sensor_reading: Readings from the sensor.
farm_external_integration | farm_id | partner_id | organization_uuid | webhook_id |
---|---|---|---|---|
Description | Foreign key to farm table. | Foreign key to integrating_partner table. | The integrating partner’s UUID for the same farm. | The webhook for the integrating partner to provide updates to this farm specifically. Incrementing integer |
Required? | Yes; LiteFarm generated | Yes | Yes | No |
Example | “d58e64d2-f72e-11ec-a4f4-0242ac120003” | “f42cde0d-7c14-4a1d-8eab-c367ce8cfe16” | 174 | |
Notes |
integrating_partner | partner_id | partner_name | access_token | refresh_token | root_url | deactivated |
---|---|---|---|---|---|---|
Description | Incrementing integer representing the unique identifier for this partner. | The name of the integrating partner | Access token passed to the foreign API when communicating. | Access token passed to the foreign API to renew the access token if it has expired. | Root URL to prefix all communication with this integrating partner | |
Required? | Yes; set by LiteFarm | Yes | No | No | No | Yes |
Example | 0 | “Ensemble Scientific” | FALSE | |||
Notes | Currently “0” for non-supported and “1” “Ensemble Scientific”. |
partner_reading_type | partner_reading_type_id | partner_id | raw_value | readable_value |
---|---|---|---|---|
Description | UUID | Foreign key to integrating_partner table | Not sure | Supported reading type for this partner. |
Required? | Yes; LiteFarm generated | Yes | No | Yes |
Example | “d58e64d2-f72e-11ec-a4f4-0242ac120003” | “0” | ||
Notes | Could be how the reading_type is represented from the partner, if for example there is a difference between that value and how the user uploads the sensor csv - e.g. “temp” vs. “temperature”. | For MVP, supported values are temperature and soil_water_potential. |
sensor_reading_type | sensor_reading_type_id | partner_reading_type_id | location_id |
---|---|---|---|
Description | UUID | UUID | UUID |
Required? | Yes; LiteFarm generated | Yes; LiteFarm generated | Yes; LiteFarm generated |
Example | “d58e64d2-f72e-11ec-a4f4-0242ac120003” | “d58e64d2-f72e-11ec-a4f4-0242ac120003” | “d58e64d2-f72e-11ec-a4f4-0242ac120003” |
Notes |
sensor | location_id | partner_id | external_id | Depth | Elevation | Model | Depth_unit |
---|---|---|---|---|---|---|---|
Description | The location associated with this sensor. | Linkage to the integrating_partner table. | The unique identifier with the integrating partner for this particular sensor. | Assumed to be in cm, comma delimited if multiple depths. | The elevation of ground level at the location where the sensor is mounted. | The model of the sensor. | The depth of the sensor. |
Required? | Connection is LiteFarm generated | Connection is LiteFarm generated | Required | Optional | Optional | LiteFarm generated | LiteFarm generated |
Example | 0 | “WERKTX” | “cm” | ||||
Notes | Note that the name, lat / long, and other physical attributes are held in the location table. | At time of writing “0” for “All others” and 1 for “Ensemble Scientific”. | Not implemented in MVP. | Not implemented in MVP. | Always “cm”. |
Sensor_reading | reading_id | location_id | Read_time | created_at | reading_type | value | unit | valid |
---|---|---|---|---|---|---|---|---|
Description | A unique identifier for this reading. | The location that represents the sensor that created this reading. | The timestamp when this reading was captured on the integrated device. | The timestamp when this reading was created in the LiteFarm database. | The reading type which (should) corresponds with a partner_reading_type | The numerical value of the reading. | The unit that when combined with the value represents the reading. | Boolean value on whether this reading has passed some sort of external QA process. |
Required? | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Example | “ce7c5f2c-c77c-11ed-86ec-0242ac120002” | “2ec78a8a-a993-11ed-ac8f-0242ac120002” | 2023-03-20 23:55:21.739103+00 | 2023-03-21 00:10:37.243388+00 | “temperature” | 20.191444 | “Celsius” | FALSE |
Notes | Why doesn’t this reference a partner_reading_type? |
Questions:
Requirements
- LF-2338Getting issue details... STATUS
Summary | Description | Fix Version |
---|---|---|
Sensor model work | Build out database to support tables for:
| MVP |
Bulk sensor upload | MVP | |
Individual sensor upload | TBD | |
Upload screen with template and front-end validation | MVP | |
Bulk sensor creation and outcome splash | MVP | |
Support for soil_water_content reading_type | This is a derived value that can be calculated based on the soil texture and soil water potential. | V1 |
Support for multiple depths within 1 sensor | V1 |
Future enhancements
Support for ‘soil_water_content’ reading type. This is a derived value that can be calculated based on the soil texture and soil water potential.
Approach for appropriately clustering sensors that have the same lat / long but different depths. Potential approaches:
Only display 1 sensor and have readings tab show selector for which depths should be shown (We would need to allow duplicates of the same external id to enable this).
To investigate
Ensemble requires a part_number and hardware_version to register it with their service.