npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

situscale

v2.0.4

Published

Node.js interface for reading data from Situscale bluetooth weighing scale (http://situscale.com/).

Downloads

4

Readme

situscale

Node.js interface for reading data from SITU® Smart Food Nutrition Scale over a bluetooth low energy connection.

Badges

npm version npm bitHound Overall Score bitHound Dependencies bitHound Code Gratipay Tips

Description

This package allows you to set up asynchronous notifications for weight update notifications from SITU scale.

SITU Scale

Dependencies

Ubuntu/Debian/Raspbian

$ sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev

Fedora/RPM Based

$ sudo yum install bluez bluez-libs bluez-libs-devel

Install

You can install this package with npm.

npm

$ npm install situscale

Using the command line helper

When you install this module, you will also find a new command available to you to test if you are able to detect situscales in your vicinity.

$ search-situscales
  Discovered SITU scale with address:  c6:e3:c7:5e:fd:fc
  0 'Received from scale with address' 'c6:e3:c7:5e:fd:fc'
  0 'Received from scale with address' 'c6:e3:c7:5e:fd:fc'
  0 'Received from scale with address' 'c6:e3:c7:5e:fd:fc'
  0 'Received from scale with address' 'c6:e3:c7:5e:fd:fc'
  0 'Received from scale with address' 'c6:e3:c7:5e:fd:fc'
  627 'Received from scale with address' 'c6:e3:c7:5e:fd:fc'
  627 'Received from scale with address' 'c6:e3:c7:5e:fd:fc'
  627 'Received from scale with address' 'c6:e3:c7:5e:fd:fc'
  1165 'Received from scale with address' 'c6:e3:c7:5e:fd:fc'
  1165 'Received from scale with address' 'c6:e3:c7:5e:fd:fc'
  1165 'Received from scale with address' 'c6:e3:c7:5e:fd:fc'
  522 'Received from scale with address' 'c6:e3:c7:5e:fd:fc'
  522 'Received from scale with address' 'c6:e3:c7:5e:fd:fc'
  522 'Received from scale with address' 'c6:e3:c7:5e:fd:fc'

Synopsis

var SituScale = require('situscale');

var scaleInstance = new SituScale(address);

Discovering Situscales in your vicinity

You can discover situscales in your vicinity using this module if you do not have the address for your situscale.

// discover.js
"use strict";
var SituScale = require("./situscale").SituScale;
SituScale.searchScales(function (scale) {
    console.log("Discovered SITU scale with address: ", scale.address);

    // Set weight callback for the discovered scale
    scale.callback = function (weight) {
        console.log(weight, " from scale ", scale.address);
    };

    // Stop weight notifications after 3 seconds
    setTimeout(
      scale.pauseNotifications(),
      3000
    );
});
// discover.ts or ES2015
import { SituScale } from "situscale";

SituScale.searchScales((scale) => {
  console.log("Discovered SITU scale with address: ", scale);
  scale.callback = (weight) => {
    console.log(weight, scale.address);
  }
});

Receiving weight notifications from a specific SITU scale

Once you know the address for your SITU scale you can receive weight notifications from it as and when they happen. Note that the weight is always received in grams and you must convert it to other unit of calculation if you need to.

// getWeight.js
"use strict";
var SituScale = require("situscale").SituScale;
var scale = new SituScale("c6:e3:c7:5e:fd:fc", function (weight) {
    console.log(weight);
});

setTimeout(function () {
    console.log('stopping notifications');
    scale.pauseNotifications();
    setTimeout(function () {
        console.log('starting notifications');
        scale.startNotifications();
    }, 4000);
}, 4000);
// getWeight.ts or ES2015
import { SituScale } from "./situscale";

let scale = new SituScale("c6:e3:c7:5e:fd:fc", (weight) => {
  console.log(weight);
});

// Stop weight notifications after 4 seconds 
setTimeout(function(){
  console.log('stopping notifications');
  scale.pauseNotifications();
 
  // Start weight notifications after another 4 seconds 
  setTimeout(function(){
    console.log('starting notifications');
    scale.startNotifications();
  }, 4000);
}, 4000);

Receiving weight notifications from all the SITU scales in your vicinity (new syntax since v2.0.0)

If you wish to receive notifications from all available SITU scales in your vicinity without knowing the address of the SITU scales, then you may use the searchScales function.

Javascript

"use strict";
var SituScale = require("./situscale").SituScale;
SituScale.searchScales(function (scale) {
    // Set weight callback for the discovered scale to receive weight notifications
    scale.callback = function (weight) {
        console.log(weight, " from scale ", scale.address);
    };
});

ES2015 or Typescript

import { SituScale } from "situscale";

SituScale.searchScales((scale) => {
  scale.callback = (weight) => {
    console.log(weight, " from scale ", scale.address);
  }
});

Turning weight notifications on or off after connecting.

You can turn off weight notifications and turn them on as needed intermittently to save scale battery. The scale will still be connected on bluetooth but it will not send notifications while the notifications are turned off this way.

Javascript

var SituScale = require("situscale").SituScale;
var scale = new SituScale("c6:e3:c7:5e:fd:fc", function (weight) {
    console.log(weight);
});

setTimeout(function () {
    console.log('stopping notifications');
    scale.pauseNotifications();
    setTimeout(function () {
        console.log('starting notifications');
        scale.startNotifications();
    }, 4000);
}, 4000);

ES2015 or Typescript

import { SituScale } from "./situscale";

let scale = new SituScale("c6:e3:c7:5e:fd:fc", (weight) => {
  console.log(weight);
});

setTimeout(function(){
  console.log('stopping notifications');
  scale.pauseNotifications();
 
  setTimeout(function(){
    console.log('starting notifications');
    scale.startNotifications();
  }, 4000);
}, 4000);

Disconnecting from the scale

You can disconnect from the SITU scale when you are done using it. Note that in disconnected state the scale will automatically power down after some time.

var SituScale = require("situscale").SituScale;
var scale = new SituScale("c6:e3:c7:5e:fd:fc", function (weight) {
    console.log(weight);
});


// Stop weight notifications after 3 seconds
setTimeout(function(){
  scale.pauseNotifications();
  console.log('stopped notifications');
  setTimeout(function(){
    scale.disconnect();
    console.log('disconnected');
  }, 3000);
});

License

The MIT License

Copyright (c) Shantanu Bhadoria. https://www.shantanubhadoria.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

##Copyrights and Trademarks All labels including SITU® Smart Food Nutrition are trademarks of their respective owners. Please refer http://situscale.com/copyrights-trademarks/ for trademark information. Permission has been sought and received from SITU to release this module under the MIT license.