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

node-homeassistant

v1.6.0

Published

A simple package to access & controll home-assistant from node.js using the websocket api.

Downloads

59

Readme

Node.js api for home-assistant

A simple package to access & controll home-assistant from node.js using the websocket api.

Installation

$ npm install node-homeassistant

Usage

Create a new Homeassistant object:

const Homeassistant = require('node-homeassistant')

let ha = new Homeassistant({
  host: '192.168.1.166',
  protocol: 'ws', // "ws" (default) or "wss" for SSL
  retryTimeout: 1000, // in ms, default is 5000
  retryCount: 3, // default is 10, values < 0 mean unlimited
  password: 'http_api_password', // api_password is getting depricated by home assistant
  token: 'access_token' // for now both tokens and api_passwords are suported
  port: 8123
})

ha.connect().then(() => {
  // do stuff
})

Access & subscribe to states:

console.log(ha.state('sun.sun'))


ha.on('state:media_player.spotify', data => console.log)

Call services:

ha.call({
     domain: 'light',
     service: 'turn_on'
   })

You can subscribe to the 'connection' event to get information about the websocket connection.

ha.on('connection', info => {
  console.log('connection state is', info)
})

See the example folders for a working demo.

License

MIT