Ewelink
Ruby API to manage eWeLink smart home devices.
Installation
Just add this into your Gemfile
:
gem 'ewelink'
Then, just run bundle install
.
Examples
Displaying all switches
require 'ewelink'
api = Ewelink::Api.new(email: 'john@example.com', password: 'secr$t')
api.switches.each do |switch|
puts switch[:name]
puts switch[:uuid]
end
email
or phone_number
must be specified for authentication.
Displaying all RF bridge buttons
require 'ewelink'
api = Ewelink::Api.new(email: 'john@example.com', password: 'secr$t')
api.rf_bridge_buttons.each do |button|
puts button[:name]
puts button[:uuid]
end
Turn switch on or off
require 'ewelink'
api = Ewelink::Api.new(phone_number: '+687 414243', password: 'secr$t')
api.turn_switch!(switch[:uuid], :on)
api.turn_switch!(switch[:uuid], :off)
Or :
api.turn_switch!(switch[:uuid], true)
api.turn_switch!(switch[:uuid], false)
Check if switch is on
require 'ewelink'
api = Ewelink::Api.new(phone_number: '+687 414243', password: 'secr$t')
puts api.switch_on?(switch[:uuid])
Press RF bridge button
require 'ewelink'
api = Ewelink::Api.new(email: 'john@example.com', password: 'secr$t')
api.press_rf_bridge_button!(button[:uuid])
Additional options
-
async_actions
(true
|false
): To perform actions (pressing an RF bridge button or turning a switch on/off) in asynchronous mode. (default:false
). -
update_devices_status_on_connect
(true
|false
): To update devices status (on, off) when connecting to Ewelink API (default:false
).
Configuring logger
In order to have some debug informations about what kagu does, you could configure its logger:
Ewelink.logger = Logger.new(STDERR)
Executable
This gem also provides a ewelink
executable, just run it with
--help
option to get all available options.