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

web-toothbrush

v0.1.0

Published

Web Bluetooth based JS library for connecting to a smart toothbrush from your browser

Downloads

14

Readme

web-toothbrush

Yet another IoT JS library nobody asked for

Overview

This library is unofficial and I'm in no way associated with the manufacturers of these devices. Use at your own risk.

This is a simple JavaScript library that uses the Web Bluetooth API to connect a smart electric toothbrush that supports bluetooth.

Depending on the model allows you to read the current status during a session, modify settings or read data from previous sessions.

Usage

  1. Install using NPM.
npm i web-toothbrush
  1. Import the Toothbrush class.
import { Toothbrush } from 'web-toothbrush'
  1. Connect to your device and receive a BluetoothRemoteGATTServer object.
// This displays a dialog to the user
const device = await navigator.bluetooth.requestDevice({
  acceptAllDevices: true,
  optionalServices: Toothbrush.services // contains list of GATT services used
})

// Connect to the GATT server
const server = await device.gatt.connect()
  1. Make an instance of Toothbrush.
const toothbrush = new Toothbrush(server)
  1. Query some properties.
const batteryLife = toothbrush.getProperty('batteryLevel')
if (!await batteryLife.isAvailable()) {
  // tough luck, we can't query that property
}
console.log(await batteryLife.readValue())

Simple version

In most cases, you can just use Toothbrush.connect() if you don't want to worry about all the bluetooth connection trouble:

import { Toothbrush } from 'web-toothbrush'

[...]

const toothbrush = await Toothbrush.connect()
const batteryLife = toothbrush.getProperty('batteryLevel')
[...]

Supported properties

The following properties can be accessed via the bluetooth API. Availability depends on the model of your device.

General information

All of these properties are read-only.

  • handleId - the unique ID of the device
  • deviceType - the type of the device
  • userAccountId - ID of user account
  • batteryLevel - current battery percent
  • data - information about previous saved sessions

Current session

These properties are read only, but can be subscribed to and reflect the status of the current session in progress.

  • brushingTime - how long the toothbrush has been on
  • buttonState - whether a button is pressed and which
  • mode - current brushing mode
  • pressureSensor - whether a pressure sensor is currently triggered
  • quadrantProperty - the quadrant currently in progress
  • smiley - current "smiley" state
  • state - current toothbrush state

Configuration

These properties can be read or modified to affect the toothbrush behavior.

  • brushingModes - modes that can be triggered and used
  • brushingTimer - how the user is notified about the timer state
  • color - color of the LEDs
  • command - used internally by other properties to send commands
  • flightMode - used to enable or disable flight mode
  • pressure - how the user if notified about the pressure sensor
  • quadrantTimes - how much time is spent per quadrant
  • rtc - current time
  • timezone - current time zone / locale
  • tongueTime - how much time is spent in tongue cleaning mode

Supported devices

The following toothbrushes are currently supported by this library:

  • Oral-B Genius 9000
  • Oral-B Genius 8000
  • Oral-B Teen
  • Oral-B SmartSeries 6500
  • Oral-B Smart 5 5000N

Please refer to Web Bluetooth Community Group's Implementation Status to see which platforms currently support the (experimental) Web Bluetooth API.