Recipes

Let Things5 read, write and delete the recipes stored on the device.

Things5 platform syncs all recipes available on the device once. So that when a user on things5 needs to get a recipe can do so even if the device is offline.
To do so things5 sends both a Read recipes request and a List recipes request.

If your hardware has very limited hardware resources and cannot send all recipes at once subscribe to list recipes request and ignore read recipes request. Things5 will send a separate Read recipe request for each recipe id provided.
Choose this method also if there are a lot of recipes since the mqtt payload cannot be over 128KB

Otherwise subscribe to Read recipes request and send all device recipes as a response.

When the user creates/edits a recipe things5 sends a write recipe request This request is expected to write the edited/new recipe on the device without touching the other recipes on the device.

NOTE: to support legacy apis things5 also sends a write recipes request when creating/editing a recipe. Please ignore it.

There are 11 topics:

Subscribe

Publish

Recipe structure

nametypedescriptionexample
idstringrecipe id. Can be any unique string. If present update the recipe, otherwise create a new recipe"83412jnjasdlfnha1234"
can_be_editedboolean
can_be_deletedboolean
namestringrecipe name"Pollo con patate"
descriptionstringrecipe description
indexintegerthe recipe index starting from 0. Can be used by device to order the recipes.
phasesobjects arrayan array of objects with a values property that lists each variable name, value and type. Values type can be integer, float, string, boolean. Dosages is optional. dosages type can be integer or float[ { "values": [ { "name": "tim", "value": "5", "type": "integer" }, { "name": "wrk", "value": "PREPARATION", "type": "string" }, { "name": "s1", "value": "0", "type": "integer" }, { "name": "s2", "value": "0", "type": "integer" }, { "name": "tmp", "value": "0", "type": "integer" } ], "dosages": [ { "name": "2", "unit": "g", "quantity": "10000", "type": "integer", "metadata": [{ "name": "wait", "value": "0", "type": "integer" }] } ] }, { "values": [ { "name": "tim", "value": "480", "type": "integer" }, { "name": "wrk", "value": "V1", "type": "string" }, { "name": "s1", "value": "0", "type": "integer" }, { "name": "s2", "value": "0", "type": "integer" }, { "name": "tmp", "value": "0", "type": "integer" } ], "dosages": [] } ]
metadataobjectCustom attributes. Type can be integer, float, string, boolean[ { "name": "max_t", "value": "0", "type": "integer" }, { "name": "weight", "value": "16830", "type": "integer" }, { "name": "pieces", "value": "48", "type": "integer" } ]
TopicDirection
things5-production/v1/devices/{device_id}/cmd/read_recipes_reqThings5 → device
things5-production/v1/devices/{device_id}/cmd/read_recipes_resDevice → Things5
things5-production/v1/devices/{device_id}/cmd/list_recipes_reqThings5 → device
things5-production/v1/devices/{device_id}/cmd/list_recipes_resDevice → Things5
things5-production/v1/devices/{device_id}/cmd/read_recipe_reqThings5 → device
things5-production/v1/devices/{device_id}/cmd/read_recipe_resDevice → Things5
things5-production/v1/devices/{device_id}/cmd/write_recipe_reqThings5 → device
things5-production/v1/devices/{device_id}/cmd/write_recipe_resDevice → Things5
things5-production/v1/devices/{device_id}/cmd/delete_recipe_reqThings5 → device
things5-production/v1/devices/{device_id}/cmd/delete_recipe_resDevice → Things5
things5-production/v1/devices/{device_id}/event/recipes_updated_manuallyDevice → Things5

Things5 → device: cmd/read_recipes_req

Subscribe to this topic to receive read recipes requests.
Publish on write recipes response to send the requested recipes.

things5-production/v1/devices/<device-id>/cmd/read_recipes_req

Payload

{
  "request_id": "UUID",
  "metadata": {
  	"is_menu": "true",
  	"parent_id": "123"
	}
}

Payload Parameters

typedescriptionexample
request_idthe request id to be sent back by the device when sending the response

