This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

MQTT publish json
#1
Hi,

I am using admin`s mqtt script from this post: https://forum.logicmachine.net/showthread.php?tid=1759

Is there a way to change this:

  object_to_mqtt = {
    ['1/1/1'] = 'out/topic1',
    ['1/1/2'] = 'out/topic2',
  }
 
to send a variable that is a json string with multiple values (something like this):

valueX= grp.getvalue('32/3/1')
valueY= grp.getvalue('32/3/2')
topic1 = '{"site": "building", "equipment":"ventilation3601", "current_mode":"'..valueX..'", "current_status":"'..valueY..'"}'

  object_to_mqtt = {
    [topic1] = 'out/topic1',
    ['1/1/2'] = 'out/topic2',
  }

-John
Reply


Messages In This Thread
MQTT publish json - by JohnTH - 05.04.2019, 11:41
RE: MQTT publish json - by admin - 08.04.2019, 09:50
RE: MQTT publish json - by JohnTH - 08.04.2019, 18:18
RE: MQTT publish json - by admin - 09.04.2019, 07:16
RE: MQTT publish json - by JohnTH - 09.04.2019, 08:21

Forum Jump: