Skip to main content

Control Denon's HEOS speakers with Python.

Project description

# Control an HEOS player with a Python script

## Requirements

You have an [HEOS][] speaker in your local network and Python 2.7 or
Python 3.

## Usage

0. Install the package with

```
python setup.py install
```

1. Create a `config.json` file, which may reside in the current directory, in
`$HOME/.heospy` or in a directory wich is specified by the environment
variable `$HEOSPY_CONF`. The config file contains the name of the lead
[HEOS][] player you want to control and the username and password of your
[HEOS account][]. See `example-config.json` for an example.

2. Run the script for the first time to see how this works:

$ heos_player
2017-02-12 20:32:29,880 INFO Starting to discover your HEOS player 'Living room' in your local network
2017-02-12 20:32:36,824 INFO Found 'Living room' in your local network
$

3. Now you can call any command from the [CLI specs][specs], see also `docs/`
folder. Additional arguments are given with `-p`. The player id will be
automatically submitted. Some examples:

heos_player player/toggle_mute
heos_player player/set_volume -p level=19
heos_player player/play_preset -p preset=3
heos_player player/set_play_state -p state=stop
heos_player group/toggle_mute
heos_player group/toggle_mute -p gid=-1352658342

Use the flag `--help` for a detailed help.

4. You can also execute a sequence of commands at once. The sequence can be
given in a file:

heos_player -i cmds.txt

An example for `cmds.txt` is:

system/heart_beat
# let's set a volume
player/set_volume level=10
# let's check if the volume is correct
player/get_volume

Note that comments are possible and start with a `#`. You can also get the
sequence of commands from `stdin`:

printf "system/heart_beat\nplayer/set_volume level=10\nplayer/get_volume" | heos_player -i -

[specs]: http://rn.dmglobal.com/euheos/HEOS_CLI_ProtocolSpecification.pdf
[HEOS]: http://heoslink.denon.com
[HEOS account]: http://denon.custhelp.com/app/answers/detail/a_id/1968

## Main player setting

The class `HeosPlayer` assumes a main HEOS player, stored in the config
file. For commands starting with `player/`, we assume that this player should
be used, otherwise you need to specify the player id explicitly as a parameter.

If this player is a lead player in a group, this group is also the main group
for commands starting with `group/`. Again, you can override this setting be
explicitly mention the group id as a parameter.


## Usage with Raspberry Pi and Kodi

If you have [OSMC][] or any other [Kodi Media center][Kodi] implementation on
your [Raspberry Pi][raspi], you can map certain actions for your HEOS on a
[keymap][].

[OSMC]: https://osmc.tv
[raspi]: https://www.raspberrypi.org
[Kodi]: http://kodi.wiki/view/Kodi
[keymap]: http://kodi.wiki/view/Keymaps

Example `keyboard.xml`-file:
```
<keymap>
<global>
<keyboard>
<F1>RunScript(heos_player, player/play_preset, -p, preset=1)</F1>
<F2>RunScript(heos_player, player/play_preset, -p, preset=2)</F2>
<F3>RunScript(heos_player, player/play_preset, -p, preset=3)</F3>
<F4>RunScript(heos_player, player/play_preset, -p, preset=4)</F4>
<F12>RunScript(heos_player, player/set_play_state, -p, state=stop)</F12>
</keyboard>
</global>
<Home>
</Home>
</keymap>
```

## Credits

- first code from <https://github.com/mrjohnsen/heos-python>
- the SSDS discovery library is from
<https://gist.github.com/dankrause/6000248>, with an additional modification
by Adam Baxter to get this working for Python 3.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

heospy-0.1.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distributions

heospy-0.1.0-py2.py3-none-any.whl (13.6 kB view details)

Uploaded Python 2 Python 3

heospy-0.1.0-py2-none-any.whl (13.3 kB view details)

Uploaded Python 2

File details

Details for the file heospy-0.1.0.tar.gz.

File metadata

  • Download URL: heospy-0.1.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15

File hashes

Hashes for heospy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fe3a8f02c3439fc2abc1b62bcccd5608d84dd5b9dcd6f6fe3c961c7eca2a34c7
MD5 70a4422584119ba3b1512dc8cd6cfcd5
BLAKE2b-256 8385169b26eca62db2397a0ec720f9d54e57a0ef7232a5a9e5e24e489bdf818f

See more details on using hashes here.

File details

Details for the file heospy-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: heospy-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15

File hashes

Hashes for heospy-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2537a5a642ab507e9b8004dd68110c69c88cb3441e82d3357fee2f4c10b6bd06
MD5 7bf99509d45c007779fbf5b4393ccfb0
BLAKE2b-256 bacf8ac1016b60a32b2cd740b6de0ba83772291051759bd06c8c7b88908a6991

See more details on using hashes here.

File details

Details for the file heospy-0.1.0-py2-none-any.whl.

File metadata

  • Download URL: heospy-0.1.0-py2-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15

File hashes

Hashes for heospy-0.1.0-py2-none-any.whl
Algorithm Hash digest
SHA256 d8ce273bbf6d3bb6cc10f8156e1ff78ca94d7715beb989a8f7f5718066ea6d05
MD5 f064d34c1adac00243fe1678f84bcb3f
BLAKE2b-256 fd29f88de741ce91e1cb13a15c613a09960e90479636825690fd28a1a046dd7f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page