Multiple farmbots for 1 account

In the version 7 documentation https://software.farm.bot/v7/docs/account-limitations it states:

While you technically can pair multiple devices to one account, we do not officially support this and it may result in unexpected behavior

Is this a constraint in v9 and if so what might cause the unexpected behavior?

Hmmm. I was wondering how to manage my second and third farmbots when I get them.

It would be great to be able to share sequences between accounts, too.

@whitecaps

That is no longer the case and there are far too many assumptions baked into the application to allow for this. Adding multi-device setups (or “workspaces”) will require a substantial effort on our part. It is on our roadmap, however. This is going to become a focus after we finish a few higher priority features, such as random move_abs commands and the ability to use variables in the MARK AS step.

An important clarification: there has never been a point where multi-device setups were useful or stable in the post-v1.2 era. The feature half-existed at one point (which I will describe later for historical reasons). The comment you read was mostly intended for curious developers that may have noticed our DB schema (Users <=> Device) is a one-to-many relation despite presenting a one-to-one relation in the UI.

A bit of a historical note might help clarify:

In 2013, before FarmBot was a company selling kits to the public, it was a side project for me.

There were less than 10 FarmBots in the world during this period.

At this point in our history, the sequence editor was essentially just a form with basic actions.

There were no groups, no sequence variables, no regimens and Farm Events were a brand new feature.

We began work on OpenFarm around this time but it had no integration with the FarmBot Web App.

During this time, I added a dropdown to the nav bar to allow the user to switch between multiple devices.

It was useful for simple things like testing RPCs against multiple devices or that sort of thing, but suffered from a variety of problems.

For example, the device would share all the same points (and garden).

Due to the numerous problems and the fact that we were building FarmBot as a tool for personal use, we decided to just dump the feature and focus on single-user setups to save time and reduce the number of edge-cases the device would have. We couldn’t have imagined how popular FarmBot would become at schools and how many customers have purchased a second or third device for their gardens. In this case, hindsight truly is 20/20.

Hopefully that helps shed some light on the comments you will find in very old documents and hopefully the comments don’t leave anyone with the impression that multi-device setups were fully functional at any point in the lifetime of the project.

2 Likes

Thanks @RickCarlino so to enable multiple Farmbots would changes need to be made to all levels of the stack not just the WebApp but the FBOS etc as well?

@whitecaps

changes need to be made to all levels of the stack not just the WebApp but the FBOS etc as well?

The short answer is that you are correct, it will require a lot of changes. Since we will need to work on this feature soon, and because you’ve asked, I will outline a possible solution.

Changes Required for Multi-Device Accounts

New “Farm” Resource

Since we plan to support multiple users (schools) and multiple devices (businesses / power users), we will add a “farm” resource which is essentially the same thing as a “workspace” or “project” seen in numerous commercial software products such as Trello or Github.

  • We could have named it “garden”, but I worry it will confuse third party developers because the name is too similar to the saved_gardens resource.
  • For legacy reasons, every farm will need a default_device that cannot be empty. This will be necessary for legacy FBOS versions that do not understand what a “farm” is.
  • A farm will have many (at least one) devices
  • A farm will have many (at least one) users

FBJS Changes

Currently, the MQTT channel is structured as follows:

bot/DEVICE_ID_HERE/from_clients: This channel will receive inbound RPC requests that the device must process.
bot/DEVICE_ID_HERE/from_device: Responses to inbound RPC requests will be sent back to clients from this channel.
bot/DEVICE_ID_HERE/status: The bot's "state tree" is constantly updated on this channel. This will include information such as the X/Y/Z coordinates and the bot's sync status.
bot/DEVICE_ID_HERE/logs: Logs intended to be read by humans are sent here. This is identical to the "ticker" seen in the web app.

The good news is that the MQTT channel structure already incorporates a device_id, so controlling multiple devices is just a matter of adding more pub/sub pathways. Minimal changes would be needed for the AMQP/MQTT adapter.

For the Web App, a substantial effort will be required, as the entire application was built on the assumption that there is only one device.

Examples:

  • Status of the “SYNC NOW” button
  • Garden rendering (needs to render the bed / plants for the current device, not all devices)
  • Internal helper functions such as currentDevice() will need to be reworked.

Schema Changes

Probably OK- The following resources will most likely not need any changes.

  • farm_events
  • fbos_config
  • firmware_config
  • peripherals
  • images
  • pin_bindings
  • sensor_readings
  • sensors
  • tools

Will Require Schema Updates

The following resource will need to replace the device_id with a farm_id.
Supporting old FBOS versions and migrating the data may be tricky.

  • sequences
  • regimens
  • plant_templates
  • tokens
  • webcam_feeds

Not Sure

  • web_app_config - Probably need to be managed at the user level, not the “farm” level.
  • farmware_envs - Easiest implementation would be to handle this at the farm level, but different devices probably need different ENV settings. This could get repetitive.
  • point_groups

Auth System

Because we have had a one-to-one mapping of users and devices, a large chunk of the authentication / token system will need to be reworked to perform checks based on a user_id or farm_id.

User Experience

Adding multi user / device setups will cause many changes in the UI. I will focus only on the essential ones.

  • Ability to pick the current “farm”. Example: A FarmBot user that has a work device at school and a personal device at home.
  • Ability to pick the current device once logged into the appropriate farm.

Mark As Step

There are a couple places where the system disregarded the device_id. There may be legacy resources that are using junk values (such as 0) for the device_id.

2 Likes