-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# node-googlehome | ||
It uses Node.js to communicate with Google Home. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const googlehome = require('./index') | ||
|
||
googlehome.search(1000) | ||
.then(resp => console.log(resp)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const search = require('./lib/search') | ||
|
||
module.exports = {search: search} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const mdns = require('mdns'), | ||
browser = mdns.createBrowser(mdns.tcp('googlecast')) | ||
|
||
async function search(waitTime = 1000) { | ||
|
||
let services = [] | ||
|
||
browser.start() | ||
browser.on('serviceUp', service => { services.push(service) }) | ||
await new Promise(resolve => setTimeout(resolve, 1000)) | ||
browser.stop() | ||
|
||
return services | ||
.filter(service => { if(service.txtRecord.md === 'Google Home') return service }) | ||
.map(service => { return Object.assign(service.txtRecord, {address: service.addresses[0]}) }) | ||
} | ||
|
||
module.exports = search |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "node-googlehome", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"repository": "https://github.com/Ghostrick/node-googlehome", | ||
"author": "_Ghostrick_ <[email protected]>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"mdns": "^2.3.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
bindings@~1.2.1: | ||
version "1.2.1" | ||
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.2.1.tgz#14ad6113812d2d37d72e67b4cacb4bb726505f11" | ||
|
||
mdns@^2.3.4: | ||
version "2.3.4" | ||
resolved "https://registry.yarnpkg.com/mdns/-/mdns-2.3.4.tgz#650380ac76089430cf6c8981a945dbd27d02f5b7" | ||
dependencies: | ||
bindings "~1.2.1" | ||
nan "~2.3.0" | ||
|
||
nan@~2.3.0: | ||
version "2.3.5" | ||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.3.5.tgz#822a0dc266290ce4cd3a12282ca3e7e364668a08" |