# Can not write MQTT Engine’s Tag

**URL:** <https://forum.inductiveautomation.com/t/can-not-write-mqtt-engine-s-tag/76245>\
**Category:** 3rd Party Modules\
**Tags:** ignition81, perspective\
**Created:** [July 12, 2023, 6:53am UTC](https://forum.inductiveautomation.com/t/can-not-write-mqtt-engine-s-tag/76245 "2023-07-12T06:53:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ekb](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@ekb](https://forum.inductiveautomation.com/u/ekb)\
**Post date:** [July 12, 2023, 6:53am UTC](https://forum.inductiveautomation.com/t/can-not-write-mqtt-engine-s-tag/76245/1 "2023-07-12T06:53:24Z")

</div>

Hello everyone, I have a problem.

About MQTT Engine Tag.

I use MQTT engine 's tag to read tags from ha HiveMQ Cloud server.  
The mqtt tags is sendt from KNX with eelectrons knx/mqtt gateway.

> **[KNX BRIDGE WITH IP INTERFACE AND POWER SUPPLY KNX + AUX 640mA + MQTTs -...](https://www.eelectron.com/en/prodotto/knx-bridge-with-ip-interface-and-power-supply-knx-aux-640ma/)**
>
> The IPSBA01KNX device integrates a KNX power supply with auxiliary output with a a total current of 640mA, and an IP interface, allowing KNX installations to be implemented quickly and efficiently. The voltage of the bus output as well as that of the...

The gateway use subscribe rule and publish rule  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/d/6d9eb948712c61771b32dcad3c1d208aea58fb78.png)

When I change the tag in KNX it's updated and sendt to  
ee/bridge/006c00636903/Instell/RT401\_T\_SP/sts  
and If I use MQTT Explorer and Publish a new value on  
ee/bridge/006c00636903/Instell/RT401\_T\_SP/cmd  
It's sendt to KNX.  
So KNX to MQTT is working. But It don't support sparkplug.

In Ignition I get the values with MQTT Engine  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/9/8985b92b86249992ed88f8a75b6ea3de42ed1a7c.png)  
But I have to set the cmd tag to 'Read only = false' and 'Write Permissions = public'

I have check on the gateway config page for engine “Block Node Commands” and “Block Device Commands”. They are false

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/b/2b17e254f20873d900de401bc4ba990dd6d723b9.png)

When I try to write to the tag I get Bad\_ReadOnly  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/5/1566aa7fef050f1445bad124f2ea5916cfe42258.png)  
I have the same user on MQTT Explorer as on Ignition Mqtt Engine server settings

Is there more places I need to look?

---

<div class="post-metadata">

