node-homeassistant
Home Assistant API Node.js library. It wraps the Home Assistant RESTful API in easy-to-use, Promise-based functions.
Install
npm install homeassistant
Usage
const HomeAssistant = ;const hass = // Your Home Assistant host // Optional, defaults to http://locahost host: 'http://example.com' // Your Home Assistant port number // Optional, defaults to 8123 port: 8123 // Your long lived access token generated on your profile page. // Optional token: '810a8c43-f22e-4ec4-b34e-c1e4741d4802' // Your Home Assistant Legacy API password // Optional // password: 'api_password', // Ignores SSL certificate errors, use with caution // Optional, defaults to false ignoreCert: false; hassservices ;
Interface
All functions return Promises.
Configuration
// Returns if the API is up and runninghassstatus; // Returns the current configurationhass; // Returns basic information about the Home Assistant instancehass; // Returns all data needed to bootstrap Home Assistanthass;
Camera
// Returns the image from the specified camera entityhasscamera;
Events
// Returns an array of event objectshassevents; // Fires an event// Requires the event name and an event data JSON objecthassevents;
History
// Returns an array of state changes in the past// Requires a datetime in YYYY-MM-DDTHH:MM:SSZ format// An optional entityId can be provided to filter the resultshasshistory;
Logs
// Returns all errors logged during the current session of Home Assistanthasslogs;
Services
// Returns an array of all service objectshassservices; // Calls a service// Requires the service, the domain, and the entity// Alternatively, you can provide a service data JSON object as the third parameterhassservices;hassservices;
States
// Returns an array of all state objectshassstates; // Returns a state object for a specified entity// Requires the domain and entityhassstates; // Updates or creates the current state of an entity// Requires the domain, entity, and a JSON object with a `state` attributehassstates;
Templates
// Renders a Home Assistant template: https://home-assistant.io/topics/templating/hasstemplates;
License
MIT