Project

rubydeako

0.0
The project is in a healthy, maintained state
A Ruby implementation of the pydeako library for controlling Deako smart switches via local network discovery and control
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 2.0
~> 1.0
~> 3.0
~> 2.0
 Project Readme

Rubydeako

Gem Version

A Ruby library for interacting with Deako smart switches via local network discovery and control. This is an unoffical port of the Python pydeako library.

📦 RubyGems: https://rubygems.org/gems/rubydeako

Features

  • Device discovery via mDNS/Zeroconf
  • Real-time device state updates
  • Control power and dimming for compatible devices
  • Thread-safe socket communication
  • Automatic connection management with heartbeat monitoring

Installation

Add this line to your application's Gemfile:

gem 'rubydeako'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install rubydeako

Usage

Basic Example

require 'rubydeako'

# Create a discoverer to find Deako devices on the network
discoverer = Rubydeako::Discover::DeakoDiscoverer.new

# Create the main client
deako = Rubydeako::Deako.new(
  discoverer.method(:get_address),
  client_name: "MyRubyApp"
)

begin
  # Connect to a device
  deako.connect
  
  # Discover all devices
  deako.find_devices
  
  # List discovered devices
  deako.devices.each do |uuid, device|
    puts "Device: #{device['name']} (#{uuid})"
    puts "  Power: #{device['state']['power']}"
    puts "  Dimmable: #{device['dimmable']}"
  end
  
  # Control a device
  if deako.devices.any?
    first_uuid = deako.devices.keys.first
    
    # Turn on
    deako.control_device(first_uuid, true)
    
    # Dim to 50% (if dimmable)
    if deako.dimmable?(first_uuid)
      deako.control_device(first_uuid, true, dim: 50)
    end
    
    # Turn off
    deako.control_device(first_uuid, false)
  end
  
ensure
  deako.disconnect
  discoverer.stop
end

Device State Callbacks

# Set up a callback for state changes
deako.set_state_callback(uuid) do
  puts "Device #{uuid} state changed!"
  state = deako.get_state(uuid)
  puts "Power: #{state['power']}, Dim: #{state['dim']}"
end

API Reference

Main Classes

Rubydeako::Deako

The main client class for controlling Deako devices.

Methods:

  • connect - Establish connection to devices
  • disconnect - Close all connections
  • find_devices(timeout: 10) - Discover devices on network
  • control_device(uuid, power, dim: nil) - Control device state
  • get_name(uuid) - Get device name
  • get_state(uuid) - Get device current state
  • dimmable?(uuid) - Check if device supports dimming
  • set_state_callback(uuid, callback) - Set state change callback

Rubydeako::Discover::DeakoDiscoverer

Handles mDNS discovery of Deako devices.

Methods:

  • start - Begin device discovery
  • stop - Stop discovery
  • get_address - Get discovered device address

Dependencies

  • dnssd - mDNS/Zeroconf service discovery
  • async - Asynchronous I/O operations
  • concurrent-ruby - Thread-safe collections

Development

After checking out the repo, run bundle install to install dependencies. Then, run bundle exec rspec to run the tests.

Contributing

Bug reports and pull requests are welcome on GitHub.

License

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

Acknowledgments

This library is a Ruby port of the Python pydeako library.