Ewelink

Ruby API to manage eWeLink smart home devices.

Installation

Just add this into your Gemfile:

ruby gem 'ewelink'

Then, just run bundle install.

Examples

Displaying all switches

```ruby require ‘ewelink’

api = Ewelink::Api.new(email: ‘[email protected]’, 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

```ruby require ‘ewelink’

api = Ewelink::Api.new(email: ‘[email protected]’, password: ‘secr$t’) api.rf_bridge_buttons.each do |button| puts button[:name] puts button[:uuid] end ```

Turn switch on or off

```ruby 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 :

ruby api.turn_switch!(switch[:uuid], true) api.turn_switch!(switch[:uuid], false)

Check if switch is on

```ruby require ‘ewelink’

api = Ewelink::Api.new(phone_number: ‘+687 414243’, password: ‘secr$t’) puts api.switch_on?(switch[:uuid]) ```

Press RF bridge button

```ruby require ‘ewelink’

api = Ewelink::Api.new(email: ‘[email protected]’, 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:

ruby Ewelink.logger = Logger.new(STDERR)

Executable

This gem also provides a ewelink executable, just run it with --help option to get all available options.