Smart Site
Home Docs Smart Data Template Management

Template Management

The Template module lets you define reusable device profiles. A template bundles a protocol configuration, a set of tag definitions, and collection parameters, so that adding a new device of the same model is a one-click operation instead of manual tag entry.

Interface Screenshot

Device Template Management (English UI)

Captured from the live Smart Site system with the English UI. See the zh-CN counterpart for the Chinese-UI screenshot.

1. Core Concepts

A Device Template contains:

  • Protocol config — connection defaults (port, slave ID, OPC UA endpoint, MQTT broker, etc.)
  • Tag definitions — name, address, data type, scale, deadband, access mode
  • Collection params — default scan rate, batch size, retry policy
  • Category — industry grouping for organization
  • Metadata — manufacturer, model, version

Templates are stored as JSON files under ss-run/ss/data/templates/{lang}/ and indexed by an index.json file, so they can be edited offline and version-controlled.

2. Template Categories

Templates are grouped into five industry categories:

Category Typical Devices
Industrial Automation PLCs (Siemens S7-1200), DCS (supcon ECS700), RTU
Energy & Power PV inverters (Sungrow), energy meters
Environmental Monitoring Temperature/humidity sensors
Smart Water Water supply pipeline monitors
IoT & Edge Computing Industrial gateways

Each category has subfolders (e.g. PLC Controllers, PV Inverters) and the index.json file lists every template with its display name, path, and metadata.

3. Functional Areas

3.1 Template List

  • Browse by category in the System → Templates page
  • Search by name, manufacturer, or model
  • Filter by protocol (Modbus / OPC UA / MQTT / S7)

3.2 Template Editor

  • Edit protocol defaults (e.g. default Modbus TCP port 502)
  • Add / edit / remove tag definitions
  • Define each tag's address, data type, scale/offset, deadband, and access mode
  • Set default scan rate and retry count

3.3 Template Import / Export (JSON)

Templates can be exchanged as JSON files:

  • Export — download a template as a .json file
  • Import — upload a JSON file to register a new template

The JSON schema mirrors the on-disk template structure, so files copied into data/templates/{lang}/ are discovered on the next reload.

Example structure:

{
  "name": "Siemens S7-1200",
  "protocol": "s7",
  "category": "Industrial Automation/PLC Controllers",
  "connection": { "rack": 0, "slot": 1, "port": 102 },
  "tags": [
    { "name": "Temperature", "address": "DB1.DBX0.0", "dataType": "float32", "access": "ro" }
  ]
}

3.4 Applying a Template to a Device

  1. Open the device detail page
  2. Click Apply Template
  3. Pick a template from the dialog
  4. The template's tags are merged into the device; existing tags with the same address are updated, others are kept
  5. Adjust per-device addresses (e.g. change the Modbus slave ID)

4. Built-in Templates

The system ships with several ready-to-use templates in both en-US and zh-CN:

Template Protocol Category
siemens-s7-1200 S7 Industrial Automation / PLC
supcon-ecs700 Modbus Industrial Automation / DCS
generic-rtu-modbus Modbus Industrial Automation / RTU
sungrow-inverter Modbus Energy & Power / PV Inverters
three-phase-meter Modbus Energy & Power / Energy Metering
humidity Modbus Environmental Monitoring
water-supply-pipeline Modbus Smart Water / Water Supply
iot-edge-gateway MQTT IoT & Edge Computing

5. FAQ

Q: My imported template does not appear in the list. A: The JSON must be placed under the correct language folder (data/templates/en-US/...) and listed in that folder's index.json. Restart the backend or trigger a template reload so the index is re-read.

Q: Applying a template overwrote my custom tags. A: The merge updates tags whose address matches a template tag. To keep custom tags, give them a unique address before applying the template, or duplicate the device first.

Q: Can a template support multiple protocols? A: No. One template maps to exactly one protocol. For a device that speaks two protocols, create two devices and apply a template to each.

Q: How do I share templates between projects? A: Export the template JSON and import it into the target installation, or copy the file into the target's data/templates/{lang}/ folder and update index.json.

  • ../../03-device/README.md
  • ../../03-device/device-detail.md
  • Templates Directory
  • ../../08-protocol/README.md