Skip to main content

Change a setpoint with approval

What you build​

A controlled change of the Filler SpeedSetpoint, the writable register 1!40020, from 120 to 100 bottles per minute. Nobody writes to the machine directly. A value is proposed, a second person approves it, it is executed with limits and a read-back check, and every step is audited.

Time: about 45 minutes.

Prerequisites
  • You finished Your first pipeline. The simulator demo-sim runs; it accepts writes to 40020 and moves the Filler speed with the setpoint.
  • Two people (or two accounts): an admin who prepares the tag, and a second user who approves. Use a role with the right to write tags, for example senior_operator.
  • Safe write turned on in the runtime (step 3).
  • This tutorial uses an agent credential or a JSON call to make the proposal. If you want the assistant version, read Claude with MCP first.

Why this order​

LayerWhat it does
Write attributeA tag can only be written if its attribute includes Write.
Safe-write limitsLowest and highest value, largest step, read-back check. An assistant may only propose a write to a tag whose lowest and highest value are set.
ProposeA proposal changes nothing. It waits 24 hours for a person.
ApproveAnother person decides. The proposer can never approve their own proposal.
ExecuteThe runtime checks the policy, reads the value first, writes once, waits and reads back. It never retries.
AuditPropose, approve, execute and the write itself are recorded.

Step by step​

1. Make SpeedSetpoint a writable tag​

  1. Open Connectivity → Devices and edit line1-modbus (row action Edit). Open Groups & tags and the group fast.

  2. Click Add tag:

    FieldValue
    NameSpeedSetpoint
    AttributeRead and Write (tick both pills)
    TypeUINT16
    Address1!40020
    Unitbottles/min
  3. Leave Decimal empty. A scaled tag cannot use safe write.

  4. Click Save. The new tag is bound to the Filler.

  5. Check the value in Plant → Plant graph, node Filler: SpeedSetpoint is 120.

Add Tag dialog: tick Read and Write for a writable tag
Add Tag dialog: tick Read and Write for a writable tag

2. Set the safe-write limits​

Only an administrator may change limits. The setting is saved at once and the device is not reconnected.

  1. In the tag list click the shield icon (Safe write) on the row SpeedSetpoint. The dialog "Safe write: SpeedSetpoint" opens.

  2. Fill:

    FieldValueMeaning
    Lowest value60Below this, the write is refused (out_of_limits).
    Highest value140Above this, refused.
    Largest step from the current value30A jump from 120 to 60 is refused (step_too_large).
    Tolerance when reading back0The device must report exactly the value.
    Only if the value is still what the person sawonIf someone changed the setpoint after the approver looked, nothing is written.
  3. Leave the timing fields at their defaults.

  4. Click Save limits.

Without limits "writes and rules go out plainly" and an assistant cannot propose a write to this tag.

3. Turn safe write on in the runtime​

The runtime decides how safe write behaves with the environment variable MI_SAFE_WRITE:

ValueEffect
off (default)Writes to tags with limits are refused. Rules still write plainly.
tagSafe write applies to tags with limits. Other tags are written plainly.
requiredTags without limits are not written at all.

For this tutorial set MI_SAFE_WRITE=tag in the environment of the Lite process. Optionally set MI_SAFE_WRITE_JOURNAL to a file path for the runtime journal.

sudo systemctl edit makeintelligent

Add, then save:

[Service]
Environment=MI_SAFE_WRITE=tag
sudo systemctl restart makeintelligent
note

The Lite components inherit the environment of the service. Set the variable in the service environment as shown, not in config/mii.env, which is documented for ports, admin name, log level and the public data listeners only.

An older runtime that does not know safe write reports "unsupported".

4. Create the second person and the proposer​

  1. Open Settings → Users (admin) and click Add user. Username shift-lead, a password of at least 12 characters, role senior_operator. This person approves and runs. The role carries the right to write tags (write_tags).
  2. Open Settings → AI connections. Under "Credentials" fill Name Setpoint assistant and choose the Access ceiling Engineer (read + propose changes and tag writes). Click Create credential.
  3. Copy the secret (mii_ac_…) with Copy secret. It is shown once and not stored. Click I have saved it.

The credential can read and propose. It cannot approve, reject or execute. The server answers such a try with 403 "agent credentials can only propose; a person must approve and execute".

Settings, AI connections: create the credential here; the secret is shown once
Settings, AI connections: create the credential here; the secret is shown once

5. Propose the change​

Use an assistant (see Claude with MCP) or the JSON calls below. The calls are the same as the assistant makes.

Set two shell variables:

export URL=https://<console>/api/v2/mcp
export H="Authorization: Bearer $MII_MCP_TOKEN" # the mii_ac_... secret

5.1 Find the tag. mii_find turns a name into ids:

curl -s -H "$H" -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' "$URL" -d '{
"jsonrpc":"2.0","id":1,"method":"tools/call",
"params":{"name":"mii_find","arguments":{"query":"Filler SpeedSetpoint","kind":"tag"}}}'

If the answer is needs_clarification, choose the candidate that is the Filler tag. Note the tagId and the deviceId (mii_see_describe shows the device of a tag).

5.2 Read the current value.

curl -s -H "$H" -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' "$URL" -d '{
"jsonrpc":"2.0","id":2,"method":"tools/call",
"params":{"name":"mii_see_read","arguments":{"tagIds":["<tagId>"]}}}'

You should get value 120, quality good.

