All Projects → karlentwistle → Ruby_home

karlentwistle / Ruby_home

Licence: mit
Ruby HAP Server - HomeKit support for the Rubyist

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Ruby home

Homebridge
HomeKit support for the impatient
Stars: ✭ 19,073 (+12205.16%)
Mutual labels:  homekit, siri, hap
Hap Nodejs
Node.js implementation of the HomeKit Accessory Protocol (HAP)
Stars: ✭ 2,541 (+1539.35%)
Mutual labels:  homekit, siri, hap
Secure Video Specification
Documentation and examples of the HomeKit Secure-Video Specification
Stars: ✭ 99 (-36.13%)
Mutual labels:  homekit, hap
homebridge-dyson-fan
A Homebridge plugin for controlling a Dyson fan.
Stars: ✭ 17 (-89.03%)
Mutual labels:  homekit, siri
Docker Homebridge
Homebridge Docker. HomeKit support for the impatient using Docker on x86_64, Raspberry Pi (armhf) and ARM64. Includes ffmpeg + libfdk-aac.
Stars: ✭ 1,847 (+1091.61%)
Mutual labels:  homekit, siri
esp-homekit-direct
Connect HomeKit using esp8266 without HomeBridge
Stars: ✭ 72 (-53.55%)
Mutual labels:  homekit, siri
nativescript-homekit
🏡 HomeKit plugin for your fancy NativeScript app
Stars: ✭ 23 (-85.16%)
Mutual labels:  homekit, siri
Hap
Swift implementation of the Homekit Accessory Protocol
Stars: ✭ 309 (+99.35%)
Mutual labels:  homekit, hap
homebridge-nello
Homebridge plugin for the smart intercom nello.io.
Stars: ✭ 26 (-83.23%)
Mutual labels:  homekit, siri
Hap Python
A python implementation of the HomeKit Accessory Protocol (HAP)
Stars: ✭ 381 (+145.81%)
Mutual labels:  homekit, hap
Esp32 Homekit
ESP-32 implementation of Apple Homekit Accessory Protocol(HAP)
Stars: ✭ 331 (+113.55%)
Mutual labels:  homekit, hap
Homebridge Govee
Homebridge plugin to control Govee devices supported by the official Govee API.
Stars: ✭ 33 (-78.71%)
Mutual labels:  homekit, siri
awesome-homebridge
Popular list of Homebridge Plugins
Stars: ✭ 106 (-31.61%)
Mutual labels:  homekit, siri
HAS
Homekit Accessory Server
Stars: ✭ 53 (-65.81%)
Mutual labels:  homekit, hap
Hc
hc is a lightweight framework to develop HomeKit accessories in Go.
Stars: ✭ 1,660 (+970.97%)
Mutual labels:  homekit, hap
homebridge-wink3
Homebridge plugin for wink.com
Stars: ✭ 53 (-65.81%)
Mutual labels:  homekit, siri
Homekit2mqtt
HomeKit to MQTT bridge 🏡📱
Stars: ✭ 286 (+84.52%)
Mutual labels:  homekit, siri
ESP8266-HomeKit-Air-Quality-Sensor-Elgato-Eve-Room
ESP8266 based  Homekit Indoor Air Quality sensor that acts like Eve Room🌱
Stars: ✭ 58 (-62.58%)
Mutual labels:  homekit, hap
homebridge-yeelight-platform
Homebridge plugin for Yeelight Lights supporting Scenes/Moods/Color Flow/Custom Presets/Music Flow/Night Mode
Stars: ✭ 53 (-65.81%)
Mutual labels:  homekit, siri
Homebridge Http Switch
Powerful http switch for Homebridge: https://github.com/homebridge/homebridge
Stars: ✭ 111 (-28.39%)
Mutual labels:  homekit, hap

Maintainability

ruby_home

ruby_home is an implementation of the HomeKit Accessory Protocol (HAP) to create your own HomeKit accessory in Ruby. HomeKit is a set of protocols and libraries to access devices for home automation. A non-commercial version of the protocol documentation is available on the HomeKit developer website.

Installation

libsodium

To use ruby_home, you will need to install libsodium:

At least version 1.0.9 is required.

For OS X users, libsodium is available via homebrew and can be installed with:

brew install libsodium

For Debian users, libsodium is available via apt:

sudo apt-get install libsodium-dev

ruby_home

Add this line to your application's Gemfile:

gem 'ruby_home'

And then execute:

$ bundle

Or install it yourself with:

$ gem install ruby_home

Basic usage

Create a fan with an on/off switch:

require 'ruby_home'

accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
fan = RubyHome::ServiceFactory.create(:fan)

fan.on.after_update do |updated_value|
  if updated_value
    puts "Fan switched on"
  else
    puts "Fan switched off"
  end
end

RubyHome.run

Examples

The following example services are available:

Sensors

Controlables

Configuration

The configuration options can be set by using the configure helper:

RubyHome.configure do |c|
  c.discovery_name = 'My Home'
end

The following is the full list of available configuration options:

Method Description Default Example Type
discovery_name The user-visible name of the accessory "RubyHome" "My Home" String
model_name The model name of the accessory "RubyHome" "Device1,1" String
password Used for pairing, must conform to the format XXX-XX-XXX where each X is a 0-9 digit and dashes are required Randomly generated "101-48-005" String
host The hostname or IP address of the interface to listen on "0.0.0.0" "192.168.0.2" String
port The port that should be used when starting the built-in web server 4567 8080 Integer
category_identifier Indicates the category that best describes the primary function of the accessory. :bridge :fan Symbol

Customization

RubyHome tries to provide sane defaults for all services. Customization of any of the options is possible.

require 'ruby_home'

accessory_information = RubyHome::ServiceFactory.create(:accessory_information,
  firmware_revision: '4.3.18421',
  manufacturer: 'Fake Company',
  model: 'BSB001',
  name: 'Kickass fan bridge',
  serial_number: 'AB1-UK-A123456',
  category_identifier: :fan
)

fan = RubyHome::ServiceFactory.create(:fan,
  on: false,
  rotation_speed: 50,
  rotation_direction: 1,
  firmware_revision: '105.0.21169',
  manufacturer: 'Fake Company',
  model: 'LWB006',
  name: 'Kickass fan',
  serial_number: '123-UK-A12345'
)

fan.on.after_update do |updated_value|
  if updated_value
    puts "Fan switched on"
  else
    puts "Fan switched off"
  end
end

RubyHome.run

Updating a characteristics value

If you have a service with characteristics that can be changed outside of Ruby Home, you'll want to keep Ruby Home in sync with these modifications. Otherwise, the characteristics current value won't correspond with reality. The simplest way to do this is a background job that periodically polls the devices current status and updates the corresponding characteristics value if it's changed.

Given a fan which can be switched on / off with a remote control, which has a JSON API endpoint at http://example.org/fan_status.json that returns its current status { "on": true } or { "on": false }, we can spawn a thread that keeps polling the fans current status and if it's changed update our fan service "on" characteristic.

require 'json'
require 'open-uri'
require 'ruby_home'

fan = RubyHome::ServiceFactory.create(:fan)

Thread.new do
  def fetch_fan_status
    json = JSON.load(open("http://example.org/fan_status.json"))
    json["on"]
  end

  loop do
    sleep 10 # seconds

    current_fan_status = fetch_fan_status

    unless fan.on == current_fan_status
      fan.on = current_fan_status
    end
  end
end

RubyHome.run

Development

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

Contributing

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

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].