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

tidbyt

v1.1.3

Published

API Client for Tidbyt devices

Downloads

35

Readme

Tidbyt Client for Node.js

Unofficial API client for the Tidbyt API. Use this client to control Tidbyt devices and integrate with other services.

Installation

You can install the package with npm:

> npm install tidbyt

Usage

const Tidbyt = require('tidbyt')

async function main() {
    const deviceId = process.argv[2]
    const tidbyt = new Tidbyt(process.env.TIDBYT_API_TOKEN)

    // get our requested device
    const device = await tidbyt.devices.get(deviceId)
    const { displayName, lastSeen } = device

    console.log(displayName, `Last Seen: (${lastSeen})`)

    // get a list of officially available apps
    // return as map so we can lookup app name/descriptions by id
    const apps = await tidbyt.apps.list({ asMap: true })

    // get the list of installations for this device
    const installations = await device.installations.list()

    for (const { id, appID } of installations) {
        const {
            name = 'Custom',
            description = `Unlike a regular Tidbyt app, this "installation" was pushed to ${displayName} via Tidbyt's API.`,
        } = apps.get(appID) || {}

        console.log(``)
        console.log(`  ${name} - ${id}`)
        console.log(`      ${description}`)
    }
}
main()

Classes

TidbytDevice

Kind: global class
Scope: Tidbyt

new TidbytDevice(options, client)

Construct a TidbytDevice with provided options.

A valid client is required to use any methods.

Available options:

 - `id`: the device id

 - `lastSeen`: the last time the device was seen

 - `brightness`: the brightness of the device from 0-100

 - `displayName`: the display name of the device

 - `autoDim`: whether the device is auto dimming at night

| Param | Type | | --- | --- | | options | Object | | client | TidByt |

tidbytDevice.installations : object

Kind: instance property of TidbytDevice

installations.list() ⇒ Promise.<Array.<TidbytDeviceInstallation>>

Return a list of installations on the device from the Tidbyt API.

Kind: instance method of installations

installations.update(installationID, imageOrConfig) ⇒ Promise.<Object>

Update an existing installation, either by providing a config object or a buffer containing the image.

Note: Updating configuration only works on Tidbyt-hosted applications. Push an updated image to update custom applications.

Throws if not client is intialized or if no installation ID is provided. Throws if an invalid image or config is provided.

Kind: instance method of installations

| Param | Type | Description | | --- | --- | --- | | installationID | String | Optional installation ID to create/update | | image | Buffer | Buffer containing the images to push |

installations.delete(installationID) ⇒ Promise.<Object>

Delete an existing installation from the device.

Throws if not client is intialized.

Kind: instance method of installations

| Param | Type | Description | | --- | --- | --- | | installationID | String | Optional installation ID to create/update |

tidbytDevice.update(updates) ⇒ Promise.<TidbytDevice>

Update a device with the provided values.

Throws if not client is intialized.

Available fields:

 - `autoDim`: whether the device is auto dimming at night

 - `brightness`: the brightness of the device from 0-100

 - `displayName`: the display name of the device

Kind: instance method of TidbytDevice

| Param | Type | | --- | --- | | updates | Object |

tidbytDevice.push(image, options) ⇒ Promise.<Object>

Push a new installation to the device.

Throws if not client is intialized.

Available options:

installationID: Installation ID to create/update

background: Whether the installation should not interrupt the rotation

Kind: instance method of TidbytDevice

| Param | Type | Description | | --- | --- | --- | | image | Buffer | Buffer containing the images to push | | options | Object | |

Tidbyt

Kind: global class

new Tidbyt(apiToken, version)

Construct a Tidbyt with provided options.

Available options:

 - `apiToken`: the API token

 - `apiVersion`: the API version. Defaults to `v0`

| Param | Type | Default | | --- | --- | --- | | apiToken | String | | | version | String | 'v0' |

tidbyt.apps : object

Kind: instance property of Tidbyt

apps.list(options) ⇒ Promise.<(Array.<Object>|Map)>

Return a list of available apps from the Tidbyt API.

Available options:

 - `asMap`: Defaults to false. If true, returns a map of app ids to app objects instead of an array of app objects.

Kind: instance method of apps

| Param | Type | | --- | --- | | options | Object |

tidbyt.devices : object

Kind: instance property of Tidbyt

devices.get(deviceId) ⇒ Promise.<TidbytDevice>

Get a device by id from the Tidbyt API.

Kind: instance method of devices

| Param | Type | Description | | --- | --- | --- | | deviceId | String | The device id |

devices.update(deviceId, updates) ⇒ Promise.<TidbytDevice>

Update a device with the provided values by ID.

Available updates:

 - `autoDim`: whether the device is auto dimming at night

 - `brightness`: the brightness of the device from 0-100

 - `displayName`: the display name of the device

Kind: instance method of devices

| Param | Type | Description | | --- | --- | --- | | deviceId | String | The device id | | updates | Object | |

devices.push(deviceId, image, [options]) ⇒ Promise.<Object>

Push a new installation to a device by ID.

Throws if not client is intialized.

Available options:

installationID: Installation ID to create/update

background: Whether the installation should not interrupt the rotation

Kind: instance method of devices

| Param | Type | Description | | --- | --- | --- | | deviceId | String | The device id | | image | Buffer | Buffer containing the images to push | | [options] | Object | Push options |

tidbyt.request(path, method, body, headers, raw, encoding) ⇒ Promise.<(Object|Buffer)>

Send a request to the Tidbyt API.

Kind: instance method of Tidbyt

| Param | Type | Default | | --- | --- | --- | | path | String | | | method | String | 'GET' | | body | Object | | | headers | Object | {} | | raw | Boolean | | | encoding | String | |