diff --git a/modules/samples/firealarm/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.firealarm.analytics-view/analytics-view.js b/modules/samples/firealarm/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.firealarm.analytics-view/analytics-view.js
index cc651dad..299a5b13 100644
--- a/modules/samples/firealarm/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.firealarm.analytics-view/analytics-view.js
+++ b/modules/samples/firealarm/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.firealarm.analytics-view/analytics-view.js
@@ -24,7 +24,7 @@ function onRequest(context) {
if (devices) {
return {
"devices": stringify(devices),
- "backendApiUri": devicemgtProps["httpsURL"] + "/firealarm/stats/"
+ "backendApiUri": devicemgtProps["httpsURL"] + "/firealarm/device/stats/"
};
} else if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
var deviceModule = require("/app/modules/device.js").deviceModule;
@@ -32,7 +32,7 @@ function onRequest(context) {
if (device && device.status != "error") {
return {
"device": device,
- "backendApiUrl": devicemgtProps["httpsURL"] + "/firealarm/stats/" + deviceId + "/sensors/"
+ "backendApiUrl": devicemgtProps["httpsURL"] + "/firealarm/device/stats/" + deviceId + "/sensors/"
};
} else {
response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!");
diff --git a/modules/samples/firealarm/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.firealarm.analytics-view/public/js/firealarm.js b/modules/samples/firealarm/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.firealarm.analytics-view/public/js/firealarm.js
index 7e643c31..af8e0c4c 100644
--- a/modules/samples/firealarm/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.firealarm.analytics-view/public/js/firealarm.js
+++ b/modules/samples/firealarm/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.firealarm.analytics-view/public/js/firealarm.js
@@ -26,6 +26,7 @@ function drawGraph_firealarm(from, to) {
var streamIndex = 0;
var streams = ["temperature", "humidity"];
+ populateGraph();
function populateGraph() {
retrieveDataAndDrawLineGraph(streams[streamIndex], from, to);
@@ -167,7 +168,6 @@ function drawGraph_firealarm(from, to) {
};
invokerUtil.get(backendApiUrl, successCallback, function (message) {
console.log(message);
- populateGraph();
});
}
diff --git a/modules/samples/firealarm/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.firealarm.realtime.analytics-view/analytics-view.hbs b/modules/samples/firealarm/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.firealarm.realtime.analytics-view/analytics-view.hbs
index 94422646..2967d0cf 100644
--- a/modules/samples/firealarm/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.firealarm.realtime.analytics-view/analytics-view.hbs
+++ b/modules/samples/firealarm/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.firealarm.realtime.analytics-view/analytics-view.hbs
@@ -22,20 +22,12 @@
diff --git a/modules/samples/firealarm/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.firealarm.realtime.analytics-view/public/js/device-stats.js b/modules/samples/firealarm/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.firealarm.realtime.analytics-view/public/js/device-stats.js
index 29ad42cf..d7299ad9 100644
--- a/modules/samples/firealarm/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.firealarm.realtime.analytics-view/public/js/device-stats.js
+++ b/modules/samples/firealarm/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.firealarm.realtime.analytics-view/public/js/device-stats.js
@@ -58,7 +58,7 @@ function lineGraph(type, chartData) {
series: [{
'color': palette.color(),
'data': chartData,
- 'name': type
+ 'name': type && type[0].toUpperCase() + type.slice(1)
}]
});
@@ -75,22 +75,17 @@ function lineGraph(type, chartData) {
orientation: 'left',
height: 300,
tickFormat: Rickshaw.Fixtures.Number.formatKMBT,
- element: document.getElementById('y_axis')
+ element: document.getElementById('y_axis-' + type)
});
- new Rickshaw.Graph.Legend({
- graph: graph,
- element: document.getElementById('legend-' + type)
- });
-
- new Rickshaw.Graph.HoverDetail({
- graph: graph,
- formatter: function (series, x, y) {
- var date = '
' + moment(x * 1000).format('Do MMM YYYY h:mm:ss a') + '';
- var swatch = '
';
- return swatch + series.name + ": " + parseInt(y) + '
' + date;
- }
- });
+ new Rickshaw.Graph.HoverDetail({
+ graph: graph,
+ formatter: function (series, x, y) {
+ var date = '
' + moment(x * 1000).format('Do MMM YYYY h:mm:ss a') + '';
+ var swatch = '
';
+ return swatch + series.name + ": " + parseInt(y) + '
' + date;
+ }
+ });
return graph;
}
@@ -108,9 +103,9 @@ function connect(target) {
ws.onmessage = function (event) {
var dataPoint = JSON.parse(event.data);
if (dataPoint) {
- var time = parseInt(dataPoint[4]) / 1000;
- graphUpdate(temperatureData, time, dataPoint[5], temperature);
- graphUpdate(humidityData, time, dataPoint[6], humidity);
+ var time = parseInt(dataPoint[0]) / 1000;
+ graphUpdate(temperatureData, time, dataPoint[3], temperature);
+ graphUpdate(humidityData, time, dataPoint[4], humidity);
}
};
}
@@ -125,15 +120,6 @@ function graphUpdate(chartData, xValue, yValue, graph) {
graph.update();
}
-function dataUpdate(chartData, xValue, yValue) {
- chartData.push({
- x: parseInt(xValue),
- y: parseFloat(yValue)
- });
- chartData.shift();
-}
-
-
function disconnect() {
if (ws != null) {
ws.close();
diff --git a/modules/samples/firealarm/feature/feature/src/main/resources/agent/read-sensor.lua b/modules/samples/firealarm/feature/feature/src/main/resources/agent/read-sensor.lua
index 1cea5351..d039bc93 100644
--- a/modules/samples/firealarm/feature/feature/src/main/resources/agent/read-sensor.lua
+++ b/modules/samples/firealarm/feature/feature/src/main/resources/agent/read-sensor.lua
@@ -16,7 +16,7 @@ tmr.alarm(0, 10000, 1, function()
print("Error reading from DHTxx")
else
if (client_connected) then
- local payload = "{event:{metaData:{owner:\"${DEVICE_OWNER}\",type:\"firealarm\",deviceId:\"${DEVICE_ID}\"},payloadData:{temperature:" .. t .. ", humidity:" .. h .. "}}}"
+ local payload = "{event:{metaData:{owner:\"${DEVICE_OWNER}\",deviceId:\"${DEVICE_ID}\"},payloadData:{temperature:" .. t .. ", humidity:" .. h .. "}}}"
m:publish("carbon.super/firealarm/${DEVICE_ID}/data", payload, 0, 0, function(client)
print("Published> Temperature: " .. t .. "C Humidity: " .. h .. "%")
end)