MQTT problems. (nodes, messages and python)

(How has to become this complicated?)

I have a python script running and I added this line:
client.publish("alarm_clock/oops",text)

I then have an MQTT IN node and set it so:

[{"id":"20f5e9bf.b0c9f6","type":"mqtt in","z":"eff5d6e6.236338","name":"","topic":"alarm_clock/received","qos":"2","datatype":"auto","broker":"9e83409.d55cfc","nl":false,"rap":false,"x":2200,"y":1520,"wires":[["dd14cb9.4e59838"]]},{"id":"9e83409.d55cfc","type":"mqtt-broker","name":"Local Host","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]

I see the messages clearly in a debug node (eg):

13:20:14@6,1

So in that spirit I add another line:

client.publish("alarm_clock/next","OK")

I then create another MQTT IN node and set it as so:

[{"id":"7af3c479.02f0ac","type":"mqtt in","z":"eff5d6e6.236338","d":true,"name":"","topic":"alarm_clock/next","qos":"2","datatype":"utf8","broker":"9e83409.d55cfc","nl":false,"rap":false,"x":960,"y":1310,"wires":[["931ebc46.313478","6e6d67af.fec578"]]},{"id":"9e83409.d55cfc","type":"mqtt-broker","name":"Local Host","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]

Excuse the fact it is disabled

I stick a debug node onto it and wait.

{"topic":"ERROR_REPORT/Alarm_Clock/LCD message handling flow/alarm_clock/next","payload":"OK","qos":0,"retain":false,"_topic":"alarm_clock/next","_msgid":"b190ae41.af86f","error":{"message":"Unexpected token O in JSON at position 0","source":{"id":"6e6d67af.fec578","type":"json","count":1}}}

Where's the elephant?

I can't understand what is wrong with this.

It happily accepts the stuff I am sending back with text - which isn't a JSON structure as far as I know.

Yet, when I want to send back a simple OK.... It spits the dummy.

After my normal Bashing head against wall it has started to behave itself.

Partly because I removed the JSON node. But I didn't put one there originally as the one which works doesn't have one.

I put one there in an attempt to obey the rules of MQTT.

What rule of MQTT were you trying to obey?

So rather than having to put everything into the payload part of the message.

At the sending end, it gets the entire msg structure and puts it into a new msg.payload structure.

I'm still not sure it does work.

I still don't understand what rule of MQTT you were trying to obey.

@Colin Andrew is refering to the fact the MQTT nodes only publish msg.payload and not the full msg object.

Ah, some strange new use of the word 'rule' with which I am unfamiliar.

Thanks.

It is my failure to understand English vocabulary.

I called it a 'rule' as it has to be obeyed if you want to send complicated (not the right word maybe) messages.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.