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.
Add this line to your application's Gemfile:
gem 'ruby_home'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ruby_home
Create a fan with an on/off switch.
require 'ruby_home'
accessory_information = RubyHome::AccessoryFactory.create(:accessory_information)
fan = RubyHome::AccessoryFactory.create(:fan)
fan.characteristic(:on).on(:updated) do |new_value|
if new_value == 1
puts "Fan switched on"
else
puts "Fan switched off"
end
end
RubyHome::Broadcast.run
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.
Bug reports and pull requests are welcome on GitHub at https://github.com/karlentwistle/ruby_home.