Open personalnadir opened 5 years ago
I observe something similar. I built my own WebThing (a temperature Sensor) and wanted to log the temperature over time. The WebThing was able to connect and in things view I can view the correct values (e.g. 22°C). The logging graph works for a small amount of time. But at some point the graph fails to render. See the picture below.
My javascript console logs for this page of the gateway are:
...
[webrtc_vad.js status] <empty string> stm_web.min.js:1:4693
Unexpected value NaN when parsing the attribute y. 2 log.js:246:8
[webrtc_vad.js status] Exception thrown, see JavaScript console stm_web.min.js:1:4693
TypeError: value.toFixed is not a function
log.js:609:24
[webrtc_vad.js error] [post-exception status] Exception thrown, see JavaScript console stm_web.min.js:1:4615
TypeError: value.toFixed is not a function
log.js:609:24
[webrtc_vad.js error] [post-exception status] Exception thrown, see JavaScript console stm_web.min.js:1:4615
TypeError: value.toFixed is not a function
log.js:609:24
[webrtc_vad.js error] [post-exception status] Exception thrown, see JavaScript console stm_web.min.js:1:4615
TypeError: value.toFixed is not a function
log.js:609:24
...
This is repeated like a hundred times.
The same sensor (WebThing) delivers humidity values, for which the graph works as expected (now 1 day of data).
@rmeissn is it possible that you’re sending the value as a string, rather than a number?
@mrstegeman I'm doing:
class DHT22 extends Thing {
constructor(sensorPin) {
super(
uuidv4(),
'DHT22',
['MultiLevelSensor'],
'A web connected temperature und humidity sensor'
);
this.temperature = new Value(0.0);
this.humidity = new Value(0.0);
this.addProperty(new Property(this, 'Humidity', this.humidity, {
'@type': 'LevelProperty',
title: 'Humidity',
type: 'number',
description: 'The current humidity in %',
minimum: 0,
maximum: 100,
unit: 'percent',
readOnly: true
})
);
this.addProperty(new Property(this, 'Temperature', this.temperature, {
'@type': 'LevelProperty',
title: 'Temperature',
type: 'number',
description: 'The current temperature in °C',
minimum: -40,
maximum: 80,
unit: 'degree celsius',
readOnly: true
})
);
this.readAndUpdate = function () {
const that = this;
sensorlib.read(22, sensorPin, function (err, Stemperature, Shumidity) {
if(!err) {
const temp = Stemperature.toFixed(1);
const humid = Shumidity.toFixed(1);
console.log('Setting new levels for pin ' + sensorPin + ':', "T:" + temp + "C, H:" + humid + "%");
that.temperature.notifyOfExternalUpdate(temp);
that.humidity.notifyOfExternalUpdate(humid);
that.emit('update')
}
});
};
this.readAndUpdate = this.readAndUpdate.bind(this);
this.readAndUpdate();
setInterval(this.readAndUpdate, 300000);
}
}
The code is mostly adapted from the examples in https://github.com/mozilla-iot/webthing-node/tree/master/example You'll see that it's exactly the same for humidity and temperature. Humidity is working fine in the gateway, temperature is not.
toFixed()
returns a string, not a number.
Uups, I'm sorry. You're totally right. Now it works as expected for me and the graphs are correctly drawn.
I'm trying to log the temperature from a Fibaro multisensor. However when I open the log the y axis is labelled NaN.
Opening the Javascript console I'm seeing the following output:
I've noticed that the data from the sensor seems to be logged in the metricsOther table.
As it stands the data is:
The metric IDs are:
The device seems to update its values correctly.
I pulled this data from the things database: