Skip to content

Commit

Permalink
changed getTime in mqtt to getUnixTime for all instances
Browse files Browse the repository at this point in the history
  • Loading branch information
joyja committed Sep 23, 2020
1 parent ee67ba9 commit ddd67aa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/service/mqtt.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { Model, executeUpdate } = require(`../database`)
const sparkplug = require(`tentacle-sparkplug-client`)
const getTime = require('date-fns/getTime')
const getUnixTime = require('date-fns/getUnixTime')
const _ = require('lodash')
const logger = require('../logger')

Expand Down Expand Up @@ -154,19 +154,19 @@ class Mqtt extends Model {
}
onBirth() {
const payload = {
timestamp: getTime(new Date()),
timestamp: getUnixTime(new Date()),
metrics: [],
}
this.client.publishNodeBirth(payload)
this.sources.forEach((source) => {
this.client.publishDeviceBirth(`${source.device.name}`, {
timestamp: getTime(new Date()),
timestamp: getUnixTime(new Date()),
metrics: source.device.config.sources.map((source) => {
return {
name: source.tag.name,
value: `${source.tag.value}`,
type: source.tag.datatype,
timestamp: getTime(new Date()),
timestamp: getUnixTime(new Date()),
}
}),
})
Expand Down Expand Up @@ -228,7 +228,7 @@ class Mqtt extends Model {
logger.info(`Mqtt service ${this.service.name} is disconnecting.`)
this.stopPublishing()
const payload = {
timestamp: getTime(new Date()),
timestamp: getUnixTime(new Date()),
}
this.sources.forEach((source) => {
if (this.testNumber) {
Expand Down

0 comments on commit ddd67aa

Please sign in to comment.