mqtt-devices-parser 1.0.4 → 1.0.6
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 +6 -0
- package/Readme.md +4 -0
- package/index.js +4 -3
- package/package.json +1 -1
- package/src/device/device.js +5 -5
package/Changelog.md
CHANGED
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/index.js
CHANGED
|
@@ -92,12 +92,13 @@ var self = module.exports = {
|
|
|
92
92
|
await $.models.dropTableIndexes();
|
|
93
93
|
await $.models.sync();
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
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
|
package/package.json
CHANGED
package/src/device/device.js
CHANGED
|
@@ -62,11 +62,11 @@ var self = module.exports = {
|
|
|
62
62
|
.catch( (err) => {});
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
if
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
// update project id if needed
|
|
66
|
+
let res = await $.db_project.getByName(project_name);
|
|
67
|
+
let project_id = res?.id;
|
|
68
|
+
if(project_id != null && project_id != device?.project_id)
|
|
69
|
+
$.db_device.updateProject(uid,project_id);
|
|
70
70
|
|
|
71
71
|
if(topic.endsWith("status")){
|
|
72
72
|
if(payload == "online" || payload == "offline")
|