Mqtt publishing from gateway script

i have a script in gateway tag change to publish in mqtt …but i am not getting the values in concerned topic.can anyone suggest me a solution?
below is my code.

import json
import urllib
import time
lowerpredict ="[Sekurit Blower Optimizer]KT/read/LowerPredict").value
upperpredict ="[Sekurit Blower Optimizer]KT/read/UpperPredict").value
publishdata = {“Lowerpredict”:lowerpredict,“Upperpredict”:upperpredict}
jsondata = json.loads(json.dumps(publishdata))
jsonstring = system.util.jsonEncode(jsondata)
publishing = system.cirruslink.engine.publish(“SekuritKT”,"[MQTT Engine]Sekurit_KTBlower_Optimizer_write",jsonstring,2,1)

The payload is supposed to be a byte array.


publishing = system.cirruslink.engine.publish("SekuritKT","[MQTT Engine]Sekurit_KTBlower_Optimizer_write",jsonstring.encode(),2,1)

edit: this topic suggests it might be a little trickier than just using .encode(), not sure: Publish to topics using system.cirruslink.engine.publish() - #2 by pturmel