All Projects → ol-iver → denonavr

ol-iver / denonavr

Licence: MIT License
Automation Library for Denon AVR receivers.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to denonavr

ioBroker.denon
Denon AVR adapter for ioBroker
Stars: ✭ 15 (-88.1%)
Mutual labels:  home-automation, denon, marantz
HADailySensor
Sensor for Home Assistant that gets reset at midnight
Stars: ✭ 20 (-84.13%)
Mutual labels:  home-automation, home-assistant
mac-api
Command your Mac from afar
Stars: ✭ 33 (-73.81%)
Mutual labels:  home-automation, home-assistant
homeassistant-lightwave2
Lightwave RF custom component for Home Assistant. Requires generation 2 ("Link Plus") hub, but will control both generation 1 ("Connect Series") and generation 2 ("Smart Series") devices.
Stars: ✭ 31 (-75.4%)
Mutual labels:  home-automation, home-assistant
light-card
Lovelace light-card for home assistant
Stars: ✭ 18 (-85.71%)
Mutual labels:  home-automation, home-assistant
issues
Issue Tracker for ESPHome
Stars: ✭ 182 (+44.44%)
Mutual labels:  home-automation, home-assistant
texecom2mqtt-hassio
Home Assistant add-on. Connect to Texecom Premier Elite alarm panels and publish updates to MQTT. Supports arming/disarming as well as zone updates and alarm events.
Stars: ✭ 15 (-88.1%)
Mutual labels:  home-automation, home-assistant
works-with-home-assistant
Equipment and software that works with Home Assistant
Stars: ✭ 32 (-74.6%)
Mutual labels:  home-automation, home-assistant
awesome-ha-blueprints
A curated collection of automation blueprints for Home Assistant.
Stars: ✭ 258 (+104.76%)
Mutual labels:  home-automation, home-assistant
soma-ctrl
Node util for controlling SOMA smart shade via MQTT or HTTP
Stars: ✭ 19 (-84.92%)
Mutual labels:  home-automation, home-assistant
amshan-homeassistant
Home Assistant integrasjon for strømmålere (AMS/HAN/P1). Integrasjonen støter både streaming (serieport/TCP-IP) og MQTT (Tibber Pulse, energyintelligence.se etc)
Stars: ✭ 39 (-69.05%)
Mutual labels:  home-automation, home-assistant
M5Stack-Air-Quality-ESPHome
ESPHome configuration for M5Stack's PM2.5 Air Quality Kit with the PMSA003 particulate matter sensor and the SHT20 temperature and humidity sensor
Stars: ✭ 19 (-84.92%)
Mutual labels:  home-automation, home-assistant
PiBuilder
Ideas for building a Raspberry Pi from "bare metal" to ready-to-run IOTstack
Stars: ✭ 26 (-79.37%)
Mutual labels:  home-automation, home-assistant
homeassistant-config
My elaborate home automation configuration + scripts
Stars: ✭ 17 (-86.51%)
Mutual labels:  home-automation, home-assistant
ha-config-ataraxis
My Home Assistant Configs. If you like what you see, please ⭐️my repo. It would encourage me a lot 🤘
Stars: ✭ 146 (+15.87%)
Mutual labels:  home-automation, home-assistant
home-assistant-config
Ma configuration Home Assistant commentée en anglais et en français | My Home Assistant config with French and English comments.
Stars: ✭ 29 (-76.98%)
Mutual labels:  home-automation, home-assistant
home-assistant-notebooks
📓 Sample Jupyter Notebooks to explore Home Assistant data
Stars: ✭ 49 (-61.11%)
Mutual labels:  home-automation, home-assistant
smart-home
🏡 My smart home setup built on top of Home Assistant
Stars: ✭ 140 (+11.11%)
Mutual labels:  home-automation, home-assistant
bom-weather-card
Custom Animated Weather Card for any weather provider
Stars: ✭ 111 (-11.9%)
Mutual labels:  home-automation, home-assistant
hhnl.HomeAssistantNet
No description or website provided.
Stars: ✭ 31 (-75.4%)
Mutual labels:  home-automation, home-assistant

denonavr

Version Build Status PyPi License

Automation Library for Denon AVR receivers - current version 0.10.10

Important changes for version 0.10.0 and above

async

As of version 0.10.0 and newer, the denonavr library has switched to usingasync methods to interact with Denon receivers.

Legacy synchronous methods are still availlable to avoid breaking existing implementations, but may be deprecated in the future. Switching to async methods is recommended. The existing sync methods are inefficient because they use the corresponding async methods by starting and stopping its own asyncio loop for each command.

Other changes:

When creating a new instance of DenonAVR there are no longer any API calls to avoid blocking the event loop. To initialize setup of your receiver you would use(async_)setup() and (async_)update() methods to populate the attributes. Calling (async_)update() invokes a call of async_setup() if the instance was not setup yet.

Methods do not return True or False anymore. If successful, None is returned. Otherwise an exception is raised from a class in denonavr/exceptions.py.

It is no longer assumed that a command was successful even when the receiver returns an HTTP 200 OK. This is because the receiver can return an HTTP 200 OK from some endpoints even when the API call has failed. As an example, you now have to call (async_)update() after you call (async_)power_off() to see the power attribute change.

Installation

Use pip:

$ pip install denonavr

or

$ pip install --use-wheel denonavr

Usage with async

Writing async and await methods are outside the scope of the documentation. You can test async usage from the Python REPL. In a terminal run:

python3 -m asyncio

The asyncio library should automatically be imported in the REPL. Import the denonavr library and set up your receiver. If you know the IP address, enter it below replacing 192.168.1.119.

