VegeHub API

The vegehubs can act as web servers is when they are awake. You can control them, and retrieve their data through this API. Since they need to be awake, they should be connected to mains power, or a solar panel, rather than batteries. This gives full control over the hub, so be careful when using these commands. If you brick a hub, you'll be responsible for the associated shipping costs to and from Vegetronix - for us to fix it. Also make sure that your local network is 100% secure as these are not encrypted with TLS (https:).

POSTs

  • /api/server/query - This is to test connecting to an external server API and returns the value retrieved. Send it JSON that contains "webCondUrl":(the target URL) and "webCondKey":(the key that leads to where the desired data is), and it will attempt to connect to that URL, and return the retrieved data. If it succeeds, it will return the value as json, if it fails, it will return "Failed to parse". Example: {"webCondUrl":"http://192.168.0.21:5100/btc_t", "webCondKey":"\"value\""}.
  • /api/wifi/reconnect - Just disconnects and reconnects the Hub's WiFi. Pass in a JSON object with the systems that you would like it to reconnect. For example: {"ap":[], "wifi":[]}. Leave off any you don’t want to restart.
  • /api/config/set - Sets the whole configuration at once. You must provide the entire top-level object to make changes, or the object will be removed. Top-level objects: api_key, route_key, id, mac, updated, who_updated, hub, sensors, actuators, web_conditions, wifi, special.
  • /api/config/get - Returns requested top-level objects of the config. Pass an object like {hub:[], sensors:[], special:[]} to retrieve them.
  • /api/info/get - Returns runtime information like time or hub status. Pass empty JSON objects to specify which parts you want. Example: {hub:[], sensors:[], actuators:[]}.
  • /api/time/set - Set the system time. Pass {"epoch":233431200}.
  • /api/certificate/delete - Delete a certificate. Pass {"delete_target":"filename"}.
  • /api/certificate/upload - Uploads a certificate. Include a header called X-Filename with the desired name and send the file in the body.
  • /api/server/test - Test an update server. Pass JSON like {"type":3, "api_key":"TestHub", "route":"", "headers":"", "url":"http://192.168.0.21:5000"}.
  • /api/actuators/override - Schedule a relay command. JSON must include id, chan, command, duration, start_time.
  • /api/firmware/temp_url - Attempt firmware upgrade from temporary URL. Pass {"firmware_url":"your_url_here"}.
  • /api/sensors/data - Request data from a specific sensor channel. Example: {"chan":0,"count":5}.
  • /api/actuators/set - Set an actuator state for a duration. Example: {"target":0, "duration":60, "state":1}.
  • /api/program/execute - Execute a sprinkler program. Pass {"target":0}.

GETs

  • /api/hub/info - Returns identifying info for the hub. Example: {"error":"success","model":"VG-HUB4S-1R","fw_version":"4.2.0","hw_revision":"D2","num_sensors":4,"num_actuators":1}.
  • /api/log - Returns the last 50 log entries (stored in volatile memory).
  • /api/netscan - Returns nearby WiFi networks (takes ~10-15 seconds).
  • /api/certificate/list - Lists all stored root certificates.
  • /api/firmware/check - Checks the firmware version against the server. Example: {"firmware_status":2,"old_version":"4.0.0","new_version":"0.19.0"}.
  • /api/firmware/upgrade - Attempts to upgrade firmware using the stored URL.
  • /api/update/send - Sends an update. Always replies with success; check /api/info/get for result.
  • /api/sample/start - Starts sensor sampling routine.
  • /api/sensors/data/last - Returns latest sensor readings. Example: {"samples": ["chan_1": 1.648,"chan_2": 1.648,"chan_3": 1.648,"chan_4": 1.648]}.
  • /api/battery/get - Returns battery voltage. Example: {"error":"success", "batt_v":8.23}.
  • /api/actuators/status - Returns the current state of actuators. Example: {"actuators":[{"slot":0,"state":0,"last_run":0, "next_window_start":1713466800,"next_window_end":1713467400,"cur_ma":0,"typ_ma":0,"error":0}],"error":"success"}.
  • /api/actuators/all_off - Immediately turns off all actuators.