5.3 Propose the write.

curl -s -H "$H" -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' "$URL" -d '{
"jsonrpc":"2.0","id":3,"method":"tools/call",
"params":{"name":"mii_act_propose_write_tag","arguments":{
"deviceId":"<deviceId>","tagId":"<tagId>","value":100,
"reason":"Label roll is nearly empty; slow the Filler to 100 bottles/min until the roll is changed."}}}'

The result is a pending proposal with an id. Nothing was written. Check:

curl -s -H "$H" -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' "$URL" -d '{
"jsonrpc":"2.0","id":4,"method":"tools/call",
"params":{"name":"mii_act_proposal_get","arguments":{"id":"<proposalId>"}}}'

The status is pending. The simulator still reports SpeedSetpoint = 120.

6. Review and approve as the second person​

  1. Sign out and sign in as shift-lead.

  2. Open Administration → Approvals. The tab Inbox shows the proposal with the status Waiting and the source "AI assistant (MCP)".

  3. Open it and check the details:

    ItemWhat you should see
    Device, Tag, Address, Typeline1-modbus, SpeedSetpoint, 1!40020, UINT16
    Now120, quality good, a few seconds old
    Requested100
    Limits60 to 140, largest step 30
    Reason"Reason given by the proposer (not verified)" followed by the text
  4. Click Approve and confirm with Approve and run. The note "The value you see now goes with the approval. If it changed, a tag with limits is not written." tells you why you should look at the current value first.

If you may approve but not run, the button reads Approve and a person with the right permission uses Run now later.

Approvals page: proposals wait in the Inbox until a person approves them
Approvals page: proposals wait in the Inbox until a person approves them
Approving your own proposal

If you made the proposal with your own access, the Console says "Proposed with your own access: someone else must decide." That is the two-person rule. Sign in as the second user.

7. Check the execution​

  1. The proposal moves to Running and then Done. The Result shows the write outcome: written and read back (applied_verified).
  2. In Plant → Plant graph, node Filler: SpeedSetpoint is 100.
  3. Open Monitoring → Trends with SpeedSetpoint and Speed. After a few seconds the speed falls from about 115 to about 90 to 98 bottles per minute.

Possible outcomes:

OutcomeMeaningWhat to do
applied_verifiedWritten and read back.Nothing.
applied_unverifiedWritten, not read back.Check the value by hand.
mismatchThe device accepted the write but reads back something else.Look at the machine. A proposal to restore the old value is created and another person must approve it.
unknownUnclear whether it was written. The tag is held.Check the device, then use Record what happened and release the hold under the tab Held tags.
rejected / "Refused"Not written. Reason such as out_of_limits or changed_since_approval.Fix the cause and propose again.

8. Try the guard rails​

Propose 200 the same way as in step 5.3. After approval the outcome is Refused with out_of_limits, "Nothing was written." Propose 50: out_of_limits again. Propose 60 from a current value of 120: refused with step_too_large. These tries show that an approved proposal still cannot break the limits.

9. Restore the setpoint​

Propose 120 with the reason "Label roll changed." Approve and run it as shift-lead. The Filler returns to 110 to 120 bottles per minute.

10. Read the audit trail​

  1. In Administration → Approvals open the tab Audit trail. You see the events propose, approve and execute with Time, User, Event, Proposal and Detail.
  2. As admin or auditor open Administration → Audit log. Filter Action to Write and Resource to Tag. The write row shows the value and the actor.
  3. Click Check integrity. The result "The audit log is intact." means the hash chain is unbroken.
  4. Ask for what the change did: the tool mii_act_outcome returns the evidence tags before and after.
Audit log with the write to SpeedSetpoint and the approval events
Audit log with the write to SpeedSetpoint and the approval events

Check it works​

  • SpeedSetpoint has the attributes Read and Write and a safe-write limit of 60 to 140.
  • The proposal was Waiting and the simulator value was still 120 before approval.
  • The approver was a different person from the proposer's owner.
  • The status is Done and the Plant graph shows 100.
  • The Filler Speed fell to about 90 to 98 and came back after the restore.
  • A write of 200 was Refused with out_of_limits.
  • The audit trail lists propose, approve and execute for each change.

Next steps​

Troubleshooting​

SymptomLikely causeFix
The assistant says the write is not allowed to be proposedThe tag has no lowest and highest value.Set the limits in step 2.
Proposal refused: "tag … is not writable; use attribute write"The tag has only Read.Tick Write in the tag.
The shield icon is missingThe device is not saved yet, the tag has no Write attribute, or the tag is scaled.Save the device, tick Write, clear Decimal.
Safe write refuses every writeMI_SAFE_WRITE is off (default) and the tag has limits.Step 3: set tag.
Approval says "You may look, but not decide."Your role has none of the needed rights.Use a role with write_tags, for example senior_operator.
"Proposed with your own access: someone else must decide."Proposer and approver are the same person.Sign in as the second user.
"This proposal has expired. It must be proposed again."Proposals expire after 24 hours.Propose again.
Refused with changed_since_approvalThe setpoint changed after the approver looked.Propose again with the new current value.
Status Outcome unknownThe runtime did not report within 2 minutes.Check the machine, then Record what happened. Nothing is written again.
The tag is held after an unknown or mismatch resultThe hold protects the machine.Look at the device, then release it under Held tags with a note.
403 on execute from the assistantAgent credentials can only propose.A person approves and runs in Approvals.