Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
homeassistant
Advanced tools
Home Assistant API Node.js library. It wraps the Home Assistant RESTful API in easy-to-use, Promise-based functions.
npm install homeassistant
const HomeAssistant = require('homeassistant');
const hass = new HomeAssistant({
// 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
});
hass.services.call('toggle', 'switch', 'lights_3_0')
.then(res => console.log('Toggled lights', res))
.catch(err => console.error(err));
All functions return Promises.
// Returns if the API is up and running
hass.status();
// Returns the current configuration
hass.config();
// Returns basic information about the Home Assistant instance
hass.discoveryInfo();
// Returns all data needed to bootstrap Home Assistant
hass.bootstrap();
// Returns the image from the specified camera entity
hass.camera.image('entityId');
// Returns an array of event objects
hass.events.list();
// Fires an event
// Requires the event name and an event data JSON object
hass.events.fire('call_service', {
domain: 'switch',
service: 'toggle',
service_data: {
entity_id: 'switch.lights_3_0'
}
});
// 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 results
hass.history.state('2017-05-01T12:00:00-04:00', 'sensor.temperature');
// Returns all errors logged during the current session of Home Assistant
hass.logs.errors();
// Returns an array of all service objects
hass.services.list();
// Calls a service
// Requires the service, the domain, and the entity
// Alternatively, you can provide a service data JSON object as the third parameter
hass.services.call('toggle', 'switch', 'lights_3_0');
hass.services.call('toggle', 'switch', {
entity_id: 'switch.lights_3_0'
});
// Returns an array of all state objects
hass.states.list();
// Returns a state object for a specified entity
// Requires the domain and entity
hass.states.get('sensor', 'temperature');
// Updates or creates the current state of an entity
// Requires the domain, entity, and a JSON object with a `state` attribute
hass.states.update('sensor', 'temperature', {
state: 80,
attributes: {
unit_of_measurement: '°F'
}
});
// Renders a Home Assistant template: https://home-assistant.io/topics/templating/
hass.templates.render('Mike is at {{ states("device_tracker.mike") }}.');
MIT
FAQs
Home Assistant Node.js library
The npm package homeassistant receives a total of 19 weekly downloads. As such, homeassistant popularity was classified as not popular.
We found that homeassistant demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.