-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
027595e
commit a0f59a8
Showing
36 changed files
with
680 additions
and
235 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 |
---|---|---|
|
@@ -4,3 +4,4 @@ node_modules/ | |
.idea/ | ||
/testing | ||
/.vscode | ||
/examples-build |
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,5 @@ | ||
Copyright (c) 2018 Daniel Freese | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
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
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,35 @@ | ||
var getHarmonyClient = require("../../packages/client/dist").getHarmonyClient; | ||
|
||
function test() { | ||
getHarmonyClient('192.168.0.31').then( | ||
(harmonyClient) => { | ||
return harmonyClient.getAvailableCommands().then((commands) => { | ||
|
||
// Look for the first device and pick its "power" control group, pick | ||
// there the "poweron" function and trigger it: | ||
var device = commands.device[0]; | ||
|
||
var powerControls = device.controlGroup | ||
.filter(function (group) { return group.name.toLowerCase() === 'power' }) | ||
.pop(); | ||
|
||
var powerOnFunction = powerControls['function'] | ||
.filter(function (action) { return action.name.toLowerCase() === 'poweron' }) | ||
.pop(); | ||
|
||
if (powerOnFunction) { | ||
var encodedAction = powerOnFunction.action.replace(/\:/g, '::'); | ||
harmonyClient.send('holdAction', 'action=' + encodedAction + ':status=press'); | ||
} else { | ||
throw new Error('could not find poweron function of first device :('); | ||
} | ||
}) | ||
.then( () => harmonyClient.end() ); | ||
}) | ||
.catch( | ||
(err) => console.log(err) | ||
); | ||
} | ||
|
||
test(); | ||
|
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,24 @@ | ||
import { getHarmonyClient } from "../../packages/client/dist"; | ||
|
||
async function run(): Promise<void> { | ||
const harmonyClient = await getHarmonyClient("192.168.0.31"); | ||
|
||
const encodedAction = `{"command"::"VolumeUp","type"::"IRCommand","deviceId"::"27633596"}`; | ||
const dt_press = `action=${encodedAction}:status=press`; | ||
const dt_release = `action=${encodedAction}:status=release`; | ||
|
||
try { | ||
const commands = await harmonyClient.getAvailableCommands(); | ||
console.log('commands', commands); | ||
await harmonyClient.send('holdAction', dt_press); | ||
await harmonyClient.send('holdAction', dt_release); | ||
|
||
harmonyClient.end(); | ||
} catch(error) { | ||
console.error('Error', error.message); | ||
} | ||
} | ||
|
||
run().catch( | ||
err => console.log(err) | ||
); |
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,30 @@ | ||
var getHarmonyClient = require("../../packages/client/dist").getHarmonyClient; | ||
|
||
async function testAsync() { | ||
var harmonyClient = await getHarmonyClient('192.168.0.31'); | ||
|
||
var commands = await harmonyClient.getAvailableCommands(); | ||
|
||
// Look for the first device and pick its "power" control group, pick | ||
// there the "poweron" function and trigger it: | ||
var device = commands.device[0]; | ||
|
||
var powerControls = device.controlGroup | ||
.filter(function (group) { return group.name.toLowerCase() === 'power' }) | ||
.pop(); | ||
|
||
var powerOnFunction = powerControls['function'] | ||
.filter(function (action) { return action.name.toLowerCase() === 'poweron' }) | ||
.pop(); | ||
|
||
if (powerOnFunction) { | ||
var encodedAction = powerOnFunction.action.replace(/\:/g, '::'); | ||
harmonyClient.send('holdAction', 'action=' + encodedAction + ':status=press'); | ||
} else { | ||
throw new Error('could not find poweron function of first device :('); | ||
} | ||
} | ||
|
||
testAsync().catch( | ||
err => console.log(err) | ||
); |
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,26 @@ | ||
var Explorer = require("../../packages/discover/dist").Explorer; | ||
|
||
const discover = new Explorer(51000); | ||
|
||
console.log( | ||
Explorer.Events | ||
); | ||
|
||
discover.on(Explorer.Events.ONLINE, function (hub) { | ||
console.log(hub); | ||
console.log('discovered ' + hub.ip); | ||
}); | ||
|
||
discover.on(Explorer.Events.OFFLINE, function (hub) { | ||
console.log('lost ' + hub.ip); | ||
}); | ||
|
||
discover.on(Explorer.Events.UPDATE, function (hubs) { | ||
const knownHubIps = hubs.reduce(function (prev, hub) { | ||
return prev + (prev.length > 0 ? ', ' : '') + hub.ip; | ||
}, ''); | ||
|
||
console.log('known ips: ' + knownHubIps); | ||
}); | ||
|
||
discover.start(); |
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,26 @@ | ||
import { Explorer, HubData } from "../../packages/discover/dist"; | ||
|
||
const discover = new Explorer(51000); | ||
|
||
console.log( | ||
Explorer.Events | ||
); | ||
|
||
discover.on(Explorer.Events.ONLINE, function (hub: HubData) { | ||
console.log(hub); | ||
console.log('discovered ' + hub.ip); | ||
}); | ||
|
||
discover.on(Explorer.Events.OFFLINE, function (hub: HubData) { | ||
console.log('lost ' + hub.ip); | ||
}); | ||
|
||
discover.on(Explorer.Events.UPDATE, function (hubs: Array<HubData>) { | ||
const knownHubIps = hubs.reduce(function (prev, hub) { | ||
return prev + (prev.length > 0 ? ', ' : '') + hub.ip; | ||
}, ''); | ||
|
||
console.log('known ips: ' + knownHubIps); | ||
}); | ||
|
||
discover.start(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Oops, something went wrong.