Skip to content

Commit

Permalink
Merge pull request #65 from svrooij/beta
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
svrooij committed Jun 30, 2020
2 parents 46b95b1 + d975c1f commit 26d3173
Show file tree
Hide file tree
Showing 26 changed files with 26,154 additions and 1,503 deletions.
3 changes: 2 additions & 1 deletion .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"repoHost": "https://github.com",
"files": [
"README.md",
"docs/development.md"
"docs/development.md",
"docs/index.md"
],
"imageSize": 100,
"commit": true,
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ on:
branches:
- master
- beta
paths-ignore:
- 'docs/**'
- 'README.md'
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'

jobs:
build-and-test:
Expand Down
9 changes: 4 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
},
"env": {
"SONOS_HOST":"192.168.96.53",
"SONOS_TTS_ENDPOINT": "false"
"SONOS_HOST":"192.168.96.56"
},
},
{
Expand All @@ -53,7 +52,6 @@
},
"env": {
"SONOS_HOST":"192.168.96.56",
"SONOS_TTS_ENDPOINT": "false"
},
},
{
Expand All @@ -62,9 +60,10 @@
"name": "Debug generator",
"program": "${workspaceFolder}/src/generator/service-generator.js",
"args": [
"--generate",
"--save-description",
"--docs"
"--docs",
"--load-files",
"--generate"
],
"console": "integratedTerminal",
"sourceMaps": true,
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ A node library to control a sonos device, written in Typescript. See [here](#imp

To use the library just add it to your project. `npm install @svrooij/sonos`. And start using it. This library isn't meant to be used by itself, as you see in the [examples](./examples) you still need to use node (or typescript).

See **[Documentation](https://svrooij.github.io/node-sonos-ts/getting-started.html)**

[![Documentation](./img/book.png)](https://svrooij.github.io/node-sonos-ts/getting-started.html)

## Use Sonos manager
Expand Down
33 changes: 32 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,42 @@ This library is in no way connected to [Sonos](//en.wikipedia.org/wiki/Sonos). I

|Name|Maintainer|Description|
|----|----------|----------|
|[sonos2mqtt](//github.com/svrooij/sonos2mqtt)|[@svrooij](//github.com/svrooij)|A bridge between sonos and mqtt, so you can control all your sonos devices right from your mqtt server|
|[sonos2mqtt](https://svrooij.github.io/sonos2mqtt)|[@svrooij](//github.com/svrooij)|A bridge between sonos and mqtt, so you can control all your sonos devices right from your mqtt server|
|[sonos-cli](//github.com/svrooij/sonos-cli)|[@svrooij](//github.com/svrooij)|An experimental command line interface for your sonos devices.|

Also using this library, but not in the list? Send a PR.

## Additional packages

|Name|Maintainer|Description|
|----|----------|----------|
|[sonos-tts-polly](//github.com/svrooij/node-sonos-tts-polly)|[@svrooij](//github.com/svrooij)|Amazon polly [text-to-speech server](https://static.svrooij.nl/node-sonos-ts/sonos-device/notifications-and-tts.html#text-to-speech)|

## Contributors ✨

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://svrooij.nl"><img src="https://avatars2.githubusercontent.com/u/1292510?v=4" width="100px;" alt=""/><br /><sub><b>Stephan van Rooij</b></sub></a><br /><a href="https://github.com/svrooij/node-sonos-ts/commits?author=svrooij" title="Code">💻</a> <a href="https://github.com/svrooij/node-sonos-ts/commits?author=svrooij" title="Documentation">📖</a> <a href="#ideas-svrooij" title="Ideas, Planning, & Feedback">🤔</a> <a href="#maintenance-svrooij" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/cheanrod"><img src="https://avatars3.githubusercontent.com/u/35066927?v=4" width="100px;" alt=""/><br /><sub><b>Sven Werner</b></sub></a><br /><a href="https://github.com/svrooij/node-sonos-ts/commits?author=cheanrod" title="Code">💻</a></td>
</tr>
</table>

<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors)
specification. Contributions of any kind welcome!

[badge_sponsor]: https://img.shields.io/badge/Sponsor-on%20Github-red
[badge_issues]: https://img.shields.io/github/issues/svrooij/node-sonos-ts
[badge_npm]: https://img.shields.io/npm/v/@svrooij/sonos
Expand Down
27 changes: 27 additions & 0 deletions docs/sonos-device/notifications-and-tts.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,31 @@ sonos.PlayTTS({
})
```

## Notifications on all speakers

If you use the **SonosManager** (the recommended way to use this library), you can also play a notification on all groups by sending the same command to the SonosManager instead of the individual speaker.
You can also use the manager for text-to-speech, `manager.PlayTTS(..)`

```js
const SonosManager = require('../lib').SonosManager
const manager = new SonosManager()

// Do device discovery
// manager.InitializeWithDiscovery(10)
// Connect known device
manager.InitializeFromDevice(process.env.SONOS_HOST || '192.168.96.56')
.then(console.log)
.then(() => {
return manager.PlayNotification({
trackUri: 'https://cdn.smartersoft-group.com/various/pull-bell-short.mp3', // Can be any uri sonos understands
// trackUri: 'https://cdn.smartersoft-group.com/various/someone-at-the-door.mp3', // Cached text-to-speech file.
onlyWhenPlaying: true, // make sure that it only plays when you're listening to music. So it won't play when you're sleeping.
timeout: 10, // If the events don't work (to see when it stops playing) or if you turned on a stream, it will revert back after this amount of seconds.
volume: 15, // Set the volume for the notification (and revert back afterwards)
delayMs: 700 // Pause between commands in ms, (when sonos fails to play notification often).
})
})
.catch(console.error)
```

[link_sponsor]: https://github.com/sponsors/svrooij
18 changes: 18 additions & 0 deletions docs/sonos-device/services/htcontrolservice.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,21 @@ No parameters
|:----------|:-----|:------------|
| **LEDFeedbackState** | `string` | |

## HTControlService event

```js
const SonosDevice = require('@svrooij/sonos').SonosDevice
const sonos = new SonosDevice('192.168.x.x')
sonos.HTControlService.Events('serviceEvent', (data) => {
console.log(data);
});
```

The **HTControlService** emits events with these properties. Not all properties are emitted everytime.

| parameter | type |
|:----------|:-----|
| **IRRepeaterState** | `string` |
| **LEDFeedbackState** | `string` |
| **RemoteConfigured** | `boolean` |
| **TOSLinkConnected** | `boolean` |
6 changes: 6 additions & 0 deletions examples/get-zone-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ sonos.DevicePropertiesService.GetZoneAttributes()
// console.log(description)
// })
// .catch(console.error)

sonos.GetDeviceDescription()
.then(properties => {
console.log(properties)
})
.catch(console.error)
8 changes: 8 additions & 0 deletions examples/use-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ manager.InitializeFromDevice(process.env.SONOS_HOST || '192.168.96.56')
console.log('New simple state for %s %s', d.Name, state)
})
})
return manager.PlayNotification({
trackUri: 'https://cdn.smartersoft-group.com/various/pull-bell-short.mp3', // Can be any uri sonos understands
// trackUri: 'https://cdn.smartersoft-group.com/various/someone-at-the-door.mp3', // Cached text-to-speech file.
onlyWhenPlaying: true, // make sure that it only plays when you're listening to music. So it won't play when you're sleeping.
timeout: 10, // If the events don't work (to see when it stops playing) or if you turned on a stream, it will revert back after this amount of seconds.
volume: 15, // Set the volume for the notification (and revert back afterwards)
delayMs: 700 // Pause between commands in ms, (when sonos fails to play notification often).
})
})
.catch(console.error)

Expand Down
Loading

0 comments on commit 26d3173

Please sign in to comment.