Expected response

📘

Response has to be sent into the things5-production/v1/devices/<device-id>/cmd/read_recipes_res topic

Device → Things5: cmd/read_recipes_res

Publish on this topic to send a response for a previous read recipes request.
Response is expected to contain all device recipes.

things5-production/v1/devices/<device-id>/cmd/read_recipes_res

Payload

{
  "request_id": "UUID sent in the request",
  "recipes": [
    {
      "id": "uniqueid",
      "can_be_edited": true,
      "can_be_deleted": false,
      "name": "Pollo con patate al cuore",
      "description": "Recipe description",
      "index": 0,
      "phases": [
        {
          "dosages": [
            {
              "name": "yeast",
              "quantity": "5.5",
              "unit": "g",
              "type": "float",
              "metadata": [
                {
                  "name": "type",
                  "value": "1",
                  "type": "integer"
                },
                {
                  "name": "temperature",
                  "value": "20",
                  "type": "integer"
                }
              ]
            }
          ],

          "values": [
            {
              "name": "evaporator_fan_speed",
              "value": "4",
              "type": "integer"
            },
            {
              "name": "core_temperature",
              "value": "-5",
              "type": "integer"
            },
            {
              "name": "cell_temperature",
              "value": "-20",
              "type": "integer"
            }
          ]
        },
        {
          "values": [
            {
              "name": "evaporator_fan_speed",
              "value": "2",
              "type": "integer"
            },
            {
              "name": "core_temperature",
              "value": "-5",
              "type": "integer"
            },
            {
              "name": "cell_temperature",
              "value": "-20",
              "type": "integer"
            }
          ]
        },
        {
          "values": [
            {
              "name": "evaporator_fan_speed",
              "value": "1",
              "type": "integer"
            },
            {
              "name": "core_temperature",
              "value": "-5",
              "type": "integer"
            },
            {
              "name": "cell_temperature",
              "value": "-20",
              "type": "integer"
            }
          ]
        },
        {
          "values": [
            {
              "name": "evaporator_fan_speed",
              "value": "0",
              "type": "integer"
            },
            {
              "name": "cell_temperature",
              "value": "-10",
              "type": "integer"
            }
          ]
        }
      ],
      "metadata": [
        {
          "name": "image_path",
          "value": "../images/fish.jpg",
          "type": "string"
        },
        {
          "name": "index_in_list",
          "value": "6",
          "type": "integer"
        }
      ]
    }
  ]
}

Things5 → device: cmd/list_recipes_req

This topic is a lightweight alternative of read recipes request. You can find more info in the introduction section.

Subscribe to this topic to receive list recipes requests.
Publish on list recipes response to send the list of recipes ids.

things5-production/v1/devices/<device-id>/cmd/list_recipes_req

Payload

{
  "request_id": "UUID"
}

Payload Parameters

typedescriptionexample
request-idthe request id to be sent back by the device when sending the response

Expected response

: Response has to be sent into the things5-production/v1/devices/<device-id>/cmd/list_recipes_res topic

Device → Things5: cmd/list_recipes_res

Publish on this topic to send a response for a previous read recipes request.
Response is expected to contain all device recipes.

things5-production/v1/devices/<device-id>/cmd/list_recipes_res

Payload

{
  "request_id":"UUID sent in the request",
  "recipes_ids": ["1","2","3"],
  "recipes_names": ["chicken", "fish", "cookies"]
}

Things5 → device: cmd/read_recipe_req

Subscribe to this topic to receive read recipes requests.
Publish on read recipe response to send the requested recipes.

things5-production/v1/devices/<device-id>/cmd/read_recipe_req

Payload

{
  "request_id": "UUID",
  "recipe_id": "123"
}

Payload Parameters

typedescriptionexample
request_idthe request id to be sent back by the device when sending the response
recipe_idthe id of the requested recipe

Expected response

: Response has to be sent into the things5-production/v1/devices/<device-id>/cmd/read_recipe_res topic

Device → Things5: cmd/read_recipe_res

Publish on this topic to send a response for a previous read recipes request.
Response is expected to contain all device recipes.

things5-production/v1/devices/<device-id>/cmd/read_recipe_res

Payload

{
  "request_id": "UUID sent in the request",
  "recipe": {
    "id": "uniqueid",
    "can_be_edited": true,
    "can_be_deleted": false,
    "name": "Pollo con patate al cuore",
    "description": "Recipe description",
    "index": 1,
    "phases": [
      {
        "dosages": 
          [
            {
              "name": "yeast",
              "quantity": "5.5",
              "type": "float",
              "unit": "g",
              "metadata" : [{
                "name": "type",
                "value": "1",
                "type": "integer"
              }, {
                "name": "temperature",
                "value": "20",
                "type": "integer"
              }]
            }
          ],
        
        "values": [
          {
            "name": "evaporator_fan_speed",
            "value": "4",
            "type": "integer"
          },
          {
            "name": "core_temperature",
            "value": "-5",
            "type": "integer"
          },
          {
            "name": "cell_temperature",
            "value": "-20",
            "type": "integer"
          }
        ]
      },
      {
        "values": [
          {
            "name": "evaporator_fan_speed",
            "value": "2",
            "type": "integer"
          },
          {
            "name": "core_temperature",
            "value": "-5",
            "type": "integer"
          },
          {
            "name": "cell_temperature",
            "value": "-20",
            "type": "integer"
          }
        ]
      },
      {
        "values": [
          {
            "name": "evaporator_fan_speed",
            "value": "1",
            "type": "integer"
          },
          {
            "name": "core_temperature",
            "value": "-5",
            "type": "integer"
          },
          {
            "name": "cell_temperature",
            "value": "-20",
            "type": "integer"
          }
        ]
      },
      {
        "values": [
          {
            "name": "evaporator_fan_speed",
            "value": "0",
            "type": "integer"
          },
          {
            "name": "cell_temperature",
            "value": "-10",
            "type": "integer"
          }
        ]
      }
    ],
    "metadata": [
      {
        "name": "image_path",
        "value": "../images/fish.jpg",
        "type": "string"
      },
      {
        "name": "index_in_list",
        "value": "6",
        "type": "integer"
      }
    ]
  }
}

Things5 → device: cmd/write_recipe_req

Subscribe to this topic to accept write recipe requests.
Write a single recipe without changing all the other recipes on the device

things5-production/v1/devices/<device-id>/cmd/write_recipe_req

Payload

{
    "request_id": "UUID sent in the request",
    "recipe": {
      "id": "uniqueid",
      "name": "Pollo con patate al cuore",
      "description": "Recipe description",
      "type": "core",
      "index": 1,
      "phases": [
        {
          "values": [
            {
              "name": "evaporator_fan_speed",
              "value": "4",
              "type": "integer"
            },
            {
              "name": "core_temperature",
              "value": "-5",
              "type": "integer"
            },
            {
              "name": "cell_temperature",
              "value": "-20",
              "type": "integer"
            }
          ]
        },
        {
          "values": [
            {
              "name": "evaporator_fan_speed",
              "value": "2",
              "type": "integer"
            },
            {
              "name": "core_temperature",
              "value": "-5",
              "type": "integer"
            },
            {
              "name": "cell_temperature",
              "value": "-20",
              "type": "integer"
            }
          ]
        },
        {
          "values": [
            {
              "name": "evaporator_fan_speed",
              "value": "1",
              "type": "integer"
            },
            {
              "name": "core_temperature",
              "value": "-5",
              "type": "integer"
            },
            {
              "name": "cell_temperature",
              "value": "-20",
              "type": "integer"
            }
          ]
        },
        {
          "values": [
            {
              "name": "evaporator_fan_speed",
              "value": "0",
              "type": "integer"
            },
            {
              "name": "cell_temperature",
              "value": "-10",
              "type": "integer"
            }
          ]
        }
      ],
      "metadata": [
        { "name": "datetime", "type": "integer", "value": "1715681973" },
        { "name": "origin", "type": "integer", "value": "0" }
      ]
    }
  }

