GithubHelp home page GithubHelp logo

denon_avr's Introduction

DenonAvr

This gem allows you to control your Denon AVR home theater receiver programatically.

Current features:

  • Power on and off
  • Source input select
  • Set volume
  • Mute and unmute
  • Multi-zone support for all functions

Usage

require 'denon_avr'

# For :host, use your receiver's IP address
receiver = DenonAvr::Receiver.new(host: '10.0.1.20')
receiver.power_on
receiver.input = 'Phono'
receiver.volume = 40

# For multi-zone support, instantiate with an optional :add_zones param:
receiver = DenonAvr::Receiver.new(host: '10.0.1.20', add_zones: ['Zone2', 'Zone3'])
receiver.zone2.power_on
receiver.zone2.input = 'CD'
receiver.zone2.volume = 32.0

Architectural Note

Most functions are implemented on an instance of Denon::Receiver::Zone for optimal multi-zone support. Methods such as receiver.power_on are actually delegated to the Main Zone; they are identical to calling, for example, receiver.main_zone.power_on.

Receiver Status

# Example Receiver instantiation
receiver = DenonAvr::Receiver.new(host: '10.0.1.239', add_zones: ['Zone2'])
 # => #<DenonAvr::Receiver:3fd47f0be51c @host="10.0.1.239", @zones=[#<DenonAvr::Receiver::Zone:3fd47f0d64b4 @name="MainZone", @volume=20.0, @input="Sonos", @power="ON", @muted=false>, #<DenonAvr::Receiver::Zone:3fd47f0de5b0 @name="Zone2", @volume=42.0, @input="Sonos", @power="ON", @muted=false>]>

 receiver.host == '10.0.1.239' # No setter on this attribute

 receiver.zones == [receiver.main_zone, receiver.zone2]

 receiver.volume == 20.0
 receiver.volume == receiver.main_zone.volume

 receiver.input == 'Sonos' # Respects renamed input

 receiver.power == 'ON'
 receiver.power == DenonAvr::Receiver::POWER_ON

 # Update status, refreshes all of the above
 receiver.get_status

Power

# Identical
receiver.power = :on
receiver.power = true
receiver.power = 'On'
receiver.power = Denon::Receiver::POWER_ON
receiver.power_on
receiver.main_zone.power_on

# Zones
receiver.zone2.power = true
receiver.zone3.power_on

# Powering off examples
receiver.power = false
receiver.power = :off
receiver.power_off

# Turn off all zones
receiver.all_off

Mute / Unmute

receiver.mute
# These methods are identical
receiver.muted == receiver.muted? == true

receiver.unmute
receiver.muted? == false

receiver.zone2.mute = true
receiver.zone2.muted? == true

Volume

receiver.volume = 24

receiver.zone2.volume = 45.5

Input Select

receiver.input = 'Blu-ray'
receiver.zone2.input = 'CD'

# If you have renamed a source, the new name will be used
receiver.input = 'Apple TV'

# To get a list of source names available, use this method.
# Note that this will return a hash, the value is the internal mapping
# used by the receiver, and the key is the
# "human" name that should be used.
receiver.source_list

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Attribution

Although this gem does not seek to keep an identical API or design paradigm, it is essentially a ruby port of scarface-471's excellent denonavr python package. Significant thanks must be given for his excellent and extensive work there, of which this gem only implements a portion. Kudos!

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/zeiv/denon_avr.

License

The gem is available as open source under the terms of the MIT License.

denon_avr's People

Contributors

zeiv avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.