Configuring ThingWorx Buttons to Write Kepware Tag Values

Karen Mitchell7 min read
HMI / SCADAOther ManufacturerTechnical Reference
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Why does clicking the button not change the Kepware tag?

The operator clicks a button in the mashup and the PLC bit stays where it was. The screen shows no error. The mashup is behaving normally, because a button has no value of its own. It only fires a Clicked event, and something has to consume that event and write to a property that is tied to a Kepware tag.

The write path has four links:

  1. The mashup button fires its Clicked event.
  2. The event calls a service on a Thing, either a custom service or a built-in property-set service.
  3. The service sets a remote property. This is a Thing property bound to a tag on an edge source, here the Kepware server. It is not a value stored only in the ThingWorx platform.
  4. ThingWorx pushes the new value over the industrial connection to Kepware. Kepware then writes it to the device through its driver.

A plain local property on a Thing changes inside ThingWorx and never reaches Kepware. That is the most common reason a button "works" in the mashup and does nothing on the machine. Walk the checks below in order. Each one isolates one link.

Check 1: Is the Kepware connection actually up?

Open the Industrial Gateway Thing that represents the Kepware server in ThingWorx and read its connection status property.

Reading Meaning Next step
Connected = true The Kepware ThingWorx interface is attached to the platform Go to Check 2
Connected = false No write can reach Kepware, regardless of the mashup In the Kepware project properties, check the ThingWorx interface: platform host, port, application key, and the Thing name. That Thing name must match the Industrial Gateway Thing name exactly.
Connection toggles Unstable network or an expired or invalid application key Check the Kepware event log for connection and authentication messages before going further

A disconnected gateway fails silently from the operator's side. The service runs, the property changes in the platform, and nothing leaves the server.

Check 2: Is the property bound to the Kepware tag, or just named like it?

Open the Thing that the mashup service targets. Go to Properties and find the property the button should drive.

Reading Meaning Next step
Property shows a remote binding to a Kepware channel.device.tag path This is a remote property Go to Check 3
Property has no remote binding It is a local property. Writes stay in ThingWorx. Delete it and recreate it from the Kepware browse (procedure below)
Bound, but the value never updates when the PLC changes Wrong tag path, or the Thing is not linked to the gateway Confirm the Thing carries the industrial thing shape and that its industrial gateway reference points to the connected gateway

The tag is right; the binding is wrong. This pattern shows up constantly. Someone creates a property named after the PLC tag and expects it to connect by name. ThingWorx does not match by name. The property must be created from the Kepware tag browse, or explicitly bound to the remote tag path.

A quick read-side test: force the bit in the PLC or in the Kepware Quick Client, then refresh the Thing's Properties view. If the value follows, the read binding is good and the write path is the only remaining link.

Check 3: Will Kepware accept the write?

Kepware silently rejects some writes that ThingWorx sends without complaint. Check the tag itself in the Kepware project.

Setting Where Effect on the button write
Client access Tag properties in Kepware Read Only blocks every write from ThingWorx. Set it to Read/Write.
Data type Tag properties, and the matching ThingWorx property base type A Boolean tag maps cleanly to a BOOLEAN property. A Word or Short tag holding 0/1 needs a NUMBER or INTEGER property. A mismatch causes rejected or coerced writes.
Scaling Tag scaling settings With scaling on a 0/1 command tag, a written 1 can land as a different raw value. Leave command bits unscaled.
Device address Tag address in Kepware An input image or read-only PLC area accepts no writes. The bit the logic reads must be in a writable data area.
User/project write restrictions Kepware user manager and project settings Restrictions on the account the ThingWorx interface uses can block writes that the Quick Client allows.

Isolate the fault in one step. Set the property value directly from the Thing's Properties page in ThingWorx Composer, then watch the tag in the Kepware Quick Client.

  • If the tag changes, the whole path from the service onward works. Any remaining fault is in the mashup or in permissions.
  • If the tag does not change, the fault is in Kepware, the device, or Check 1.

How do I build the button-to-tag write?

Both approaches below work. Use one service with an input parameter. It keeps permissions, logging, and validation in one place. The alternative is two hard-coded services, such as Start and Stop, which double the maintenance for every added command.

  1. Create the remote property. On the Thing linked to the Kepware gateway, add a property and use the browse option to select the Kepware tag. Match the base type to the Kepware data type: BOOLEAN for a Boolean tag, NUMBER or INTEGER for a word used as 0/1. Save.
  2. Create the service. On the same Thing, add a JavaScript service with one input matching the property type. The names below are examples; substitute your own.
// Service: WriteCommand
// Input:   cmd (BOOLEAN)
// StartCmd is the remote property bound to the Kepware tag
me.StartCmd = cmd;
  1. Test the service in Composer. Execute it with cmd = true, then false. Confirm each value in the Kepware Quick Client before touching the mashup.
  2. Add the service to the mashup. In the mashup data panel, add the Thing and the WriteCommand service.
  3. Bind the button. Bind the button's Clicked event to the service. For fixed-value buttons, supply the input as a static value: one button sends true, another sends false. For a toggle, bind a toggle or checkbox widget's state to cmd and fire the service on its change event.
  4. Grant runtime permissions. Give the operator's user or group execute permission on the service and write permission on the property. Without these, the button click fails for operators while it works for an administrator.

What recurs after the button works once?

Symptom Cause Fix
Works for the admin, not for operators Missing runtime execute or write permission Add the permissions to the operator group on the Thing or its template
Momentary "start" bit stays at 1 A web button has no reliable release event. The click writes 1 and nothing resets it. Let the PLC logic unlatch the command bit after it is consumed, or have the service write 1 and let the PLC clear it. Do not rely on a second click or timed web logic for a pushbutton.
Second press does nothing The bit is already 1 because the PLC never reset it Same handshake: the PLC clears the bit, then ThingWorx reads 0 again
Mashup shows the new value but the machine does not act Display bound to the platform value, not the device read-back Drive the status indicator from a separate PLC status tag, not the command tag
Writes stop after a Kepware restart Gateway reconnect or application key issue Re-run Check 1

For the final verification, log in to the mashup as an operator-level user, not an administrator. Press the button. Confirm three things:

  1. The tag changes in the Kepware Quick Client.
  2. The PLC logic sees the bit, either online in the controller or through a status tag.
  3. The status indicator in the mashup updates from the device read-back rather than from the written value.

FAQ

Can I write to a Kepware tag from a mashup without writing a custom service?

Yes. A mashup can call a Thing's built-in property-set services against a remote property. A custom service is the better choice, though, because it lets you validate the input, log the operator action, and control execute permissions on one item.

Does the ThingWorx property need to be a remote property to reach Kepware?

Yes. Only a property bound to the Kepware tag path through the industrial gateway sends values to Kepware. A local property with the same name changes only inside ThingWorx.

Does the Kepware tag need Read/Write client access?

Yes. A tag set to Read Only rejects writes from ThingWorx even when the gateway is connected and the service runs without error. Check the tag's client access setting in the Kepware project.

Can I use one button as a momentary pushbutton to the PLC?

Not reliably. A web button has no guaranteed release event, so write 1 on click and have the PLC logic clear the bit once it acts on it. Show the result from a separate PLC status tag.

How do I confirm the write reached the device and not just ThingWorx?

Set the value from the Thing's Properties page or run the service in Composer. Watch the same tag in the Kepware Quick Client and online in the controller. If it changes in ThingWorx only, recheck the gateway connection and the remote binding.

Back to blog