**Author:** ![deon.korb](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@deon.korb](https://forum.inductiveautomation.com/u/deon.korb)\
**Post date:** [July 12, 2023, 7:38am UTC](https://forum.inductiveautomation.com/t/can-not-write-mqtt-engine-s-tag/76245/2 "2023-07-12T07:38:10Z")

</div>

This sounds familiar. Check the versions.

> [@MQTT Engine Custom Namespace Not Writeable](https://forum.inductiveautomation.com/t/mqtt-engine-custom-namespace-not-writeable/60611):
>
> My MQTT Engine namespaces seem to suddenly not be writeable anymore. This was working. The writeable option is definitely ticked: The AccessRights on the MQTT Engine tag provider seems to be Read\_Write: [image] Writing to it (either directly or via reference tag) always produces this: [image] I have upgraded to 8.1.17 and MQTT Engine v 4.0.11 in hopes of solving this, but no change. I use a change script on a reference tag to do the actual MQTT publish, but the script isn’t exec…

---

<div class="post-metadata">

**Author:** ![ekb](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@ekb](https://forum.inductiveautomation.com/u/ekb)\
**Post date:** [July 13, 2023, 7:26am UTC](https://forum.inductiveautomation.com/t/can-not-write-mqtt-engine-s-tag/76245/3 "2023-07-13T07:26:39Z")

</div>

I have the 4.0.17 version and Ignition Version: **8.1.27 (b2023042509)**

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/7/1713b71110754b77ac262527ec7d6f773403d53d.png)

On the download page mqtt version 4.0.17 is linked to ignition version 8.1.28

So I installed mqtt version 4.0.16 that is linked to ignition version 8.1.27.

But still error when I try to write to the tag:(

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/5/a56d10044a18d61fd071022cc7d4af889e4ec0d6.png)

From the logs

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/1/11cbd5ba2eb185f9e81a88914e5f07b611dcd103.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 13, 2023, 12:49pm UTC](https://forum.inductiveautomation.com/t/can-not-write-mqtt-engine-s-tag/76245/4 "2023-07-13T12:49:42Z")

</div>

You might want to post on [Cirrus Link's own forum](https://forum.cirrus-link.com/), for more focused advice.

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [July 13, 2023, 1:14pm UTC](https://forum.inductiveautomation.com/t/can-not-write-mqtt-engine-s-tag/76245/5 "2023-07-13T13:14:25Z")

</div>

If you're bringing in tags from a [_Custom Namespace_](https://docs.chariot.io/display/CLD80/MQTT+Engine+Custom+Namespace), writes don't automatically translate to publishes back to those respective topics. So even if you enable [Writable Tags](https://docs.chariot.io/display/CLD80/ME%3A+Configuration#ME:Configuration-NamespacesCustomGeneralAdvancedNamespacesCustom-GeneralAdvanced) in the MQTT Engine configuration, those writes don't _do_ anything by default. One thing you can do is setup a [Tag Change](https://docs.inductiveautomation.com/display/DOC81/Gateway+Event+Scripts#GatewayEventScripts-TagChangeScripts) script (triggering on a wildcard off of your custom namespace root tag folder, perhaps `ee/bridge/*` ?) and then leverage [MQTT Engine Python Scripting Functions](https://docs.chariot.io/display/CLD80/ME%3A+Python+Scripting#ME:PythonScripting-publish) to publish a message back to the topic. It is a bit hand-cranked, but it can work nicely once assembled.

---

<div class="post-metadata">

**Author:** ![ekb](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@ekb](https://forum.inductiveautomation.com/u/ekb)\
**Post date:** [July 25, 2023, 1:06pm UTC](https://forum.inductiveautomation.com/t/can-not-write-mqtt-engine-s-tag/76245/6 "2023-07-25T13:06:49Z")

</div>

Sorry for the late replay, but other things happen..

I have setup the name spaces to subscribe to knx brigde

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/a/5a033c1bfff727a33e16f9fea29cf782274d5c3a.png)  
And enabelt write to mqtt. 🙂

And I can now send a new setpoint from ignition to mqtt broker and to KNX  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/7/e799424617bfd44297fb2371dff4c4ce8103c3d1.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/b/bbb5ba1c17c81e217da403243e8816901383352f.png)

So far so good.  
I have used Gateway Tag Change Scripts  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/e/fe480212cae200cc970341434648cbfc43d978d7.png)

```auto
system.cirruslink.engine.publish("HiveMQ Cloud storm elektro", "ee/bridge/006c00636903/Instell/RT401_T_SP/cmd", str("18").encode(), 0, 0)

```

- 

But the Gateway Tag Change script is not a good way to change a lot of setpoints on room control. Is it a good way to do it in the NumericEntryField ? I can't get ignition to send updates directly to the tag

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/3/e35f4770171f5f4808f8132fd2719970996d6775.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 25, 2023, 1:10pm UTC](https://forum.inductiveautomation.com/t/can-not-write-mqtt-engine-s-tag/76245/7 "2023-07-25T13:10:50Z")

</div>

> [@ekb](#):
>
> I can't get ignition to send updates directly to the tag

Kevin C already explained why:

> [@kcollins](#):
>
> If you're bringing in tags from a [_Custom Namespace_](https://docs.chariot.io/display/CLD80/MQTT+Engine+Custom+Namespace), writes don't automatically translate to publishes back to those respective topics. So even if you enable [Writable Tags](https://docs.chariot.io/display/CLD80/ME%3A+Configuration#ME:Configuration-NamespacesCustomGeneralAdvancedNamespacesCustom-GeneralAdvanced) in the MQTT Engine configuration, those writes don't _do_ anything by default.

Using the tag change script to publish is the solution for this.

---

<div class="post-metadata">

**Author:** ![ekb](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@ekb](https://forum.inductiveautomation.com/u/ekb)\
**Post date:** [July 26, 2023, 7:03am UTC](https://forum.inductiveautomation.com/t/can-not-write-mqtt-engine-s-tag/76245/8 "2023-07-26T07:03:07Z")

</div>

OK, I was hoping is was a way to have the script running from a UDT or the tagg.

(Update after some houres)  
This is a solution I found to do it if anybody else wounder.

I have tags from knx to the mqtt broker. Some of them are setpoints that I need to send values down to. But they can be change on the KNX side to. If they are updated on the KNX side it's only publish to the sts value. If I want to update them from mqtt I send them on the cmd, but then sts is not updated.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/3/9361b388666443a2351d39612b6403596e9e84af.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/8/a80fa8d79da3a97fafb7317ea3f01182d1659e22.png)

Inn ignition i made a tag script on value changes  
[MQTT Engine]KNX/ee/bridge/006c00636903/Instell/RT401\_T\_SP/cmd

```auto
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	    # Get the value of the [MQTT Engine]KNX/ee/bridge/006c00636903/Instell/RT401_T_SP/cmd tag as a string
		    tag_value = str(system.tag.read("[MQTT Engine]KNX/ee/bridge/006c00636903/Instell/RT401_T_SP/cmd").value)
		    
		    # Construct the MQTT payload with the tag name and its value
		    payload = tag_value.encode('utf-8')

		    # Publish the payload to the MQTT broker
		    system.cirruslink.engine.publish("HiveMQ Cloud storm elektro", "ee/bridge/006c00636903/Instell/RT401_T_SP/sts", payload, 0, 0)				
		    # Publish the payload to the MQTT broker
		    system.cirruslink.engine.publish("HiveMQ Cloud storm elektro", "ee/bridge/006c00636903/Instell/RT401_T_SP/cmd", payload, 0, 0)

```

and on [MQTT Engine]KNX/ee/bridge/006c00636903/Instell/RT401\_T\_SP/sts

```auto
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
    # Get the value of the [MQTT Engine]KNX/ee/bridge/006c00636903/Instell/RT401_T_SP/sts tag as a string
	    tag_value = str(system.tag.read("[MQTT Engine]KNX/ee/bridge/006c00636903/Instell/RT401_T_SP/sts").value)
	    
	    # Construct the MQTT payload with the tag name and its value
	    payload = tag_value.encode('utf-8')
	
	    # Publish the payload to the MQTT broker
	    system.cirruslink.engine.publish("HiveMQ Cloud storm elektro", "ee/bridge/006c00636903/Instell/RT401_T_SP/cmd", payload, 0, 0)

```

If the sts value is updated from KNX I update the cmd value.  
And if I change the cmd value from ignition I update both the sts and cmd value.

Thanks for all the help 🙂
