README
Google Home Module
This module includes everything of Google Home!
Table of Contents
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
Commands | Description |
---|---|
websiteVersion: string |
Deprecated! Get the website version of the Google Home website. |
version: string |
Deprecated! 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
Commands | Description |
---|---|
randomGreeting: (signedIn: boolean, username?: string) => string |
Get 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
Commands | Description |
---|---|
BasicSearch(query: string, searchEngine?: string): BasicSearch |
Make a new BasicSearch so the user can search with their desired search engine. |
URLSearch(url: string): URLSearch |
Make a new URLSearch for a user to use. |
SmartSearch(command: string): SmartSearch |
Make a new SmartSearch for a user to interact with. |
User(displayName: string, email: string, password: string, exists?: boolean, admin?: boolean, signedOut?: boolean): User |
Make a new User for a user's account. |