Module: Ketra::Commands

Defined in:
lib/ketra/commands.rb

Overview

This module is used to execute specific Ketra API commands

Class Method Summary collapse

Class Method Details

.activate_button(keypad, button, level = 65535) ⇒ Hash

Activates a keypad button at a specific brightness level

Parameters:

  • keypad (String)

    the GUID or Name of the keypad containing the button you want to activate

  • button (String)

    the GUID or Name of the keypad button you want to activate

  • level (Integer) (defaults to: 65535)

    (65535) the brightness level from 0 to 65535

Returns:

  • (Hash)

    deserialized response hash



13
14
15
16
# File 'lib/ketra/commands.rb', line 13

def self.activate_button(keypad, button, level=65535)
  Ketra.client.post("Keypads/#{keypad}/Buttons/#{button}/Activate",
                    :Level => level)
end

.deactivate_button(keypad, button) ⇒ Hash

Deactivates a keypad button

Parameters:

  • keypad (String)

    the GUID or Name of the keypad containing the button you want to deactivate

  • button (String)

    the GUID or Name of the keypad button you want to deactivate

Returns:

  • (Hash)

    deserialized response hash



23
24
25
26
# File 'lib/ketra/commands.rb', line 23

def self.deactivate_button(keypad, button)
  Ketra.client.post("Keypads/#{keypad}/Buttons/#{button}/Deactivate",
                    :Level => 0)
end

.groupsHash

Queries for the available Ketra Groups

Returns:

  • (Hash)

    deserialized response hash containing the group info, see Ketra API documentation for details



49
50
51
# File 'lib/ketra/commands.rb', line 49

def self.groups
  Ketra.client.get("Groups")
end

.keypadsHash

Queries for the available Ketra Keypads

Returns:

  • (Hash)

    deserialized response hash containing the keypad info, see Ketra API documentation for details



42
43
44
# File 'lib/ketra/commands.rb', line 42

def self.keypads
  Ketra.client.get("Keypads")
end

.push_button(keypad, button) ⇒ Hash

Pushes a keypad button which will either activate or deactivate based on its current state and the configuration of the keypad settings

Parameters:

  • keypad (String)

    the GUID or Name of the keypad containing the button you want to deactivate

  • button (String)

    the GUID or Name of the keypad button you want to deactivate

Returns:

  • (Hash)

    deserailized response hash



34
35
36
37
# File 'lib/ketra/commands.rb', line 34

def self.push_button(keypad, button)
  Ketra.client.post("Keypads/#{keypad}/Buttons/#{button}/PushButton",
                    :query_params => { :idempotency_key => SecureRandom.hex })
end