>>> import asyncio
>>> import denonavr
>>> d = denonavr.DenonAVR("192.168.1.119")
>>> await d.async_setup()
>>> await d.async_update()
>>> print(d.volume)
-36.5

Power & Input

>>> await d.async_power_on()
>>> await d.async_update()
>>> d.power
'ON'

>>> await d.async_power_off()
>>> await d.async_update()
>>> d.power
'OFF'

>>> d.input_func
'Tuner'
>>> await d.async_set_input_func("Phono")
>>> d.input_func
'Phono'

Sound

>>> await d.async_mute_on(True)
>>> await d.async_mute_off(False)

Other methods

Other async methods available include:

  • d.async_bass_down
  • d.async_bass_up
  • d.async_treble_down
  • d.async_treble_up
  • d.async_volume_down
  • d.async_volume_up
  • d.async_set_volume(50)

Legacy Usage

Note: Legacy sync methods are still available, but may be deprecated in the future. It is recommended to use the async methods described above. The existing sync methods in versions 0.9.10 and below are inefficient as they use the corresponding async methods by starting and stopping its own asyncio loop for each command.

For creation of a device you could use the following lines of codes

import denonavr
d = denonavr.DenonAVR("192.168.0.250", "Name of device (Optional)")

Library is not polling the Denon device. Thus you need to update device information using the update method.

d.update()

Some basic automatic discovery functions for uPnP devices using SSDP broadcast are available. It is either possible to just discover the Denon AVR devices in the LAN zone or to create instances for each discovered device directly.

discovered_devices = denonavr.discover()
instanced_devices = denonavr.init_all_receivers()

In addition to the Main Zone which is always started, Zone2 and Zone3 of the receiver can be started assigning a dictionary to the add_zones parameter when creating the instance of the receiver.

import denonavr
zones = {"Zone2": "Name of Zone2", "Zone3": "Name of Zone 3"}
d = denonavr.DenonAVR("192.168.0.250", name="Name of Main Zone", add_zones=zones)

Each Zone is represented by an own instance which is assigned to the device instance by the zones attribute with type dictionary.

d.zones
{'Zone2': <denonavr.denonavr.DenonAVRZones object at 0x000001F893EB7630>, 'Main': <denonavr.denonavr.DenonAVR object at 0x000001F8964155F8>, 'Zone3': <denonavr.denonavr.DenonAVRZones object at 0x000001F896415320>}

Some code examples for the Main Zone:

>>> import denonavr
>>> d = denonavr.DenonAVR("192.168.0.250")
>>> d.update()
>>> d.power
'STANDBY'
>>> d.power_on()
>>> d.update()
>>> d.power
'ON'
>>> d.name
'Denon AVR-X4100W'
>>> d.artist
'Wynton Marsalis'
>>> d.title
"When It's Sleepytime Down South"
>>> d.image_url
'http://192.168.0.250/NetAudio/art.asp-jpg?1480031583'
>>> d.next_track()
>>> d.previous_track()
>>> d.volume
-43.5
>>> d.volume_up()
>>> d.update()
>>> d.volume
-43.0
>>> d.volume_down()
>>> d.set_volume(-40.0)
>>> d.update()
>>> d.volume
-40.0
>>> d.mute(True)
>>> d.mute(False)
>>> d.toggle_play_pause()
>>> d.toggle_play_pause()
>>> d.input_func
'Online Music'
>>> d.input_func_list
['AUX', 'AUX2', 'Blu-ray', 'Bluetooth', 'CBL/SAT', 'CD', 'DVD', 'Game', 'Internet Radio', 'Media Player', 'Media Server', 'Online Music', 'Phono', 'TV Audio', 'Tuner', 'iPod/USB']
>>> d.set_input_func("Tuner")
>>> d.update()
>>> d.input_func
'Tuner'
>>> d.power_off()

>>> discovered_devices = denonavr.discover()
discovered_devices
[{'friendlyName': 'Denon AVR-X4100W', 'host': '192.168.0.250', 'modelName': '*AVR-X4100W', 'presentationURL': 'http://192.168.0.250'}]
>>> discovered_denon = denonavr.DenonAVR(discovered_devices[0]['host'])
>>> discovered_denon.power
'STANDBY'

>>> instanced_devices = denonavr.init_all_receivers()
>>> instanced_devices
[<denonavr.denonavr.DenonAVR object at 0x000001AF8EA63E10>]
>>> instanced_devices[0].update()
>>> instanced_devices[0].power
'STANDBY'
>>> instanced_devices[0].power_on()
>>> instanced_devices[0].update()
>>> instanced_devices[0].power
'ON'
>>> instanced_devices[0].power_off()
>>> instanced_devices[0].update()
>>> instanced_devices[0].power
'STANDBY'

The code examples for the Main Zone instance d from above are working for all zones. The other zones (and Main Zone as well) could be accessed via zones attribute.

d.zones['Zone2'].power
'OFF'
d.zones['Zone2'].power_on()
d.zones['Zone2'].update()
d.zones['Zone2'].power
'ON'
d.zones['Zone2'].power_off()
d.zones['Zone2'].update()
d.zones['Zone2'].power
'OFF

Collection of HTTP calls

For a collection of HTTP calls for Denon receivers please have a look at the doc folder.

License

MIT

Author

@ol-iver: https://github.com/ol-iver

Contributors

@soldag: https://github.com/soldag
@shapiromatron: https://github.com/shapiromatron
@glance-: https://github.com/glance-
@p3dda: https://github.com/p3dda
@russel: https://github.com/russell
@starkillerOG: https://github.com/starkillerOG
@andrewsayre: https://github.com/andrewsayre
@JPHutchins: https://github.com/JPHutchins
@MarBra: https://github.com/MarBra

Users

Home Assistant: https://github.com/home-assistant/home-assistant/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].