MQTT discussion topic

Forum about MQTT, machine-to-machine (M2M), "Internet of Things" and Node.js

Moderators: Digit, Rene, Willem4ever, Bwired

dad
Starting Member
Starting Member
Posts: 30
Joined: Thu Jun 13, 2013 10:20 pm

Re: MQTT discussion topic

Post by dad »

Digit wrote:I also create a separate topic for every device value, for example an Oregon Scientific sensor can have 4 of them: */temp, */hum, */batt and */comfort. Cause if you want all the info of that sensor, you simply do a */#.
Using an object notation for the payload does keep it more flexible, e.g. adding a timestamp later on, so you know when that value in the payload was 'sensed'.

So that you can store information like when the AV receiver was powered on (*/powerstate = {value:on, changed: "13:44:00"}), but also when the last time was that the volume level has changed (*/volume = {value:35, changed: "14:00:23"}) In a way, you keep all options open for the future, without having to change a single line of code other than for adding that new 'feature'. I don't use JSON in the payload.
@Digit: I am new to MQTT - at the moment I just have the raw value as the payload, but if you do a wild card you just get a series of numbers. Am I correct that you send the following as payload:

value:35, changed: "14:00:23"

BTW: where do you inject the time value?

Thanks

Dad
Bwired
Administrator
Administrator
Posts: 4704
Joined: Sat Mar 25, 2006 1:07 am
Location: Netherlands
Contact:

Re: MQTT discussion topic

Post by Bwired »

you need to add that yourself

example:

Code: Select all

var s = (new Date()).toMyString() + ' '+ value;
MqttClient.publish(MQTT_LOGGING_ROOT+global.systemId, s.toString(), false);
Post Reply

Return to “MQTT & Node.js”