Skip to content

Instantly share code, notes, and snippets.

@garo
Created Jul 1, 2020
Embed
What would you like to do?
// 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