Closed rool80 closed 6 years ago
You'll probably want to set up an interval with setInterval()
in your Device
or Property
class (whichever makes the most sense to you) to read the temperature value periodically. After reading, you can do something like this:
// If inside Device class:
const value = temperature.toFixed(1);
temperatureProperty.setCachedValue(value);
this.notifyPropertyChanged(temperatureProperty);
// If inside Property class:
const value = temperature.toFixed(1);
this.setCachedValue(value);
this.device.notifyPropertyChanged(this);
If you haven't already read it, this blog post is an excellent reference as well.
Hello,
thank you very much for your help. Your advice helped me a lot. It works. thanks
Hello,
thank you very much for your help. Your advice helped me a lot. It works. thanks
st 17. 10. 2018 o 13:40 Michael Stegeman notifications@github.com napísal(a):
You'll probably want to set up an interval with setInterval() in your Device or Property class (whichever makes the most sense to you) to read the temperature value periodically. After reading, you can do something like this:
// If inside Device class:const value = temperature.toFixed(1);temperatureProperty.setCachedValue(value);this.notifyPropertyChanged(temperatureProperty); // If inside Property class:const value = temperature.toFixed(1);this.setCachedValue(value);this.device.notifyPropertyChanged(this);
If you haven't already read it, this blog post https://hacks.mozilla.org/2018/02/making-a-clap-sensing-web-thing/ is an excellent reference as well.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mozilla-iot/example-adapter/issues/12#issuecomment-430595080, or mute the thread https://github.com/notifications/unsubscribe-auth/ARtTy4fA0vxk0zNVUP2s5PDkz1vwYHkbks5ulxdHgaJpZM4XjOnZ .
Hello, I will try to create an adapter for DHT22 (AM2302). I use this library to read data from the DHT sensor. => node-dht-sensor
Now I downloaded example-adapter code. But I do not know where to put the temperature.toFixed (1) into the example-adapter code.
Will you please help me?