The .lotnb Format
LoT Notebook files use the.lotnb extension and follow a JSON-based structure compatible with VS Code’s notebook API. Each file contains an array of cells—documentation and code blocks that make up your notebook.
You don’t need to edit the JSON directly. VS Code’s notebook interface handles the structure automatically. This page is for understanding what’s happening under the hood.
File Structure
A.lotnb file is a JSON array where each element represents a cell:
Cell Properties
Each cell has three required properties:| Property | Type | Description |
|---|---|---|
kind | integer | Cell type: 1 = Markdown, 2 = Code |
language | string | Cell language: "markdown", "lot", or "python" |
value | string | Cell content (use \n for line breaks) |
Kind Values
| Kind | Type | Purpose |
|---|---|---|
1 | Markdown | Documentation, explanations, headers |
2 | Code | Executable LoT or Python code |
Language Values
| Language | Cell Kind | Description |
|---|---|---|
markdown | 1 | Rich text documentation |
lot | 2 | LoT definitions (Actions, Models, Routes, Rules) |
python | 2 | Python scripts for broker execution |
Cell Types in Detail
Markdown Cells
Markdown cells support standard Markdown syntax plus some extensions:- Headers (
#,##,###) - Bold, italic, code formatting
- Bullet and numbered lists
- Tables
- Code blocks (for examples, not execution)
- Links and images
LoT Code Cells
LoT cells contain executable Language of Things definitions:| Definition | Syntax |
|---|---|
| Action | DEFINE ACTION ActionName |
| Model | DEFINE MODEL ModelName WITH TOPIC "..." |
| Route | DEFINE ROUTE RouteName WITH TYPE ... |
| Rule | DEFINE RULE RuleName |
Python Cells
Python cells contain scripts that run inside the broker when called from LoT:Creating a New Notebook
Method 1: VS Code Interface
- Create a new file with
.lotnbextension - VS Code automatically opens it in notebook mode
- Use the + Code and + Markdown buttons to add cells
- Select cell language from the dropdown (lot, python, markdown)
Method 2: Manual Creation
Create a file with minimal JSON structure:.lotnb extension and open in VS Code.
Example: Complete Notebook
Here’s a full example showing all cell types working together:Best Practices
Use descriptive markdown headers
Use descriptive markdown headers
Start notebooks with a title and overview. Use headers to organize sections logically.
One definition per code cell
One definition per code cell
Keep each Action, Model, Route, or Rule in its own cell. This makes debugging and selective execution easier.
Document before you code
Document before you code
Write a markdown cell explaining what the next code cell does before writing the code. This helps you think through the logic.
Use consistent naming
Use consistent naming
Follow a naming convention for your Actions, Models, and Python scripts. Example:
SensorTemperatureMonitor, ProductionPartCounter.Troubleshooting
File won't open as notebook?
File won't open as notebook?
- Verify the file has
.lotnbextension (not.lotnb.json) - Check that the LoT Notebooks extension is installed
- Ensure the file contains valid JSON (use a JSON validator)
JSON syntax errors?
JSON syntax errors?
Common issues:
- Missing commas between cells
- Unescaped quotes in
valuestrings (use\") - Unescaped newlines (use
\n) - Missing closing brackets
Cell showing wrong language?
Cell showing wrong language?
Check the
language property matches the content type. VS Code should auto-detect, but you can manually switch using the language selector in the cell toolbar.
