1)make a virtual datasource binary datapoint, add it to the script context points. Tick the checkbox that this point triggers the script.
we shall call the context point switch.
Then add your mqtt point to the context. We shall call it toggle. It does not need the checkbox to the right filled. Ensure the mqtt point is settable
This is the script.
if(switch.value===true)
{
toggle.set("on");
}
if(switch.value===false)
{
toggle.set("off");
}
See how you go. I do not use the mqtt client myself, but generally all points can be set - some which send the value back out the data source. I am hoping this is the latter...
Hope this helps
Fox