mqtt-devices-parser 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Changelog.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 1.0.5
2
+ - db: adds mqtt user passed on mqtt struct and grants admin privileges
3
+
4
+ # 1.0.4
5
+ - mqtt: adds retain to project state
6
+
1
7
  # 1.0.3
2
8
  - fixes config arg
3
9
 
package/Readme.md CHANGED
@@ -33,3 +33,7 @@
33
33
 
34
34
  The default configuration uses ./config/index.js file\
35
35
  In your program set the same struct and pass it as argument on the module init call.
36
+
37
+ An mqtt account will be created using the following settings
38
+ mqtt.user - mqtt user login
39
+ mqtt.pwd - mqtt pwd login
package/Release.md ADDED
@@ -0,0 +1,11 @@
1
+ # Release
2
+
3
+ ## Before release
4
+
5
+ increases version on package.json
6
+ edit changelog
7
+ commit and push to repo
8
+
9
+ ## Releasing
10
+
11
+ npm publish
package/index.js CHANGED
@@ -92,12 +92,13 @@ var self = module.exports = {
92
92
  await $.models.dropTableIndexes();
93
93
  await $.models.sync();
94
94
 
95
- let user = await $.models.insertUser("admin","admin",5); // ads user
96
- //console.log(user);
95
+ // adds user for mqtt with admin credentials
96
+ let user = await $.models.insertUser($.config.mqtt.user,$.config.mqtt.pwd,5);
97
97
  let user_id = user.dataValues.id;
98
98
  await $.models.insertUser("device","device",3);
99
99
  await $.models.insertUser("client","client_pwd",3);
100
- await $.models.insertClient("admin","admin",user_id); // ads client with credentials admin@admin
100
+ // adds client with credentials admin@admin
101
+ await $.models.insertClient("admin","admin",user_id); // dashboard login
101
102
  }
102
103
 
103
104
  // project tables
@@ -136,9 +137,9 @@ function mqtt_connect(){
136
137
 
137
138
  for(let project in $.config.projects){
138
139
  if($.config.projects[project])
139
- client.publish(mqtt_prefix+"/"+project,"active");
140
+ client.publish(mqtt_prefix+"/"+project,"active",{qos:2,retain:true});
140
141
  else
141
- client.publish(mqtt_prefix+"/"+project,"deactive");
142
+ client.publish(mqtt_prefix+"/"+project,"deactive",{qos:2,retain:true});
142
143
  };
143
144
  })
144
145
  console.log(`MQTT connected to: ${$.config.mqtt.host}:${$.config.mqtt.port}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mqtt-devices-parser",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {