google-home-notify-client

0.3.2 • Public • Published

Google Home Notify Client

GitHub version Build Status npm version MIT License

Send notifications to Google Home

source: https://github.com/o-o-o/google-home-notify-client
npm: https://www.npmjs.com/package/google-home-notify-client

Installation

npm install google-home-notify-client

Usage

const { Scanner } = require('google-home-notify-client');
Scanner.name('Google Home').scan(device => {
  device.notify('Hello world.');
});

Scanner (Scan local network)

const { Scanner } = require('google-home-notify-client');
 
Scanner.scan(console.log);
 
// or
const scanner = new Scanner();
scanner.scan(console.log);

IP address filtering

Scanner.ip('192.168.11.1').scan(console.log);
 
// or
Scanner.ip(['192.168.11.1', '192.168.11.2']).scan(console.log);
 
// or
Scanner.ip('192.168.11.1').ip('192.168.11.2').scan(console.log);
 
// or
Scanner.ip('192.168.11.1', '192.168.11.2').scan(console.log);

Device name filtering

Scanner.name('Google Home').scan(console.log);
 
// or
Scanner.name(['Google Home', 'AQUOS']).scan(console.log);
 
// or
Scanner.name('Google Home').name('AQUOS').scan(console.log);
 
// or
Scanner.name('Google Home', 'AQUOS').scan(console.log);

Promise and timeout

const devices = await Scanner.timeout(10 * 1000).scan();
devices.forEach(console.log);

Device

const { Device } = require('google-home-notify-client');
const device = new Device('192.168.11.1', 'My Google Home');
 
// language and accent
const device = new Device('192.168.11.1', 'My Google Home', 'ja', 'ja');
// language and accent and speechSpeec and speechTimeout
const device = new Device('192.168.11.1', 'My Google Home', 'ja', 'ja', 1, 10 * 1000);

Notify (message)

device.notify('Hello World.');
 
// language and accent
device.language('ja').accent('ja').notify('こんにちは、世界。');
// speech speed (0.24 = slow), speech timeout
device.speechSpeed(0.24).speechTimeout(10 * 1000).notify('Slow Slow Slow.');
 
// use callback
device.notify('Hello World.', (error) => {
  if (error) {
    console.error(error)
  }
});
 
// use promise
try {
  await device.notify('Hello World.');
} catch (error) {
  console.error(error);
}

Play (mp3)

device.play('https://example.org/example.mp3');
 
// use callback
device.play('https://example.org/example.mp3', (error) => {
  if (error) {
    console.error(error)
  }
});
 
// use promise
try {
  await device.play('https://example.org/example.mp3');
} catch (error) {
  console.error(error);
}

Package Sidebar

Install

npm i google-home-notify-client

Weekly Downloads

8

Version

0.3.2

License

MIT

Unpacked Size

11 kB

Total Files

5

Last publish

Collaborators

  • o-o-o