1.2.0 • Published 3 years ago

google-home-module v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Google Home Module

npm npm install size Lines of code Website

This module includes everything of Google Home!

Table of Contents

  1. Website & Documentation URL
    1. Website
    2. Documentation
  2. Installation
  3. Usage
    1. Weather
  4. Commands
    1. Variables
    2. Methods
    3. Classes

Website & Documentation URL

Website

See the website at https://arnavthorat78.github.io/Google-Home/.

Documentation

See the website at https://arnavthorat78.github.io/Google-Home/developer.html.

Installation

npm install google-home-module

It's that easy!

To then use it in your project, simple require it.

const googleHome = require("google-home-module");

Usage

Popular only! We only have the popular variables, methods and classes. Sorry for any inconvenience caused by this.

Weather

To get the weather, you can use the getWeather method, as described below. It returns a Promise with the data. Please note that the data is by default parsed.

googleHome
	.getWeather(
		"metric", // units: string
		"Melbourne", // city: string
		"VIC", // stateCode?: string
		"AUS" // countryCode?: string
	)
	.then((data) => {
		console.log(`In ${data.name}, it is ${data.temp.toFixed(1)} degrees Celcius.`);
	})
	.catch((err) => {
		console.log(err);
	});

This outputs...

In Melbourne, it is 20.2 degrees Celcius.

With the weather data, we can change some values that are non-human readable, and also add some values. The changeWeatherData method helps us with that.

googleHome
	.getWeather("metric", "Melbourne", "VIC", "AUS")
	.then((data) => {
		console.log(
			googleHome.changeWeatherData(
				data.weather[0].icon, // icon: string
				data.sys.sunrise, // sunrise: number
				data.sys.sunset // sunset: number
			)
		);
	})
	.catch((err) => {
		console.log(err);
	});

This should output something like this, depending on your data.

{
	"http://openweathermap.org/img/wn/03d@2x.png",
	"day",
	'readable-sunrise-date',
	'readable-sunset-date'
}
More are coming soon!

Commands

Variables

CommandsDescription
websiteVersion: stringDeprecated! Get the website version of the Google Home website.
version: stringDeprecated! Get the version of the Google Home Module NPM module.
keyboardShortcuts: { openHome: { definition: string, shortcut: string, ...more }, ...more }Get all of the keyboard shortcuts and the information from the website!

Methods

CommandsDescription
randomGreeting: (signedIn: boolean, username?: string) => stringGet a random greeting for the user.
getWeather: (units: string, city: string, stateCode?: string, countryCode?: string) => Promise<object>Get the weather for your location chosen.
changeWeatherData: (icon: string, sunrise: number, sunset: number) => { icon: string; dayNight: string; sunrise: string; sunset: string; }Change the format of the weather data retrieved with the getWeather method.

Classes

CommandsDescription
BasicSearch(query: string, searchEngine?: string): BasicSearchMake a new BasicSearch so the user can search with their desired search engine.
URLSearch(url: string): URLSearchMake a new URLSearch for a user to use.
SmartSearch(command: string): SmartSearchMake a new SmartSearch for a user to interact with.
User(displayName: string, email: string, password: string, exists?: boolean, admin?: boolean, signedOut?: boolean): UserMake a new User for a user's account.