Skip to content

Referring to a Tag Everywhere ​

Last updated

Every place in Scada.Ink addresses a tag as device + tag path, but they differ in whether the device can be given by name, and whether there's a picker. Get the device id from the device page URL (/devices/3 is device 3) or the Devices list.

Warning: Device ids differ between appliances. A dashboard, script or page copied to another appliance must be re-pointed unless it looks devices up by name.

Quick reference ​

WhereHow you choose the tagDevice given asExample
Dashboard widget bindingTag source → Select tag → Browse Tags pickerPicked (stored as id)Picker: CNC Mill 1 → Spindle/Speed
<scada-widget> shortcode in a custom pageTyped attributeNumeric id onlybind-value="tag:3/Spindle/Speed"
Custom page JavaScriptscadaink.subscribe(id, path, cb), scadaink.read(id, path)Numeric id only; a name never receives updatesscadaink.subscribe(3, 'Spindle/Speed', v => …)
Scripttags.read(device, path)Number, or device name as a string (case-insensitive)tags.read('CNC Mill 1', 'Spindle/Speed')
Script local writetags.write(path, value)Always the Local Tags devicetags.write('line1/count', 5)
Script device writetags.writeDevice(device, path, value)Number or nametags.writeDevice(3, 'Spindle/Override', 90)
Script trigger (Tag Change, Tag Threshold)Device ID box + Tag PathNumeric id typed inDevice ID 3, Tag Path Spindle/Speed
Workflow nodes (Tag Change, Tag Value, Read Tag, Set Tag)Device picker + Tag Path pickerPicked; choosing a tag also sets the device—
Ladder logicDevice Tag operand → BrowsePicked; shows Device #3 / Line1/Speed—
Alarm ruleDevice (required) then Tag (required)Picked; subscribed tags only—
Expression tag{deviceId:tagPath}Numeric id only{3:Spindle/Speed}
Script expression.eval(){name:path}Device name only{CNC Mill 1:Spindle/Speed}
Public Data APItags= queryId or name/api/data/history.json?tags=3:Spindle/Speed&start=-1h
REST APIJSON body / pathNumeric idPOST /api/tags/write { "deviceId": 3, "tagPath": "…", "value": 90 }

What the pickers list ​

The tag picker used by dashboards, workflows, ladder and the script Tag Snippet (title Browse Tags, search Search tags, devices, UDTs...) lists:

  • Devices: every enabled device with its enabled subscriptions, Local Tags first, then Expression Tags (every enabled expression tag, device 0, path Expression/<name>) when the Expression Tags feature is licensed;
  • Tag UDTs: each UDT's instances and their fields.

It does not list disabled tags, disabled expression tags, tags on disabled devices, or tags the device offers but you haven't subscribed. For those, subscribe first, or type the reference where a text form exists (scripts, custom pages, shortcodes).

Tips for portable references ​

  • Scripts: use names. const cnc = devices.find('CNC Mill 1'); returns the id or null; devices.localId() returns the Local Tags device id. A string of digits like '3' is treated as a name, so pass numbers as numbers.
  • Custom pages: look the id up at load time:
javascript
scadaink.devices.find('CNC Mill 1').then(function (id) {
  if (id == null) return;
  scadaink.subscribe(id, 'Spindle/Speed', function (value) {
    document.getElementById('rpm').textContent = value;
  });
});
  • Local tags in custom pages: scadaink.devices.localId() gives the id for subscribe; scadaink.write(path, value) needs no id.
  • Templates: bind template widgets to parameters instead of fixed tags, so each placement picks its own device (see Template Parameters).

Tag values in each place ​

  • Scripts and custom pages get the cached value as a string, or undefined if no value has arrived yet.
  • Workflow Read Tag reads the cached value; it does not poll the device.
  • Alarm rules and Tag Value workflow triggers compare numbers; true/false count as 1/0 and other text is ignored.
  • Dashboards convert values for display according to the widget.

See Script API Reference, Custom Page API, Widget Shortcodes and Workflow Input/Output Nodes for the full APIs.

See also ​

Scada.Ink Help Center