send_command json instead of str

send_command json instead of str
This commit is contained in:
Brian Martin 2019-10-01 16:27:58 -04:00
parent e873e22fd3
commit e233fe933e
2 changed files with 61 additions and 10 deletions

View file

@ -183,9 +183,16 @@ class MQTTHelperBot:
cmdjson["payloadType"],
)
try:
await self.Client.publish(
ttopic, str(cmdjson["payload"]).encode(), QOS_0
)
if cmdjson["toType"] == "x":
await self.Client.publish(
ttopic, str(cmdjson["payload"]).encode(), QOS_0
)
if cmdjson["toType"] == "j":
await self.Client.publish(
ttopic, json.dumps(cmdjson["payload"]).encode(), QOS_0
)
except Exception as e:
helperbotlog.exception("{}".format(e))