Skip to content

Instantly share code, notes, and snippets.

@garo
Created July 1, 2020 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garo/49c986e5a0ca98587e5beca15701127e to your computer and use it in GitHub Desktop.
Save garo/49c986e5a0ca98587e5beca15701127e to your computer and use it in GitHub Desktop.
// This program receives BLE advertisements from www.streamsave.fi shower consumption devices and displays the data inside.
// Installation: see https://www.npmjs.com/package/@abandonware/noble
const noble = require('@abandonware/noble');
noble.on('stateChange', async (state) => {
if (state === 'poweredOn') {
noble.startScanning([], true);
}
});
noble.on('discover', async (peripheral) => {
if (peripheral.advertisement.localName != "SHOWER") {
return;
}
const duration_in_seconds = peripheral.advertisement.manufacturerData.readUInt16BE(9);
const temperature = peripheral.advertisement.manufacturerData.readUInt16BE(11) / 10.0;
const litres = peripheral.advertisement.manufacturerData.readUInt16BE(13);
const id = peripheral.advertisement.manufacturerData.readUInt16BE(15);
console.log("Streamsave", id, "RSSI:", peripheral.rssi, "duration:", duration_in_seconds, "temperature:", temperature, "litres:", litres);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment