Created
July 1, 2020 16:42
-
-
Save garo/49c986e5a0ca98587e5beca15701127e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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