Payload Parameters

namedescriptionexample
request_idthe request id to be sent back by the device when sending the response
recipeslist of recipes to write

Recipe type

namerequired
idfalse
nametrue
descriptionfalse
typefalse
phasestrue
metadatafalse

📘

Response has to be sent into the write recipe response:

Device → Things5: cmd/write_recipe_res

Publish on this topic to send a response for a previous write recipee request.
Response must contain the written recipe.

things5-production/v1/devices/<device-id>/cmd/write_recipe_res

Payload

{
  "request_id": "UUID sent in the request",
  "errors": ["errors if any"],
  "recipe": {
    "id": "uniqueid",
    "can_be_edited": true,
    "can_be_deleted": false,
    "name": "Pollo con patate al cuore",
    "description": "Recipe description",
    "index": 1,
    "phases": [
      {
        "dosages": 
          [
            {
              "name": "yeast",
              "quantity": "5.5",
              "type": "float",
              "unit": "g",
              "metadata" : [{
                "name": "type",
                "value": "1",
                "type": "integer"
              }, {
                "name": "temperature",
                "value": "20",
                "type": "integer"
              }]
            }
          ],
        
        "values": [
          {
            "name": "evaporator_fan_speed",
            "value": "4",
            "type": "integer"
          },
          {
            "name": "core_temperature",
            "value": "-5",
            "type": "integer"
          },
          {
            "name": "cell_temperature",
            "value": "-20",
            "type": "integer"
          }
        ]
      },
      {
        "values": [
          {
            "name": "evaporator_fan_speed",
            "value": "2",
            "type": "integer"
          },
          {
            "name": "core_temperature",
            "value": "-5",
            "type": "integer"
          },
          {
            "name": "cell_temperature",
            "value": "-20",
            "type": "integer"
          }
        ]
      },
      {
        "values": [
          {
            "name": "evaporator_fan_speed",
            "value": "1",
            "type": "integer"
          },
          {
            "name": "core_temperature",
            "value": "-5",
            "type": "integer"
          },
          {
            "name": "cell_temperature",
            "value": "-20",
            "type": "integer"
          }
        ]
      },
      {
        "values": [
          {
            "name": "evaporator_fan_speed",
            "value": "0",
            "type": "integer"
          },
          {
            "name": "cell_temperature",
            "value": "-10",
            "type": "integer"
          }
        ]
      }
    ],
    "metadata": [
      {
        "name": "image_path",
        "value": "../images/fish.jpg",
        "type": "string"
      },
      {
        "name": "index_in_list",
        "value": "6",
        "type": "integer"
      }
    ]
  }
}

Things5 → device: cmd/delete_recipe_req

Subscribe to this topic to accept delete recipe requests.
Delete a single recipe.

things5-production/v1/devices/<device-id>/cmd/delete_recipe_req

Payload

{
  "request_id": "UUID sent in the request",
  "recipe_id": "recipe unique id" 
}

Payload Parameters

namedescriptionexamplerequired
request_idthe request id to be sent back by the device when sending the response
recipe_idstring. the recipe unique idtrue

: Response has to be sent into the delete recipe response

Device → Things5: cmd/delete_recipe_res

Publish on this topic to send a response for a previous delete recipe request.

things5-production/v1/devices/<device-id>/cmd/delete_recipe_res

Payload

{
  "request_id": "UUID sent in the request",
  "recipe_id": "id of the recipe",
  "errors": ["errors if any"]
}

Device → Things5: event/recipes_updated_manually

Publish on this topic when recipes are updated manually on a device.

When recipes are changed directly on a machine publish an empty message on this topic to notify Things5 of the changes.

things5-production/v1/devices/<device-id>/event/recipes_updated_manually

Legacy messages

To support older devices Things5 can also send cmd/write_recipes_req (replace all recipes). New devices can ignore it and answer cmd/write_recipe_req only.