MQTT discussion topic

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

Moderators: Digit, Rene, Willem4ever, Bwired

Re: MQTT discussion topic

Postby dad » Mon Apr 28, 2014 10:33 am

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?


Starting Member
Starting Member
Posts: 30
Joined: June 2013

Re: MQTT discussion topic

Postby Bwired » Mon Apr 28, 2014 11:59 pm

you need to add that yourself


Code: Select all
var s = (new Date()).toMyString() + ' '+ value;
MqttClient.publish(MQTT_LOGGING_ROOT+global.systemId, s.toString(), false);
User avatar
Posts: 5315
Joined: March 2006
Location: Netherlands


Return to MQTT & Node.js

Who is online

Users browsing this forum: No registered users and 1 guest